Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/RuleTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use function file_get_contents;
use function file_put_contents;
use function implode;
use function in_array;
use function ksort;
use function preg_match;
use function preg_match_all;
Expand Down Expand Up @@ -62,10 +63,15 @@ protected function analyzeFiles(
$actualErrors = $this->processActualErrors(array_values($fileErrors));
$expectedErrors = $this->parseExpectedErrors($file);

$extraErrors = array_filter($actualErrors, static fn (string $error): bool => !in_array($error, $expectedErrors, true));
$missingErrors = array_filter($expectedErrors, static fn (string $error): bool => !in_array($error, $actualErrors, true));

self::assertSame(
implode("\n", $expectedErrors) . "\n",
implode("\n", $actualErrors) . "\n",
"Errors in file {$file} do not match",
"Errors in file {$file} do not match:\n\n" .
($extraErrors === [] ? '' : "New errors reported:\n" . implode("\n", $extraErrors) . "\n\n") .
($missingErrors === [] ? '' : "Errors not reported:\n" . implode("\n", $missingErrors) . "\n\n"),
);
}
}
Expand Down