views:

111

answers:

1

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 class 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.

A: 

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

Alex C
It guess it works because the path to the phpunit files is in your include path and my merging and not overwriting the old include path php is able to find the files :) (And that path is maybe set at runtime or different from /usr/local/pear because of 2 installs or something :) )
edorian