@@ -11,83 +11,117 @@ class RawErrorFormatterTest extends ErrorFormatterTestCase
1111 public function dataFormatterOutputProvider (): iterable
1212 {
1313 yield [
14- 'No errors ' ,
15- 0 ,
16- 0 ,
17- 0 ,
18- '' ,
14+ 'message ' => 'No errors ' ,
15+ 'exitCode ' => 0 ,
16+ 'numFileErrors ' => 0 ,
17+ 'numGenericErrors ' => 0 ,
18+ 'verbose ' => false ,
19+ 'expected ' => '' ,
1920 ];
2021
2122 yield [
22- 'One file error ' ,
23- 1 ,
24- 1 ,
25- 0 ,
26- '/data/folder/with space/and unicode 😃/project/folder with unicode 😃/file name with "spaces" and unicode 😃.php:4:Foo ' . "\n" ,
23+ 'message ' => 'One file error ' ,
24+ 'exitCode ' => 1 ,
25+ 'numFileErrors ' => 1 ,
26+ 'numGenericErrors ' => 0 ,
27+ 'verbose ' => false ,
28+ 'expected ' => '/data/folder/with space/and unicode 😃/project/folder with unicode 😃/file name with "spaces" and unicode 😃.php:4:Foo ' . "\n" ,
2729 ];
2830
2931 yield [
30- 'One generic error ' ,
31- 1 ,
32- 0 ,
33- 1 ,
34- '?:?:first generic error ' . "\n" ,
32+ 'message ' => 'One generic error ' ,
33+ 'exitCode ' => 1 ,
34+ 'numFileErrors ' => 0 ,
35+ 'numGenericErrors ' => 1 ,
36+ 'verbose ' => false ,
37+ 'expected ' => '?:?:first generic error ' . "\n" ,
3538 ];
3639
3740 yield [
38- 'Multiple file errors ' ,
39- 1 ,
40- 4 ,
41- 0 ,
42- '/data/folder/with space/and unicode 😃/project/folder with unicode 😃/file name with "spaces" and unicode 😃.php:2:Bar ' . "\nBar2 \n" .
43- '/data/folder/with space/and unicode 😃/project/folder with unicode 😃/file name with "spaces" and unicode 😃.php:4:Foo ' . "\n" .
44- '/data/folder/with space/and unicode 😃/project/foo.php:1:Foo<Bar> ' . "\n" .
45- '/data/folder/with space/and unicode 😃/project/foo.php:5:Bar ' . "\nBar2 \n" ,
41+ 'message ' => 'Multiple file errors ' ,
42+ 'exitCode ' => 1 ,
43+ 'numFileErrors ' => 4 ,
44+ 'numGenericErrors ' => 0 ,
45+ 'verbose ' => false ,
46+ 'expected ' => '/data/folder/with space/and unicode 😃/project/folder with unicode 😃/file name with "spaces" and unicode 😃.php:2:Bar
47+ Bar2
48+ /data/folder/with space/and unicode 😃/project/folder with unicode 😃/file name with "spaces" and unicode 😃.php:4:Foo
49+ /data/folder/with space/and unicode 😃/project/foo.php:1:Foo<Bar>
50+ /data/folder/with space/and unicode 😃/project/foo.php:5:Bar
51+ Bar2
52+ ' ,
4653 ];
4754
4855 yield [
49- 'Multiple generic errors ' ,
50- 1 ,
51- 0 ,
52- 2 ,
53- '?:?:first generic error ' . "\n" .
54- '?:?:second generic<error> ' . "\n" ,
56+ 'message ' => 'Multiple generic errors ' ,
57+ 'exitCode ' => 1 ,
58+ 'numFileErrors ' => 0 ,
59+ 'numGenericErrors ' => 2 ,
60+ 'verbose ' => false ,
61+ 'expected ' => '?:?:first generic error
62+ ?:?:second generic<error>
63+ ' ,
5564 ];
5665
5766 yield [
58- 'Multiple file, multiple generic errors ' ,
59- 1 ,
60- 4 ,
61- 2 ,
62- '?:?:first generic error ' . "\n" .
63- '?:?:second generic<error> ' . "\n" .
64- '/data/folder/with space/and unicode 😃/project/folder with unicode 😃/file name with "spaces" and unicode 😃.php:2:Bar ' . "\nBar2 \n" .
65- '/data/folder/with space/and unicode 😃/project/folder with unicode 😃/file name with "spaces" and unicode 😃.php:4:Foo ' . "\n" .
66- '/data/folder/with space/and unicode 😃/project/foo.php:1:Foo<Bar> ' . "\n" .
67- '/data/folder/with space/and unicode 😃/project/foo.php:5:Bar ' . "\nBar2 \n" ,
67+ 'message ' => 'Multiple file, multiple generic errors ' ,
68+ 'exitCode ' => 1 ,
69+ 'numFileErrors ' => 4 ,
70+ 'numGenericErrors ' => 2 ,
71+ 'verbose ' => false ,
72+ 'expected ' => '?:?:first generic error
73+ ?:?:second generic<error>
74+ /data/folder/with space/and unicode 😃/project/folder with unicode 😃/file name with "spaces" and unicode 😃.php:2:Bar
75+ Bar2
76+ /data/folder/with space/and unicode 😃/project/folder with unicode 😃/file name with "spaces" and unicode 😃.php:4:Foo
77+ /data/folder/with space/and unicode 😃/project/foo.php:1:Foo<Bar>
78+ /data/folder/with space/and unicode 😃/project/foo.php:5:Bar
79+ Bar2
80+ ' ,
81+ ];
82+
83+ yield [
84+ 'message ' => 'One file error with tip ' ,
85+ 'exitCode ' => 1 ,
86+ 'numFileErrors ' => [5 , 6 ],
87+ 'numGenericErrors ' => 0 ,
88+ 'verbose ' => false ,
89+ 'expected ' => '/data/folder/with space/and unicode 😃/project/foo.php:5:Foobar\Buz
90+ ' ,
91+ ];
92+
93+ yield [
94+ 'message ' => 'One file error with tip and verbose ' ,
95+ 'exitCode ' => 1 ,
96+ 'numFileErrors ' => [5 , 6 ],
97+ 'numGenericErrors ' => 0 ,
98+ 'verbose ' => true ,
99+ 'expected ' => '/data/folder/with space/and unicode 😃/project/foo.php:5:Foobar\Buz [identifier=foobar.buz]
100+ ' ,
68101 ];
69102 }
70103
71104 /**
72105 * @dataProvider dataFormatterOutputProvider
73- *
106+ * @param array{int, int}|int $numFileErrors
74107 */
75108 public function testFormatErrors (
76109 string $ message ,
77110 int $ exitCode ,
78- int $ numFileErrors ,
111+ array | int $ numFileErrors ,
79112 int $ numGenericErrors ,
113+ bool $ verbose ,
80114 string $ expected ,
81115 ): void
82116 {
83117 $ formatter = new RawErrorFormatter ();
84118
85119 $ this ->assertSame ($ exitCode , $ formatter ->formatErrors (
86120 $ this ->getAnalysisResult ($ numFileErrors , $ numGenericErrors ),
87- $ this ->getOutput (),
121+ $ this ->getOutput (false , $ verbose ),
88122 ), sprintf ('%s: response code do not match ' , $ message ));
89123
90- $ this ->assertEquals ($ expected , $ this ->getOutputContent (), sprintf ('%s: output do not match ' , $ message ));
124+ $ this ->assertEquals ($ expected , $ this ->getOutputContent (false , $ verbose ), sprintf ('%s: output do not match ' , $ message ));
91125 }
92126
93127}
0 commit comments