I've run into a bit of trouble between the Zend Framework autoloader
(Zend::loadClass) when trying to work with PHPUnit 3.0

The problem that I was trying to solve was to load PHPUnit after I'd enabled
the Zend Framework class autoloader

function __autoload($classname) {
   Zend::loadClass($classname);
}

In an attempt to use PHPUnit with the autoloader, I've simply added
/usr/share/php to my include path where the PEAR-managed package has been
installed.  Upon extending a PHPUnit class (PHPUnit_Framework_TestCase) to
create a unit test, the framework attempts to autoload all the requisites.

In the process it ends up trying to load PHPUnit_Framework_SelfDescribing
which is an interface.  The framework ends up throwing an exception in
loadClass because it included the file PHPUnit/Framework/SelfDiscovery.php
but cannot detect the class after loading it.

So, in an attempt to
However, what actually happens is that PHPUnit/Framework/SelfDiscovery.php
does the following:

if (!interface_exists('PHPUnit_Framework_SelfDescribing')) {

interface PHPUnit_Framework_SelfDescribing {
...
}

}

The problem might be immediately apparent, the interface_exists function
isn't passed the optional second parameter to disable autoloading.  It
should have a second parameter 'false' to make sure the autoloader isn't
instantiated again.


The question that I have is whether there are alternate suggestions for
avoiding this other than changing the PHPUnit source (which I'll also be
proposing).

Thanks,
David

Reply via email to