symfony - codeception symfony2 unit test throws a fatal error -


using classical phpunit style generate:test symfony2 helper. can service , can assert ok.

// tests public function testgetserviceurl() { $ecservice = $this->getmodule('symfony2')->grabservicefromcontainer("ecservice");

    $this->assertequals("https://ecoconnect2.niwa.co.nz/services", $ecservice->getserviceurl());     $this->assertequals("xxx", $ecservice->getserviceurl());  } 

however in second case assertion fails exception:

    trying test service url (demotest::testgetserviceurl) - failed     php fatal error:  call member function getresponse() on non-object in /users/watkinsav/workspace/cd/ecoconnect_web/vendor/codeception/codeception/src/codeception/util/framework.php on line 30     php stack trace:     php   1. {main}() /users/watkinsav/workspace/cd/ecoconnect_web/vendor/codeception/codeception/codecept:0     php   2. symfony\component\console\application->run() /users/watkinsav/workspace/cd/ecoconnect_web/vendor/codeception/codeception/codecept:38     php   3. symfony\component\console\application->dorun() /users/watkinsav/workspace/cd/ecoconnect_web/vendor/symfony/symfony/src/symfony/component/console/application.php:106     php   4. symfony\component\console\command\command->run() /users/watkinsav/workspace/cd/ecoconnect_web/vendor/symfony/symfony/src/symfony/component/console/application.php:193     php   5. codeception\command\run->execute() /users/watkinsav/workspace/cd/ecoconnect_web/vendor/symfony/symfony/src/symfony/component/console/command/command.php:240     php   6. codeception\codecept->runsuite() /users/watkinsav/workspace/cd/ecoconnect_web/vendor/codeception/codeception/src/codeception/command/run.php:74     php   7. codeception\suitemanager->run() /users/watkinsav/workspace/cd/ecoconnect_web/vendor/codeception/codeception/src/codeception/codecept.php:110     php   8. codeception\phpunit\runner->doenhancedrun() /users/watkinsav/workspace/cd/ecoconnect_web/vendor/codeception/codeception/src/codeception/suitemanager.php:132     php   9. phpunit_framework_testsuite->run() /users/watkinsav/workspace/cd/ecoconnect_web/vendor/codeception/codeception/src/codeception/phpunit/runner.php:107     php  10. phpunit_framework_testsuite->runtest() /users/watkinsav/workspace/cd/ecoconnect_web/vendor/phpunit/phpunit/phpunit/framework/testsuite.php:745     php  11. phpunit_framework_testcase->run() /users/watkinsav/workspace/cd/ecoconnect_web/vendor/phpunit/phpunit/phpunit/framework/testsuite.php:775     php  12. phpunit_framework_testresult->run() /users/watkinsav/workspace/cd/ecoconnect_web/vendor/phpunit/phpunit/phpunit/framework/testcase.php:776     php  13. phpunit_framework_testresult->addfailure() /users/watkinsav/workspace/cd/ecoconnect_web/vendor/phpunit/phpunit/phpunit/framework/testresult.php:698     php  14. codeception\phpunit\listener->addfailure() /users/watkinsav/workspace/cd/ecoconnect_web/vendor/phpunit/phpunit/phpunit/framework/testresult.php:307     php  15. codeception\phpunit\listener->fire() /users/watkinsav/workspace/cd/ecoconnect_web/vendor/codeception/codeception/src/codeception/phpunit/listener.php:24     php  16. symfony\component\eventdispatcher\eventdispatcher->dispatch() /users/watkinsav/workspace/cd/ecoconnect_web/vendor/codeception/codeception/src/codeception/phpunit/listener.php:66     php  17. symfony\component\eventdispatcher\eventdispatcher->dodispatch() /users/watkinsav/workspace/cd/ecoconnect_web/vendor/symfony/symfony/src/symfony/component/eventdispatcher/eventdispatcher.php:53     php  18. call_user_func() /users/watkinsav/workspace/cd/ecoconnect_web/vendor/symfony/symfony/src/symfony/component/eventdispatcher/eventdispatcher.php:164     php  19. codeception\subscriber\module->failed() /users/watkinsav/workspace/cd/ecoconnect_web/vendor/symfony/symfony/src/symfony/component/eventdispatcher/eventdispatcher.php:164     php  20. codeception\util\framework->_failed() /users/watkinsav/workspace/cd/ecoconnect_web/vendor/codeception/codeception/src/codeception/subscriber/module.php:47 

this because _failed() function in framework.php tries call client-getresponse(). , don't have response class instantiated.

public function _failed(\codeception\testcase $test, $fail)  {      if (!$this->client->getresponse()) return;      file_put_contents(\codeception\configuration::logdir() . basename($test->getfilename()) . '.page.debug.html',  $this->client->getresponse()->getcontent());  } 

in example blog post here: http://codeception.com/02-12-2013/testing-symfony2.html there lines - not fix problem.

thanks again andrew

well, looks function expected null getresponse.

if (!$this->client->getresponse()) return; 

this line should have blocked screenshot call if no response available. didn't. looks issue. symfony version use?


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -