我刚接触过单元测试,我一直在编写我在互联网上发现的教程:
http://blog.fedecarg.com/2008/12/27/testing-zend-framework-controllers/
我的问题是我根本无法执行本教程中显示的测试!
C
题名/责任者::\wamp\www\portailmg\dev\tests>phpunit PHPUnit . 从C:\wamp\www\portailmg\dev\tests\phpunit.xml读取配置 时间:0秒,内存: 4.00Mb 不执行测试! 生成HTML格式的代码覆盖报告..。完成 C:\wamp\www\portailmg\dev\tests>
我的bootstrap.php是我编辑的唯一文件,因为我有以下错误:
注意: Zend_Loader::Zend_Loader::registerAutoload从1.8.0开始不再推荐使用,并将在2.0.0中删除;在/www/zf-教程/库/Zend/Loader.php中使用Zend_Loader_Autoloader。
我试着用它来解决这个问题:
This is because you have the lines:
require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload();
(or similar) somewhere in your bootstrap system.
The easiest solution is to change them to:
require_once 'Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
$loader->registerNamespace('App_');
Where 'App_' is the name of a directory on your include path that has classes within it that follow the Zend Framework naming convention, so change it as appropriate and add more if you need them.我的鞋带:
<?php
error_reporting( E_ALL | E_STRICT );
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
date_default_timezone_set('Europe/London');
define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../applications'));
define('APPLICATION_ENV', 'loc');
define('LIBRARY_PATH', realpath(dirname(__FILE__) . '/../library'));
define('TESTS_PATH', realpath(dirname(__FILE__)));
$_SERVER['SERVER_NAME'] = 'http://localhost';
$includePaths = array(LIBRARY_PATH, get_include_path());
set_include_path(implode(PATH_SEPARATOR, $includePaths));
require_once 'Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
$loader->registerNamespace('LIBRARY_PATH');
Zend_Session::$_unitTestEnabled = true;
Zend_Session::start();
?>提前感谢您的帮助
发布于 2013-05-27 12:24:18
您的设置看起来还不错,不过如果我没记错的话,ZendFramework1只适用于>=3.5.x,所以可能会将评级从3.7降到3.5。请确保正确设置phpunit.xml文件,并指向测试引导程序,而不是应用程序引导程序。还要确保遵循单元测试名称约定。请参阅http://phpunit.de/manual/3.5/en/index.html
https://stackoverflow.com/questions/16772867
复制相似问题