PHP单元测试 - 包括项目类的一次错误

时间:2011-12-15 11:32:06

标签: php phpunit

我创建了一些测试,但运行它们存在问题

In bootstrap I have:

    define("BASE_PATH",str_replace("\\","/",dirname(__FILE__)));

//Get an array of your include paths
$include_parts = explode(PATH_SEPARATOR,get_include_path());

//Extend the paths
$include_parts[] = dirname(dirname(BASE_PATH)); //this is ../../

//recompile the paths and set them
set_include_path(implode(PATH_SEPARATOR,$include_parts));
/**
 * Test if phpunit running on php 5.3 or newer
 */
version_compare(PHP_VERSION, '5.3', '<') and exit('Test requires PHP 5.3 or newer.');
error_reporting(E_ALL & ~E_STRICT);
ini_set('display_errors', TRUE);
define('DOC_ROOT','');

运行测试时,我收到警告

警告:include_once():打开失败 '/private/config/abc.php'包含在内 (include_path中= '在/ usr / local / bin目录:在/ usr / local / lib目录/ PHP /:.:/选择/文档根目录/共享:/导出/家庭/ JOHN /的public_html /体育') 在/export/home/john/public_html/sports/private/tests/Football/Match/LineupTest.php 在第3行

出了什么问题,因为我看到包含的路径,我看到了我的目录。

2 个答案:

答案 0 :(得分:2)

您使用绝对路径包含abc.php,因此忽略包含路径。你的文件系统中真的有/private/config/abc.php吗?

答案 1 :(得分:2)

您包括'/private/config/abc.php'而非'private/config/abc.php',因此此处的包含路径并不重要。

这可能有两个原因:

  • 以太你在那里有一个拼写错误(因此我的评论看到了这一行)
  • 或者您缺少一个定义,而且您的行显示为$path.'/private...,但由于某种原因,$path为空,因此包含失败。