sebastianbergmann / phpunit

The PHP Unit Testing framework.
https://phpunit.de/
BSD 3-Clause "New" or "Revised" License
19.69k stars 2.2k forks source link

Wrong stack trace when mbstring.func_overload is true #690

Closed gavinlove closed 11 years ago

gavinlove commented 12 years ago

In the latest master version of phpunit if a test fails and tries to generate a stack trace when mbstring.func_overload is true rather than getting the stack trace for your error you get a stack trace for a warning within phpunit.

The problem is that the mb_strpos is stricter than strpos and passing false to it generates a warning.

Warning: mb_strpos(): Empty delimiter in /home/gavin/site_versions/phpunit/phpunit/PHPUnit/Util/Filter.php on line 110

Call Stack:
    0.0002     629080   1. {main}() /home/gavin/site_versions/phpunit/phpunit/phpunit.php:0
    0.0086    1882640   2. PHPUnit_TextUI_Command::main() /home/gavin/site_versions/phpunit/phpunit/phpunit.php:46
    0.0086    1883368   3. PHPUnit_TextUI_Command->run() /home/gavin/site_versions/phpunit/phpunit/PHPUnit/TextUI/Command.php:129
    0.3184   21671640   4. PHPUnit_TextUI_TestRunner->doRun() /home/gavin/site_versions/phpunit/phpunit/PHPUnit/TextUI/Command.php:176
    0.3470   22581064   5. PHPUnit_Framework_TestSuite->run() /home/gavin/site_versions/phpunit/phpunit/PHPUnit/TextUI/TestRunner.php:346
   19.8480   37215488   6. PHPUnit_Framework_TestSuite->runTest() /home/gavin/site_versions/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:745
   19.8480   37215488   7. PHPUnit_Extensions_PhptTestCase->run() /home/gavin/site_versions/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:775
   20.2044   37236680   8. PHPUnit_Framework_TestResult->addFailure() /home/gavin/site_versions/phpunit/phpunit/PHPUnit/Extensions/PhptTestCase.php:216
   20.2045   37237320   9. PHPUnit_Util_Log_JUnit->addFailure() /home/gavin/site_versions/phpunit/phpunit/PHPUnit/Framework/TestResult.php:307
   20.2068   37239760  10. PHPUnit_Util_Filter::getFilteredStacktrace() /home/gavin/site_versions/phpunit/phpunit/PHPUnit/Util/Log/JUnit.php:209
   20.2091   37243304  11. mb_strpos() /home/gavin/site_versions/phpunit/phpunit/PHPUnit/Util/Filter.php:110
edorian commented 12 years ago

Does changing Line 110 from:

strpos($frame['file'], $prefix) !== 0 &&

to

($prefix == false || strpos($frame['file'], $prefix) !== 0) &&

fix the issue for you?

I'm not really sure if PHPUnit should support that function overloading or if thats is something that has to be fixed in mb but anyways: Thanks a bunch for taking the time to test with master and reporting the issue :)

gavinlove commented 12 years ago

That fixes the problem.