开发者

Dealing with PHPUnit path issues

开发者 https://www.devze.com 2023-01-08 08:44 出处:网络
I am getting the following error when I try to run PHPUnit from within my current MVC framework application

I am getting the following error when I try to run PHPUnit from within my current MVC framework application

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

I've managed to trace that error to a combination of a few things.

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

When I comment out

    set_include_path(implode(PATH_SEPARATOR, $paths));

PHPUnit runs tests

when I comment out

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

I get

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

If I comment out every other directory, save for the

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

I get the "cannot redeclare" error.

The only way that I can get to run actual tests is if I run without the set_include_path statement and manually include all the cla开发者_高级运维ss files that are called by any individual unit test.

Any ideas?

EDIT: it appears there's a conflict with the __autoload function. I'm still not quite sure how to address the issue.


well as it turns out, I have no idea why this actually works ... but since it does, I'll post the result.

$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 :)

0

精彩评论

暂无评论...
验证码 换一张
取 消