Skip to content

Commit

Permalink
Drop colored prettified method name printing
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Mar 11, 2024
1 parent 0bddfd3 commit 6b9462d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
15 changes: 9 additions & 6 deletions src/Event/Value/Test/TestDox.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
*/
namespace PHPUnit\Event\Code;

use RuntimeException;

/**
* @psalm-immutable
*
Expand All @@ -18,24 +20,25 @@
{
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
{
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;
Expand Down
6 changes: 1 addition & 5 deletions src/Event/Value/Test/TestDoxBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
);
}

Expand All @@ -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),
);
}
}
2 changes: 1 addition & 1 deletion src/TextUI/Output/TestDox/ResultPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Check failure on line 101 in src/TextUI/Output/TestDox/ResultPrinter.php

View workflow job for this annotation

GitHub Actions / Type Checker

MissingThrowsDocblock

src/TextUI/Output/TestDox/ResultPrinter.php:101:57: MissingThrowsDocblock: RuntimeException is thrown but not caught - please either catch or add a @throws annotation (see https://psalm.dev/169)
}

private function printTestResultBody(TestDoxTestResult $test): void
Expand Down

0 comments on commit 6b9462d

Please sign in to comment.