From 6b9462d1aa4e053109756107a2dac8a8b150c0f2 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Mon, 11 Mar 2024 09:11:03 +0100 Subject: [PATCH] Drop colored prettified method name printing --- src/Event/Value/Test/TestDox.php | 15 +++++++++------ src/Event/Value/Test/TestDoxBuilder.php | 6 +----- src/TextUI/Output/TestDox/ResultPrinter.php | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/Event/Value/Test/TestDox.php b/src/Event/Value/Test/TestDox.php index 2703a368500..4e5ad0f5b36 100644 --- a/src/Event/Value/Test/TestDox.php +++ b/src/Event/Value/Test/TestDox.php @@ -9,6 +9,8 @@ */ namespace PHPUnit\Event\Code; +use RuntimeException; + /** * @psalm-immutable * @@ -18,13 +20,11 @@ { private string $prettifiedClassName; private string $prettifiedMethodName; - private string $prettifiedAndColorizedMethodName; - public function __construct(string $prettifiedClassName, string $prettifiedMethodName, string $prettifiedAndColorizedMethodName) + public function __construct(string $prettifiedClassName, string $prettifiedMethodName) { - $this->prettifiedClassName = $prettifiedClassName; - $this->prettifiedMethodName = $prettifiedMethodName; - $this->prettifiedAndColorizedMethodName = $prettifiedAndColorizedMethodName; + $this->prettifiedClassName = $prettifiedClassName; + $this->prettifiedMethodName = $prettifiedMethodName; } public function prettifiedClassName(): string @@ -32,10 +32,13 @@ public function prettifiedClassName(): string return $this->prettifiedClassName; } + /** + * @throws RuntimeException + */ public function prettifiedMethodName(bool $colorize = false): string { if ($colorize) { - return $this->prettifiedAndColorizedMethodName; + throw new RuntimeException('Pretty printing method names is no longer supported for performance reasons.'); } return $this->prettifiedMethodName; diff --git a/src/Event/Value/Test/TestDoxBuilder.php b/src/Event/Value/Test/TestDoxBuilder.php index ae8f62dad26..d17cd3aafc3 100644 --- a/src/Event/Value/Test/TestDoxBuilder.php +++ b/src/Event/Value/Test/TestDoxBuilder.php @@ -24,7 +24,6 @@ public static function fromTestCase(TestCase $testCase): TestDox return new TestDox( $prettifier->prettifyTestClassName($testCase::class), $prettifier->prettifyTestCase($testCase, false), - $prettifier->prettifyTestCase($testCase, true), ); } @@ -36,12 +35,9 @@ public static function fromClassNameAndMethodName(string $className, string $met { $prettifier = new NamePrettifier; - $prettifiedMethodName = $prettifier->prettifyTestMethodName($methodName); - return new TestDox( $prettifier->prettifyTestClassName($className), - $prettifiedMethodName, - $prettifiedMethodName, + $prettifier->prettifyTestMethodName($methodName), ); } } diff --git a/src/TextUI/Output/TestDox/ResultPrinter.php b/src/TextUI/Output/TestDox/ResultPrinter.php index b9bcb48d72a..66fa85b25c1 100644 --- a/src/TextUI/Output/TestDox/ResultPrinter.php +++ b/src/TextUI/Output/TestDox/ResultPrinter.php @@ -98,7 +98,7 @@ private function printTestResultHeader(TestDoxTestResult $test): void $this->printer->print($buffer); } - $this->printer->print($test->test()->testDox()->prettifiedMethodName($this->colors) . PHP_EOL); + $this->printer->print($test->test()->testDox()->prettifiedMethodName() . PHP_EOL); } private function printTestResultBody(TestDoxTestResult $test): void