phpunit

TYPO3 4.5 extbase test backend module

﹥>﹥吖頭↗ 提交于 2019-12-11 15:09:42
问题 I search for a way to test my extbase-extension. I work with two different templatepaths for front- and backend. module.myext{ view { templateRootPath = myext/Resources/Private/Backend/Templates/ partialRootPath = myext/Resources/Private/Backend/Partials/ layoutRootPath = myext/Resources/Private/Backend/Layouts/ } } The backendmodule works without any problem, but my test will not get the different templatepath. If i write the view.templateRootPath to config.tx_extbase in the ext_typoscript

PHPUnit Installation on WAMP gives error

北城余情 提交于 2019-12-11 15:06:57
问题 I'm following below post How to install PHPUnit with WAMP? http://nishutayaltech.blogspot.in/2011/04/installing-phpunit-on-windows.html But i'm still getting error as below mentioned D:\wamp\bin\php\php5.5.12>pear channel-discover pear.phpunit.de Discovering channel pear.phpunit.de over http:// failed with message: channel-ad d: Cannot open "http://pear.phpunit.de/channel.xml" (File http://pear.phpunit.de :80/channel.xml not valid (received: HTTP/1.1 410 Gone )) Trying to discover channel

How do I write test(s) for this in Symfony?

▼魔方 西西 提交于 2019-12-11 14:07:10
问题 I'm about to delve into test in the PHP world and I have some questions. I have a controller which handles a loan application. The bulk of the work is then delegated to a ProcessLoanApplication class. ApplyController class ApplyController extends Controller { public function indexAction(Request $request) { $form = $this->createForm(new LoanApplication()); if($request->getMethod() == 'POST') { $form->bind($request); if($form->isValid()) { $session = $this->getRequest()->getSession(); $loan_app

how to unit-test a php method_exists()

牧云@^-^@ 提交于 2019-12-11 13:35:20
问题 having this code <?php public function trueOrFalse($handler) { if (method_exists($handler, 'isTrueOrFalse')) { $result= $handler::isTrueOrFalse; return $result; } else { return FALSE; } } how would you unit-test it? is there a chance to mock a $handler ? obviously i would need some kind of <?php $handlerMock= \Mockery::mock(MyClass::class); $handlerMock->shouldReceive('method_exists')->andReturn(TRUE); but it cannot be done 回答1: Okay In your testCase class you need to use the same namespace

PHPUnit test and abstract class with a method named 'Method'

谁说我不能喝 提交于 2019-12-11 12:49:04
问题 I am in the process of testing an abstract class that has a method called Method . Here is my abstract class (abridged): abstract class ClassToTest { function Method($_value = NULL) { // based on the value passed in a different value is returned. } } Here is my PHPUnit class: class ClassToTestTest extends PHPUnit_Framework_TestCase { public $object = NULL; public function setUp() { $this->object = $this->getMockForAbstractClass('ClassToTest'); } public function testMethod() { // passing no

How to detect last test from TestCase in Laravel?

主宰稳场 提交于 2019-12-11 12:35:24
问题 I can easily detect first test: public static $databaseMigrated = false; protected function setUp() { parent::setUp(); if (TestCase::$databaseMigrated === false) { $this->migrateDatabase(); TestCase::$databaseMigrated = true; } } But does anybody have idea how to detect last test ? protected function tearDown() { // something here ? ? } 回答1: Solution is: public static $databaseMigrated = false; public function setUp() { parent::setUp(); if (TestCase::$databaseMigrated === false) { TestCase::

PHPUnit_Framework_Exception: PHPUnit_Framework_TestCase::$name must not be null

喜夏-厌秋 提交于 2019-12-11 12:21:04
问题 I am developing on a vagrant box which was custom built to serve the purpose. My PHPUnit version is 5.2.12 and Laravel version is 5.2.22 . When I am executing phpunit command, I get the following errors: PHPUnit_Framework_Exception: PHPUnit_Framework_TestCase::$name must not be null. Code Below is my phpunit.xml content: <?xml version="1.0" encoding="UTF-8"?> <phpunit backupGlobals="false" backupStaticAttributes="false" bootstrap="bootstrap/autoload.php" colors="true"

Test a recursive method

帅比萌擦擦* 提交于 2019-12-11 12:20:01
问题 I want test a method public function get($key) { if (!($time = $this->driver->get($key))) { if ($key == self::LAST_UPDATE_KEY) { $time = new \DateTime(); $this->driver->set($key, $time); } else { $time = $this->get(self::LAST_UPDATE_KEY); // need test this condition } } return $time; } The first request data from the driver should return null, while the second meaning is necessary to me. I write a test public function testGetEmpty() { $time = new \DateTime(); $driver_mock = $this -

Php, how to mock object instantiation?

混江龙づ霸主 提交于 2019-12-11 12:19:49
问题 So, a function: function testMe ($a, $b) { $obj = new CalculationObject(); return $obj->calcIt ($a, $b); } how to mock this creation? 回答1: Refactor the function to separate object creation and object usage. If this is a method of a class, the trivial solution is to make $obj a class property so you can replace it with a mock. If you always need a new instance of CalculationObject , the factory pattern can be used. Example: function testMe ($a, $b) { $obj = $this->factory-

PHPUnit error - Class could not be found

*爱你&永不变心* 提交于 2019-12-11 12:02:21
问题 I just installed PHPUnit 3.5 on my system, upgrading it from 3.4, and I'm having some trouble with the new version. When I try to run a test, I always get the same output. Here's what I get when I try to run on the command line the StackTest example from the PHPUnit manual, example 4.1: > phpunit StackTest X-Powered-By: PHP/5.2.17 Content-type: text/html PHPUnit 3.5.13 by Sebastian Bergmann. Class StackTest could not be found in StackTest.php. Worse yet, when I try to run it from a web