我是单元测试的新手,我一直在研究我在互联网上找到的这个教程:
http://blog.fedecarg.com/2008/12/27/testing-zend-framework-controllers/
我的问题是我根本无法执行教程中显示的测试!
C
:\wamp\www\porttailmg\dev\tests>phpunit PHPUnit 3.7.21 由 Sebastian Bergmann 编写。
从 C:\wamp\www\porttailmg\dev\tests\phpunit.xml 读取的配置
时间:0 秒,内存:4.00Mb
未执行任何测试!
生成 HTML 格式的代码覆盖率报告...完成
C:\wamp\www\porttailmg\dev\tests>
我的 bootstrap.php 是我编辑的唯一文件,因为我有以下错误:
注意: Zend_Loader::Zend_Loader::registerAutoload 自 1.8.0 起已弃用,将在 2.0.0 中删除;在 /www/zf-tutorial/library/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();
?>
在此先感谢您的帮助