我成功安装了PHPUnit,现在我正在尝试使用Zend Framework 1.x.我检查了各处不同的方法,但它们都不适合我,因为每次我在“tests”文件夹中执行PHPUnit命令时都会出现以下错误:
警告:require_once(Zend / xxxxxxxxx.php):无法打开流:第12行的C:\ wamp \ www \ square \ tests \ TestHelper.php中没有此类文件或目录“
其中xxxxxxx.php是Application.php,Autoloader.php等。
所以我得出的结论是,PHPUnit或Bootstrap找不到我的Zend库。很奇怪,因为当我在我的生产|开发环境中运行我的项目时没有任何问题(在php.ini中添加到Zend的路由)。
phpunit.xml
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./TestHelper.php">
<testsuite>
<directory>./</directory>
</testsuite>
<filter>
<whitelist>
<directory suffix=".php">../application/</directory>
<exclude>
<directory suffix=".phtml">../application/</directory>
</exclude>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="./log/report" charset="UTF-8"
yui="true" highlight="true"
lowUpperBound="50" highLowerBound="80"/>
<log type="testdox-html" target="./log/testdox.html" />
</logging>
</phpunit>
TestHelper.php
<?php
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'testing'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
/**
* Register autoloader
*/
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
require_once APPLICATION_PATH . '/../tests/application/ControllerTestCase.php';