function NamePrettifier::prettifyTestCase
File
-
vendor/
phpunit/ phpunit/ src/ Logging/ TestDox/ NamePrettifier.php, line 173
Class
- NamePrettifier
- @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
Namespace
PHPUnit\Logging\TestDoxCode
public function prettifyTestCase(TestCase $test, bool $colorize) : string {
$annotationWithPlaceholders = false;
$methodLevelTestDox = MetadataRegistry::parser()->forMethod($test::class, $test->name())
->isTestDox()
->isMethodLevel();
if ($methodLevelTestDox->isNotEmpty()) {
$methodLevelTestDox = $methodLevelTestDox->asArray()[0];
assert($methodLevelTestDox instanceof TestDox);
$result = $methodLevelTestDox->text();
if (str_contains($result, '$')) {
$annotation = $result;
$providedData = $this->mapTestMethodParameterNamesToProvidedDataValues($test, $colorize);
$variables = array_map(static fn(string $variable): string => sprintf('/%s(?=\\b)/', preg_quote($variable, '/')), array_keys($providedData));
$result = preg_replace($variables, $providedData, $annotation);
$annotationWithPlaceholders = true;
}
}
else {
$result = $this->prettifyTestMethodName($test->name());
}
if (!$annotationWithPlaceholders && $test->usesDataProvider()) {
$result .= $this->prettifyDataSet($test, $colorize);
}
return $result;
}