Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. NamePrettifier.php

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\TestDox

Code

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;
}
RSS feed
Powered by Drupal