我在努力获得PHPUnit测试以使用ZF2。带有Zend Framework 2模块的PHPUnit
我的目录结构如下所示
project
- src
- config, data, module, public, vendor
- init_autoloader.php
- test
- bootstrap.php
- SimpleTest.php
本身运作良好的应用。
现在运行PHPUnit测试,我的bootstrap.php如下所示
putenv('ZF2=../src/vendor/zendframework/zendframework/library');
$loader = include '../src/vendor/autoload.php';
include '../src/init_autoloader.php';
这适用于ZF2有关的事情,但是没有找到我的模块。然后我读,我有以下行添加到我的bootstrap.php
Zend\Mvc\Application::init(include '../src/config/application.config.php');
但现在我得到以下错误:
PHP Fatal error: Uncaught exception 'Zend\ModuleManager\Exception\RuntimeException' with message 'Module (Mymodule) could not be initialized.' in /Users/_/src/vendor/zendframework/zendframework/library/Zend/ModuleManager/ModuleManager.php:139
不幸的是,我没能解决这个问题。我做错了什么?我该如何做这项工作?
非常感谢。
看看这个,它为我工作。 http://devblog.x2k.co.uk/getting-phpunit-working-with-a-zend-framework-2-mvc-application/ – vascowhite
他们使用Zend \ Mvc \ Application :: init()和我一样,所以它不适合我。 – str
我很高兴看到你的工作。如果您有兴趣,请点击此处查看我的工作设置https://github.com/vascowhite/ZendMinimumApplication/tree/master/test。 – vascowhite