diff --git a/src/Result/JunitFormatter.php b/src/Result/JunitFormatter.php index 047e621..bf94816 100644 --- a/src/Result/JunitFormatter.php +++ b/src/Result/JunitFormatter.php @@ -13,7 +13,6 @@ use function count; use function extension_loaded; use function htmlspecialchars; -use function implode; use function sprintf; use function strlen; use function strpos; @@ -161,18 +160,14 @@ private function createSymbolBasedTestSuite(string $title, array $errors, int $m foreach ($errors as $symbol => $usages) { $xml .= sprintf('', $this->escape($symbol)); - $failureUsage = []; - foreach ($usages as $index => $usage) { - $failureUsage[] = $this->relativizeUsage($usage); + $xml .= sprintf('%s', $this->escape($this->relativizeUsage($usage))); - if ($index === $maxShownUsages) { + if ($index === $maxShownUsages - 1) { break; } } - $xml .= sprintf('%s', $this->escape(implode("\n", $failureUsage))); - $xml .= ''; } @@ -194,17 +189,17 @@ private function createPackageBasedTestSuite(string $title, array $errors, int $ $printedSymbols = 0; foreach ($usagesPerClassname as $symbol => $usages) { - $printedSymbols++; - $xml .= sprintf( - '%s', - $symbol, - $this->escape( - implode("\n", $this->createUsages($usages, $maxShownUsages)) - ) - ); - - if ($printedSymbols === $maxShownUsages) { - break; + foreach ($this->createUsages($usages, $maxShownUsages) as $usage) { + $printedSymbols++; + $xml .= sprintf( + '%s', + $symbol, + $this->escape($usage) + ); + + if ($printedSymbols === $maxShownUsages) { + break 2; + } } } diff --git a/tests/JunitFormatterTest.php b/tests/JunitFormatterTest.php index 3efde79..5d479a2 100644 --- a/tests/JunitFormatterTest.php +++ b/tests/JunitFormatterTest.php @@ -47,7 +47,10 @@ public function testPrintResult(): void 10, 0.123, [], - ['Unknown\\Thing' => [new SymbolUsage('/app/app/init.php', 1093, SymbolKind::CLASSLIKE)]], + ['Unknown\\Thing' => [ + new SymbolUsage('/app/app/init.php', 1091, SymbolKind::CLASSLIKE), + new SymbolUsage('/app/app/init.php', 1093, SymbolKind::CLASSLIKE), + ]], ['Unknown\\function' => [new SymbolUsage('/app/app/foo.php', 51, SymbolKind::FUNCTION)]], [ 'shadow/package' => [ @@ -76,7 +79,7 @@ public function testPrintResult(): void }); $verboseOutput = $this->getFormatterNormalizedOutput(static function ($formatter) use ($analysisResult): void { $options = new CliOptions(); - $options->verbose = true; + $options->showAllUsages = true; $formatter->format($analysisResult, $options, new Configuration()); }); @@ -85,7 +88,7 @@ public function testPrintResult(): void - app/init.php:1093 + app/init.php:1091 @@ -120,6 +123,7 @@ public function testPrintResult(): void + app/init.php:1091 app/init.php:1093 @@ -135,9 +139,11 @@ public function testPrintResult(): void src/bootstrap.php:873 src/Printer.php:25 - src/Utils.php:19 -src/Utils.php:22 -src/Application.php:128 + src/Utils.php:19 + src/Utils.php:22 + src/Application.php:128 + src/Controller.php:229 + src/bootstrap.php:317 @@ -151,7 +157,7 @@ public function testPrintResult(): void - + OUT;