Skip to content

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

@pdobrovolny

Description

@pdobrovolny

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)

Metadata

Metadata

Labels

feature/testdoxThe TextDox printer/formattertype/bugSomething is brokenversion/10Something affects PHPUnit 10version/11Something affects PHPUnit 11version/12Something affects PHPUnit 12

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions