@@ -11,83 +11,117 @@ class RawErrorFormatterTest extends ErrorFormatterTestCase
11
11
public function dataFormatterOutputProvider (): iterable
12
12
{
13
13
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 ' => '' ,
19
20
];
20
21
21
22
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" ,
27
29
];
28
30
29
31
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" ,
35
38
];
36
39
37
40
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
+ ' ,
46
53
];
47
54
48
55
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
+ ' ,
55
64
];
56
65
57
66
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
+ ' ,
68
101
];
69
102
}
70
103
71
104
/**
72
105
* @dataProvider dataFormatterOutputProvider
73
- *
106
+ * @param array{int, int}|int $numFileErrors
74
107
*/
75
108
public function testFormatErrors (
76
109
string $ message ,
77
110
int $ exitCode ,
78
- int $ numFileErrors ,
111
+ array | int $ numFileErrors ,
79
112
int $ numGenericErrors ,
113
+ bool $ verbose ,
80
114
string $ expected ,
81
115
): void
82
116
{
83
117
$ formatter = new RawErrorFormatter ();
84
118
85
119
$ this ->assertSame ($ exitCode , $ formatter ->formatErrors (
86
120
$ this ->getAnalysisResult ($ numFileErrors , $ numGenericErrors ),
87
- $ this ->getOutput (),
121
+ $ this ->getOutput (false , $ verbose ),
88
122
), sprintf ('%s: response code do not match ' , $ message ));
89
123
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 ));
91
125
}
92
126
93
127
}
0 commit comments