unit testing - Missing DbAdapter dependencies in Zend Framework 2 PHPUnit -
i have simple controller action
<?php namespace application\controller; use zend\mvc\controller\abstractactioncontroller; use zend\view\model\viewmodel; class indexcontroller extends abstractactioncontroller { public function myaction() { return new viewmodel(); } }
and want test it:
<?php namespace applicationtest\controller; use zend\test\phpunit\controller\abstracthttpcontrollertestcase; class indexcontrollertest extends abstracthttpcontrollertestcase { public function setup() { $this->setapplicationconfig( include '../../../config/application.config.php' ); /* $test = $this->getapplicationconfig(); print_r($test); die('~~~'); */ parent::setup(); } public function testindexactioncanbeaccessed() { $this->dispatch('/my'); $this->assertresponsestatuscode(200); $this->assertmodulename('application'); $this->assertcontrollername('application\controller\index'); $this->assertcontrollerclass('indexcontroller'); $this->assertmatchedroutename('my'); } }
when start phpunit, error:
1) applicationtest\controller\indexcontrollertest::testindexactioncanbeaccessed zend\servicemanager\exception\servicenotfoundexception: zend\servicemanager\servicemanager::get unable fetch or create instance zend\db\adapter\adapter /path/to/project/vendor/zendframework/zendframework/library/zend/servicemanager/servicemanager.php:456 /path/to/project/module/catalog/module.php:56 /path/to/project/vendor/zendframework/zendframework/library/zend/servicemanager/servicemanager.php:737 /path/to/project/vendor/zendframework/zendframework/library/zend/servicemanager/servicemanager.php:869 /path/to/project/vendor/zendframework/zendframework/library/zend/servicemanager/servicemanager.php:494 /path/to/project/vendor/zendframework/zendframework/library/zend/servicemanager/servicemanager.php:441 /path/to/project/module/catalog/module.php:51 /path/to/project/vendor/zendframework/zendframework/library/zend/servicemanager/servicemanager.php:737 /path/to/project/vendor/zendframework/zendframework/library/zend/servicemanager/servicemanager.php:869 /path/to/project/vendor/zendframework/zendframework/library/zend/servicemanager/servicemanager.php:494 /path/to/project/vendor/zendframework/zendframework/library/zend/servicemanager/servicemanager.php:441 /path/to/project/module/cache/module.php:58 /path/to/project/vendor/zendframework/zendframework/library/zend/servicemanager/servicemanager.php:737 /path/to/project/vendor/zendframework/zendframework/library/zend/servicemanager/servicemanager.php:869 /path/to/project/vendor/zendframework/zendframework/library/zend/servicemanager/servicemanager.php:494 /path/to/project/vendor/zendframework/zendframework/library/zend/servicemanager/servicemanager.php:441 /path/to/project/module/search/module.php:61 /path/to/project/vendor/zendframework/zendframework/library/zend/servicemanager/servicemanager.php:737 /path/to/project/vendor/zendframework/zendframework/library/zend/servicemanager/servicemanager.php:869 /path/to/project/vendor/zendframework/zendframework/library/zend/servicemanager/servicemanager.php:494 /path/to/project/vendor/zendframework/zendframework/library/zend/servicemanager/servicemanager.php:441 /path/to/project/module/search/module.php:81 /path/to/project/vendor/zendframework/zendframework/library/zend/servicemanager/servicemanager.php:737 /path/to/project/vendor/zendframework/zendframework/library/zend/servicemanager/abstractpluginmanager.php:205 /path/to/project/vendor/zendframework/zendframework/library/zend/servicemanager/servicemanager.php:494 /path/to/project/vendor/zendframework/zendframework/library/zend/servicemanager/servicemanager.php:441 /path/to/project/vendor/zendframework/zendframework/library/zend/servicemanager/abstractpluginmanager.php:103 /path/to/project/vendor/zendframework/zendframework/library/zend/view/renderer/phprenderer.php:378 /path/to/project/vendor/zendframework/zendframework/library/zend/view/renderer/phprenderer.php:397 /path/to/project/module/application/view/layout/layout.phtml:76 /path/to/project/module/application/view/layout/layout.phtml:76 /path/to/project/vendor/zendframework/zendframework/library/zend/view/renderer/phprenderer.php:507 /path/to/project/vendor/zendframework/zendframework/library/zend/view/view.php:205 /path/to/project/vendor/zendframework/zendframework/library/zend/mvc/view/http/defaultrenderingstrategy.php:126 /path/to/project/vendor/zendframework/zendframework/library/zend/eventmanager/eventmanager.php:472 /path/to/project/vendor/zendframework/zendframework/library/zend/eventmanager/eventmanager.php:207 /path/to/project/vendor/zendframework/zendframework/library/zend/mvc/view/http/defaultrenderingstrategy.php:136 /path/to/project/vendor/zendframework/zendframework/library/zend/eventmanager/eventmanager.php:472 /path/to/project/vendor/zendframework/zendframework/library/zend/eventmanager/eventmanager.php:207 /path/to/project/vendor/zendframework/zendframework/library/zend/mvc/application.php:332 /path/to/project/vendor/zendframework/zendframework/library/zend/mvc/application.php:307 /path/to/project/vendor/zendframework/zendframework/library/zend/test/phpunit/controller/abstractcontrollertestcase.php:255 /path/to/project/module/application/test/applicationtest/controller/indexcontrollertest.php:37
why? i'm not using dbtable
classes in action.
Comments
Post a Comment