Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Not automatically using the autoloader in GlobalState.php during class_exists #754

Closed
wants to merge 1 commit into from

8 participants

@brobie

We found this need because:
1. We do not have PHP_Invoker installed.
2. We have multiple autoloaders registered
3. When the class_exists was checking for "PHP_Invoker" it was
automatically trying to autoload it and failing in a way that fatally
ended our phpunit tests.

@brobie brobie Setting the "use autoloader" switch to false on class_exists
We found this need because:
1. We do now have PHP_Invoker installed.
2. We have multiple autoloaders registered
3. When the class_exists was checking for "PHP_Invoker" it was
automatically trying to autoload it and failing in a way that fatally
ended our phpunit tests.
e6a4b20
@edorian
Collaborator

While we don't grantee that PHPUnit never ever calls the autoloader and suggest to not have a autoloader that dies when it doesn't find a file this case seems like something that is avoidable. I'm not sure when those files are loaded but I assume it's before code coverage and in that case everything that has been executed can be blacklisted and the rest can be safely ignored.

Thanks for the PR!

@tohann

We're interested in this fix, too. Does that mean this pull request will be accepted?

@edorian
Collaborator

@tohann I currently don't oversee the implications of this and don't have time to regression test it so my plan was to leave it for Sebastian to decide.

If it doesn't break anything or cause other issues I don't see why it shouldn't be merged. We already try to avoid autoloader calls where possible.

@tohann

Cool, thanks for the update!

@jasonevans1

I am interested in having this pull request accepted too.

@simonrjones

I too would like to see this pull request accepted. I've been writing some phpunit tests and came across this issue when I'm using the spl autoloader to autoload classes.

thanks,
Simon

@sebastianbergmann

I am against this. Autoloaders are stackable (as in: you can have more than one registered). An autoloader should do NOTHING when it is not responsible for a class.

@brobie brobie referenced this pull request in netz98/n98-magerun
Closed

Make `phpunit/php-invoker` a non-required Package? #127

@GuillermoCerezo

Thanks for that line! It helped a lot with Yii + PHPUnit + Windows.

@Ragazzo Ragazzo referenced this pull request in yiisoft/yii
Closed

CTestCase PHPUnit 3.7.10 autoload fails #1907

@spencer-aerian

Come on Sebastian. Invoker is an optional package (according to the documentation) but you are making it a prerequisite. This is breaking lots of developers if its not loaded (and if you do load it you then have to muck about installing an optional php extension locally and on integration servers.)
I think the patch 'should be applied'.

@sebastianbergmann

I agree that the current situation is not ideal and am open to suggestion for how to improve it. Messing with the autoloader, however, because of broken autoloaders (see my comment in #754 (comment)) is not an option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 17, 2012
  1. @brobie

    Setting the "use autoloader" switch to false on class_exists

    brobie authored
    We found this need because:
    1. We do now have PHP_Invoker installed.
    2. We have multiple autoloaders registered
    3. When the class_exists was checking for "PHP_Invoker" it was
    automatically trying to autoload it and failing in a way that fatally
    ended our phpunit tests.
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  PHPUnit/Util/GlobalState.php
View
2  PHPUnit/Util/GlobalState.php
@@ -406,7 +406,7 @@ public static function phpunitFiles()
*/
protected static function addDirectoryContainingClassToPHPUnitFilesList($className, $parent = 1)
{
- if (!class_exists($className)) {
+ if (!class_exists($className, false)) {
return;
}
Something went wrong with that request. Please try again.