0

当我尝试从当前 MVC 框架应用程序中运行 PHPUnit 时出现以下错误

Fatal error: Cannot redeclare class PHPUnit_Util_FilterIterator in /usr/local/pear/PHPUnit/Util/FilterIterator.php on line 162

我已经设法将该错误追溯到几件事的组合。

$paths = array();
$paths[] = '../m';
$paths[] = '../v';
$paths[] = '../c';
$paths[] = '/usr/local/pear';
set_include_path(implode(PATH_SEPARATOR, $paths));

当我注释掉

    set_include_path(implode(PATH_SEPARATOR, $paths));

PHPUnit 运行测试

当我注释掉

$paths[] = '/usr/local/pear';

我明白了

Fatal error: require_once(): Failed opening required 'PHPUnit/Framework/TestCase.php' 

如果我注释掉所有其他目录,请保存

$paths[] = '/usr/local/pear';

我收到“无法重新声明”错误。

我可以运行实际测试的唯一方法是,如果我在没有 set_include_path 语句的情况下运行并手动包含任何单个单元测试调用的所有类文件。

有任何想法吗?

编辑:似乎与 __autoload 函数有冲突。我仍然不太确定如何解决这个问题。

4

1 回答 1

0

事实证明,我不知道为什么这实际上有效……但是既然有效,我将发布结果。

$paths[] = get_include_path();
$paths[] = '../m';
$paths[] = '../v';
$paths[] = '../c';
set_include_path(implode(PATH_SEPARATOR, $paths));

So there you go. Well at least, there you go in the case that you've actually got this problem too :)

于 2010-07-23T17:56:30.593 回答