Trying to instantiate ReflectionClass object w/ path that doesn't exist
PHPUnit_Util_GlobalState::phpunitFiles() is trying to call
self::addDirectoryContainingClassToPHPUnitFilesList('PHPUnit_Extensions_Story_TestCase', 2);
and PHPUnit_Extensions_Story_TestCase does not exist.
phpunit --version 3.7.13
He,
thanks for the bug report.
Whats the error message you are getting and what are you trying to do when the error happens?
NP.
Testing Magento modules using the EcomDev_PHPUnit module. Tried commenting out the offending stmt and tests start running again.
phpunit --filter processOrderShouldFailGracefully PHPUnit 3.7.13 by Sebastian Bergmann.
Configuration read from /var/www/server/bmodules/B/phpunit.xml.dist
EPHP Fatal error: Uncaught exception 'Exception' with message 'Warning: include(PHPUnit/Extensions/Story/TestCase.php): failed to open stream: No such file or directory in /var/www/server/bmodules/sites/ 1.7.0.2/httpdocs/lib/Varien/Autoload.php on line 93' in /var/www/server/bmodules/sites/ 1.7.0.2/httpdocs/app/code/core/Mage/Core/functions.php:245 Stack trace: #0 /var/www/server/bmodules/sites/ 1.7.0.2/httpdocs/lib/Varien/Autoload.php(93): mageCoreErrorHandler(2, 'include(PHPUnit...', '/var/www/server...', 93, Array) #1 /var/www/server/bmodules/sites/ 1.7.0.2/httpdocs/lib/Varien/Autoload.php(93): Varien_Autoload::autoload() #2 [internal function]: Varien_Autoload->autoload('PHPUnit_Extensi...') #3 [internal function]: spl_autoload_call('PHPUnit_Extensi...') #4 /usr/share/php/PHPUnit/Util/GlobalState.php(409): class_exists('PHPUnit_Extensi...') #5 /usr/share/php/PHPUnit/Util/GlobalState.php(395): PHPUnit_Util_GlobalState::addDirectoryContainingClassToPHPUnitFilesList('PHPUnit_Extensi...', 2) #6 /usr/share/php/ in /var/www/server/bbmodules/sites/ 1.7.0.2/httpdocs/app/code/core/Mage/Core/functions.php on line 245
Thanks, Jamie K.
On Wed, Jan 30, 2013 at 3:51 PM, Volker Dusch [email protected]:
He,
thanks for the bug report.
Whats the error message you are getting and what are you trying to do when the error happens?
— Reply to this email directly or view it on GitHubhttps://github.com/sebastianbergmann/phpunit/issues/802#issuecomment-12911762.
This is not a problem with PHPUnit but with the autoloader declared in Varien/Autoload.php.
I'm a little confused how this is an issue w/ the autoloader in Varien/Autoload.php
Specifically I'm confused on why every other file that is called in the PHPUnit_Util_GlobalState::phpunitFiles() method exists in the file system except the call self::addDirectoryContainingClassToPHPUnitFilesList('PHPUnit_Extensions_Story_TestCase', 2);
I can clearly see when PHPUnit/Extensions/Story/TestCase.php existed in phpunit version 3.5, but I'm running phpunit 3.7.13 and the entire PHPUnit/Extensions/Story directory was removed in version 3.6
and when I comment out the the TestCase line, the call to class_exists($className) in PHPUnit_Util_GlobalState::addDirectoryContainingClassToPHPUnitFilesList doesn't get called, causing the defaulted 2nd parameter, autoload = true, to not fire the autoloader in Varien/Autoload.php which throws the correct Exception "failed to open stream: No such file or directory..."
It is an issue with the autoloader declared in `Varien/Autoload.php' because that autoloader is trying to include a file that it is not responsible for.
The PHPUnit_Extensions_Story_TestCase class is not part of the main PHPUnit distribution anymore. It is distributed via the optional PHPUnit_Story package. If that package is installed, its autoloader is available and takes care of loading the PHPUnit_Extensions_Story_TestCase class. The error you are experiencing happens because a completely different autoloader thinks it is responsible for loading that class.
@sebastianbergmann You are right. It's a problem with the Magento Autoloader and it's possible to unregister the autoloader during the tests. I did this in my project n98-magerun.
- Init Magento
Mage::app() - Unregister autoloader
spl_autoload_unregister(array(\Varien_Autoload::instance(), 'autoload')); - Register an own PSR-0 autoloader and add the Magento pathes.
I did this with Composer autoloader.
$loader = require __DIR__ . '/../vendor/autoload.php';
/* @var $loader \Composer\Autoload\ClassLoader */
$loader->setUseIncludePath(true);
$base = 'MAGENTO BASE DIR';
$paths = array(
$base . '/app/code/local',
$base . '/app/code/community',
$base . '/app/code/core',
$base . '/lib',
);
set_include_path(implode(PATH_SEPARATOR, $paths) . PATH_SEPARATOR . get_include_path());
@veilig2000 This is also a possible solution for EcomDev_PHPUnit. It's always the same issue.