Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backed enumerations with values not of type string cannot be used in customized TestDox output #6115

Closed
pdobrovolny opened this issue Jan 30, 2025 · 0 comments
Assignees
Labels
feature/testdox The TextDox printer/formatter type/bug Something is broken version/10 Something affects PHPUnit 10 version/11 Something affects PHPUnit 11 version/12 Something affects PHPUnit 12

Comments

@pdobrovolny
Copy link

The exception is thrown when using an provider and one of the parameters is an enum of type int

fix example:
NamePrettifier::objectToString() on line 292

if( $enumReflector->isBacked() ) {
  return (string)$value->value;
}

Trace:

Message:  PHPUnit\Logging\TestDox\NamePrettifier::objectToString(): Return value must be of type string, int returned
Location: ./vendor/phpunit/phpunit/src/Logging/TestDox/NamePrettifier.php:296

#0 ./vendor/phpunit/phpunit/src/Logging/TestDox/NamePrettifier.php(249): PHPUnit\Logging\TestDox\NamePrettifier->objectToString(PDobrovolny\Quantity\Enums\EMetricExponent::MICRO)
#1 ./vendor/phpunit/phpunit/src/Logging/TestDox/NamePrettifier.php(187): PHPUnit\Logging\TestDox\NamePrettifier->mapTestMethodParameterNamesToProvidedDataValues(Object(Test\ReadyPhp\Logger\Unit\Helper\MetricScaleHelperTest), false)
#2 ./vendor/phpunit/phpunit/src/Event/Value/Test/TestDoxBuilder.php(28): PHPUnit\Logging\TestDox\NamePrettifier->prettifyTestCase(Object(Test\ReadyPhp\Logger\Unit\Helper\MetricScaleHelperTest), false)
#3 ./vendor/phpunit/phpunit/src/Event/Value/Test/TestMethodBuilder.php(45): PHPUnit\Event\Code\TestDoxBuilder::fromTestCase(Object(Test\ReadyPhp\Logger\Unit\Helper\MetricScaleHelperTest))
#4 ./vendor/phpunit/phpunit/src/Framework/TestCase.php(939): PHPUnit\Event\Code\TestMethodBuilder::fromTestCase(Object(Test\ReadyPhp\Logger\Unit\Helper\MetricScaleHelperTest))
#5 ./vendor/phpunit/phpunit/src/Framework/TestSuite.php(164): PHPUnit\Framework\TestCase->valueObjectForEvents()
#6 ./vendor/phpunit/phpunit/src/Framework/TestBuilder.php(107): PHPUnit\Framework\TestSuite->addTest(Object(Test\ReadyPhp\Logger\Unit\Helper\MetricScaleHelperTest), Array)
#7 ./vendor/phpunit/phpunit/src/Framework/TestBuilder.php(51): PHPUnit\Framework\TestBuilder->buildDataProviderTestSuite('testMain', 'Test\\ReadyPhp\\L...', Array, false, NULL, false, Array, Array)
#8 ./vendor/phpunit/phpunit/src/Framework/TestSuite.php(508): PHPUnit\Framework\TestBuilder->build(Object(ReflectionClass), 'testMain', Array)
#9 ./vendor/phpunit/phpunit/src/Framework/TestSuite.php(109): PHPUnit\Framework\TestSuite->addTestMethod(Object(ReflectionClass), Object(ReflectionMethod), Array)
#10 ./vendor/phpunit/phpunit/src/Framework/TestSuite.php(209): PHPUnit\Framework\TestSuite::fromClassReflector(Object(ReflectionClass), Array)
#11 ./vendor/phpunit/phpunit/src/Framework/TestSuite.php(230): PHPUnit\Framework\TestSuite->addTestSuite(Object(ReflectionClass), Array)
#12 ./vendor/phpunit/phpunit/src/TextUI/Configuration/Xml/TestSuiteMapper.php(105): PHPUnit\Framework\TestSuite->addTestFile('/Users/pdobrovo...', Array)
#13 ./vendor/phpunit/phpunit/src/TextUI/Configuration/TestSuiteBuilder.php(75): PHPUnit\TextUI\XmlConfiguration\TestSuiteMapper->map('/Users/pdobrovo...', Object(PHPUnit\TextUI\Configuration\TestSuiteCollection), '', '')
#14 ./vendor/phpunit/phpunit/src/TextUI/Application.php(418): PHPUnit\TextUI\Configuration\TestSuiteBuilder->build(Object(PHPUnit\TextUI\Configuration\Configuration))
#15 ./vendor/phpunit/phpunit/src/TextUI/Application.php(181): PHPUnit\TextUI\Application->buildTestSuite(Object(PHPUnit\TextUI\Configuration\Configuration))
#16 ./vendor/phpunit/phpunit/phpunit(104): PHPUnit\TextUI\Application->run(Array)
@pdobrovolny pdobrovolny added the type/bug Something is broken label Jan 30, 2025
@sebastianbergmann sebastianbergmann added version/10 Something affects PHPUnit 10 version/11 Something affects PHPUnit 11 version/12 Something affects PHPUnit 12 labels Jan 30, 2025
@sebastianbergmann sebastianbergmann self-assigned this Jan 30, 2025
@sebastianbergmann sebastianbergmann added the feature/testdox The TextDox printer/formatter label Jan 30, 2025
@sebastianbergmann sebastianbergmann changed the title PHPUnit\Logging\TestDox\NamePrettifier::objectToString(): Return value must be of type string, int returned Backed enumerations with values not of type string cannot be used in customized TestDox output Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/testdox The TextDox printer/formatter type/bug Something is broken version/10 Something affects PHPUnit 10 version/11 Something affects PHPUnit 11 version/12 Something affects PHPUnit 12
Projects
None yet
Development

No branches or pull requests

2 participants