在“Getting Started with Zend Framework 2”教程中,有一个应用程序基本单元测试的示例:http://zf2.readthedocs.org/en/latest/user-guide/unit-testing.html我刚刚复制了代码(只需将include __DIR__ . '/../init_autoloader.php';
更改为{ {1}})现在我收到了一个错误:
include __DIR__ . '/../../../init_autoloader.php';
当我只使用标准的PHPUnit断言方法如assertEmpty(...)时,它可以正常工作。
这是我的IndexControllerTest.php:
root@devmv:/var/www/sandbox/zf2sandbox/module/Application/test# phpunit
PHPUnit 3.7.13 by Sebastian Bergmann.
Configuration read from /var/www/sandbox/zf2sandbox/module/Application/test/phpunit.xml
E
Time: 0 seconds, Memory: 3.75Mb
There was 1 error:
1) ApplicationTest\Controller\IndexControllerTest::testIndexActionCanBeAccessed
array_replace_recursive(): Argument #1 is not an array
/lib/ZendFramework/ZendFramework-2.1.0/library/Zend/Test/PHPUnit/Controller/AbstractControllerTestCase.php:144
/lib/ZendFramework/ZendFramework-2.1.0/library/Zend/Test/PHPUnit/Controller/AbstractControllerTestCase.php:173
/lib/ZendFramework/ZendFramework-2.1.0/library/Zend/Test/PHPUnit/Controller/AbstractControllerTestCase.php:193
/lib/ZendFramework/ZendFramework-2.1.0/library/Zend/Test/PHPUnit/Controller/AbstractControllerTestCase.php:236
/var/www/sandbox/zf2sandbox/module/Application/test/ApplicationTest/Controller/IndexControllerTest.php:18
FAILURES!
Tests: 1, Assertions: 0, Errors: 1.
有人可以帮忙吗?
THX
答案 0 :(得分:0)
检查你的行
include '/var/www/sandbox/zf2sandbox/config/test/application.config.php'
实际上会生成一个数组。到目前为止,我猜它正在生成false
或者没有返回任何内容。
该文件应如下所示:
<?php
return array(
// ...
);