@@ -53,29 +53,27 @@ public function testAutofix(): void
5353 self ::assertFileEquals ($ expectedFile , $ tmpFile );
5454 }
5555
56- public function testErrorMessageWithExtraError (): void
56+ public function testErrorMessageFormat (): void
5757 {
58- $ testFile = __DIR__ . '/Rule/Data/DisallowDivisionByLiteralZeroRule/extra- error.php ' ;
58+ $ testFile = __DIR__ . '/Rule/Data/DisallowDivisionByLiteralZeroRule/error-message .php ' ;
5959
6060 try {
6161 $ this ->analyzeFiles ([$ testFile ]);
62- self ::fail ('Expected assertion to fail due to extra error ' );
62+ self ::fail ('Expected assertion to fail ' );
6363 } catch (AssertionFailedError $ e ) { // @phpstan-ignore catch.internalClass
64- self ::assertStringContainsString ('New errors reported: ' , $ e ->getMessage ());
65- self ::assertStringContainsString ('Division by literal zero is not allowed ' , $ e ->getMessage ());
66- }
67- }
64+ $ expectedMessage = <<<MSG
65+ Errors in file {$ testFile } do not match:
6866
69- public function testErrorMessageWithMissingError (): void
70- {
71- $ testFile = __DIR__ . '/Rule/Data/DisallowDivisionByLiteralZeroRule/missing-error.php ' ;
67+ New errors reported:
68+ 08: Division by literal zero is not allowed
7269
73- try {
74- $ this ->analyzeFiles ([$ testFile ]);
75- self ::fail ('Expected assertion to fail due to missing error ' );
76- } catch (AssertionFailedError $ e ) { // @phpstan-ignore catch.internalClass
77- self ::assertStringContainsString ('Errors not reported: ' , $ e ->getMessage ());
78- self ::assertStringContainsString ('Division by literal zero is not allowed ' , $ e ->getMessage ());
70+ Errors not reported:
71+ 08: This error should not be reported
72+ 09: Division by literal zero is not allowed
73+
74+
75+ MSG ;
76+ self ::assertStringContainsString ($ expectedMessage , $ e ->getMessage ());
7977 }
8078 }
8179
0 commit comments