From 673c5d6fbdd7196b8a7a7307fb7501300caf8c9d Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Thu, 6 Mar 2025 15:59:30 +0100 Subject: [PATCH] Refactor --- src/TextUI/Output/TestDox/ResultPrinter.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/TextUI/Output/TestDox/ResultPrinter.php b/src/TextUI/Output/TestDox/ResultPrinter.php index 2aec0939cd..d46beebacb 100644 --- a/src/TextUI/Output/TestDox/ResultPrinter.php +++ b/src/TextUI/Output/TestDox/ResultPrinter.php @@ -77,12 +77,12 @@ public function print(TestResult $result, array $tests): void } $this->printBeforeClassOrAfterClassErrors( - 'These before-first-test methods errored:', + 'before-first-test', $beforeFirstTestMethodErrored, ); $this->printBeforeClassOrAfterClassErrors( - 'These after-last-test methods errored:', + 'after-last-test', $afterLastTestMethodErrored, ); } @@ -436,18 +436,23 @@ private function symbolFor(TestStatus $status): string } /** - * @param non-empty-string $header + * @param 'after-last-test'|'before-first-test' $type * @param array $errors */ - private function printBeforeClassOrAfterClassErrors(string $header, array $errors): void + private function printBeforeClassOrAfterClassErrors(string $type, array $errors): void { if (empty($errors)) { return; } - $index = 0; + $this->printer->print( + sprintf( + 'These %s methods errored:' . PHP_EOL . PHP_EOL, + $type, + ), + ); - $this->printer->print($header . PHP_EOL . PHP_EOL); + $index = 0; foreach ($errors as $method => $error) { $this->printer->print(