带有Zend Framework 2模块的PHPUnit [英] PHPUnit with a Zend Framework 2 module
本文介绍了带有Zend Framework 2模块的PHPUnit的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在努力使PHPUnit测试与ZF2一起使用.
I'm struggling in getting a PHPUnit test to work with ZF2.
我的目录结构如下
project
- src
- config, data, module, public, vendor
- init_autoloader.php
- test
- bootstrap.php
- SimpleTest.php
应用程序本身运行良好.
The application itself works well.
现在可以运行PHPUnit测试了,我的bootstrap.php如下所示
Now for running PHPUnit tests, my bootstrap.php looks as follows
putenv('ZF2=../src/vendor/zendframework/zendframework/library');
$loader = include '../src/vendor/autoload.php';
include '../src/init_autoloader.php';
这适用于ZF2相关的东西,但找不到我的模块.然后,我读到我必须将以下行添加到bootstrap.php
This works for ZF2 related things but does not find my module. I then read that I have to add the following line to my bootstrap.php
Zend\Mvc\Application::init(include '../src/config/application.config.php');
但是现在我收到以下错误:
But now I get the following error:
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
很遗憾,我无法解决此问题.我做错什么了?而我该如何做呢?
Unfortunately, I was not able to resolve this issue. What did I do wrong? And how can I make this work?
非常感谢您.
推荐答案
同时,我能够使用 查看全文