You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A lot of ReflectionException messages in the test output when using testdox. prettifyTestClass($className = 'MyTest') should not throw ReflectionException
Current behavior
When xdebug is active bunch of noise due to not properly handled ReflectionExceptions.
This issue exists since ages: see #4379
How to reproduce
cat > MyTest.php <<FILE
<?php
class MyTest extends \PHPUnit\Framework\TestCase {
public function testFoo(): void {
\$this->assertTrue(true);
}
}
FILE
No exceptions in the output if nothing is wrong with the code.
Testdox processors should either catch exceptions not expose them, or let the developer know what is wrong with the code. Throwing exception when some generated method doesn't exist doesn't help anyone.
yes xdebug.show_exception_trace=0 makes the exception disappear as many other exceptions which wanted to see/catch.
in the end the issue is with defining default value "" but checking against null. If default value would have been null or the check afterwards would check the default value instead of just arbitrary null, then we would not have this false positive exception.
public static function parseTestMethodAnnotations(string $className, ?string $methodName = '') : array
{
$registry = Registry::getInstance();
if ($methodName !== null) {
it should be
public static function parseTestMethodAnnotations(string $className, ?string $methodName = null) : array
sebastianbergmann
changed the title
PHPUnit\Util\Test::parseTestMethodAnnotations() wrong default value causes ReflectionException
Wrong default value for optional parameter of PHPUnit\Util\Test::parseTestMethodAnnotations() causes ReflectionException
Feb 28, 2023
Summary
A lot of
ReflectionException
messages in the test output when using testdox.prettifyTestClass($className = 'MyTest')
should not throwReflectionException
Current behavior
When xdebug is active bunch of noise due to not properly handled ReflectionExceptions.
This issue exists since ages: see #4379
How to reproduce
Expected behavior
No exceptions in the output if nothing is wrong with the code.
Testdox processors should either catch exceptions not expose them, or let the developer know what is wrong with the code. Throwing exception when some generated method doesn't exist doesn't help anyone.
should not throw
ReflectionException
The text was updated successfully, but these errors were encountered: