1313use PHPUnit \Framework \TestCase ;
1414use Symfony \Component \Finder \Finder ;
1515use function array_combine ;
16+ use function array_diff ;
1617use function array_filter ;
1718use function array_map ;
1819use function explode ;
@@ -53,11 +54,12 @@ public function it_finds_and_fixes_violations(
5354 string $ contents ,
5455 string $ fixed ,
5556 array $ messages ,
57+ array $ ignoreMessages ,
5658 ?string $ description ,
5759 ?string $ fixedEncoding
5860 ) : void {
5961 $ file = $ this ->createFile ($ filename , $ contents );
60- $ actual = flatten ($ this ->getMessages ($ file ));
62+ $ actual = array_diff ( flatten ($ this ->getMessages ($ file )), $ ignoreMessages );
6163
6264 sort ($ actual );
6365 sort ($ messages );
@@ -84,6 +86,10 @@ public function cases() : iterable
8486 $ parts ['messages ' ] = array_filter (explode ("\n" , $ parts ['messages ' ]));
8587 }
8688
89+ if (isset ($ parts ['ignore-messages ' ])) {
90+ $ parts ['ignore-messages ' ] = array_filter (explode ("\n" , $ parts ['ignore-messages ' ]));
91+ }
92+
8793 $ keys = ['fixed ' , 'fixed-encoding ' , 'fixed-line-endings ' , 'messages ' ];
8894 if (empty ($ parts ['contents ' ])) {
8995 throw new LogicException ("Couldn't find contents in {$ file ->getRelativePathname ()}" );
@@ -134,6 +140,7 @@ public function cases() : iterable
134140 $ parts ['contents ' ],
135141 $ parts ['fixed ' ],
136142 $ parts ['messages ' ] ?? [],
143+ $ parts ['ignore-messages ' ] ?? [],
137144 $ parts ['description ' ] ?? null ,
138145 $ parts ['fixed-encoding ' ] ?? null ,
139146 ];
0 commit comments