大佬教程收集整理的这篇文章主要介绍了zend-framework2 – Zend Framework 2教程:Module(Application)无法初始化,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
user@xubuntu1210:~/Desktop/zf2-tutorial/module/Application/test$PHPunit PHPUnit 3.7.13 by Sebastian BergmAnn. Configuration read from /home/user/Desktop/zf2-tutorial/module/Application/test/PHPunit.xml.dist E Time: 0 seconds,Memory: 4.00Mb There was 1 error: 1) ApplicationTest\Controller\IndexControllerTest::tesTindexActionCanBeAccessed Zend\ModuleManager\Exception\RuntimeException: Module (Application) Could not be initialized. /home/user/Desktop/zf2-tutorial/vendor/zendframework/zendframework/library/Zend/ModuleManager/ModuleManager.PHP:140 /home/user/Desktop/zf2-tutorial/vendor/zendframework/zendframework/library/Zend/ModuleManager/ModuleManager.PHP:81 /home/user/Desktop/zf2-tutorial/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.PHP:460 /home/user/Desktop/zf2-tutorial/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.PHP:204 /home/user/Desktop/zf2-tutorial/vendor/zendframework/zendframework/library/Zend/ModuleManager/ModuleManager.PHP:100 /home/user/Desktop/zf2-tutorial/vendor/zendframework/zendframework/library/Zend/Mvc/Application.PHP:239 /home/user/Desktop/zf2-tutorial/vendor/zendframework/zendframework/library/Zend/Test/PHPUnit/Controller/AbstractControllerTESTCase.PHP:146 /home/user/Desktop/zf2-tutorial/vendor/zendframework/zendframework/library/Zend/Test/PHPUnit/Controller/AbstractControllerTESTCase.PHP:173 /home/user/Desktop/zf2-tutorial/vendor/zendframework/zendframework/library/Zend/Test/PHPUnit/Controller/AbstractControllerTESTCase.PHP:193 /home/user/Desktop/zf2-tutorial/vendor/zendframework/zendframework/library/Zend/Test/PHPUnit/Controller/AbstractControllerTESTCase.PHP:236 /home/user/Desktop/zf2-tutorial/module/Application/test/ApplicationTest/Controller/IndexControllerTest.PHP:20 @R_432_4895@! Tests: 1,Assertions: 0,Errors: 1.
我从教程中复制了IndexControllerTest.PHP的内容.
<?PHP namespace ApplicationTest\Controller; use Zend\Test\PHPUnit\Controller\AbstracthttpControllerTESTCase; class IndexControllerTest extends AbstracthttpControllerTESTCase { public function setUp() { $this->setApplicationConfig( include '/home/user/Desktop/zf2-tutorial/config/application.config.PHP' ); parent::setUp(); } public function tesTindexActionCanBeAccessed() { $this->dispatch('/'); // this is line 20 $this->assertResponseStatusCode(200); $this->assertModule('application'); $this->assertControllerName('application_index'); $this->assertControllerClass('IndexController'); $this->assertMatchedRoutename('home'); } }
我不知道为什么应用程序不会初始化,我会欣赏任何指针.
该application.config.PHP可能如下所示:
return array( 'modules' => array( 'Application','Album',),'module_listener_options' => array( 'module_paths' => array( './module','./vendor',);
要解决您的问题,请将./module的值更改为绝对路径,例如__DIR__. ‘/../module,假设application.config.PHP在应用程序的根目录中的config /中.
要澄清:问题发生是因为./module是一个相对于你的cwd的路径.你的cwd运行PHPunit是在测试目录里,哪里没有(显然)任何模块目录.
以上是大佬教程为你收集整理的zend-framework2 – Zend Framework 2教程:Module(Application)无法初始化全部内容,希望文章能够帮你解决zend-framework2 – Zend Framework 2教程:Module(Application)无法初始化所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。