@@ -28,22 +28,24 @@ protected function tearDown(): void
2828 public function dataFormatterOutputProvider (): iterable
2929 {
3030 yield [
31- 'No errors ' ,
32- 0 ,
33- 0 ,
34- 0 ,
35- '
31+ 'message ' => 'No errors ' ,
32+ 'exitCode ' => 0 ,
33+ 'numFileErrors ' => 0 ,
34+ 'numGenericErrors ' => 0 ,
35+ 'extraEnvVars ' => [],
36+ 'expected ' => '
3637 [OK] No errors
3738
3839 ' ,
3940 ];
4041
4142 yield [
42- 'One file error ' ,
43- 1 ,
44- 1 ,
45- 0 ,
46- ' ------ -------------------------------------------------------------------
43+ 'message ' => 'One file error ' ,
44+ 'exitCode ' => 1 ,
45+ 'numFileErrors ' => 1 ,
46+ 'numGenericErrors ' => 0 ,
47+ 'extraEnvVars ' => [],
48+ 'expected ' => ' ------ -------------------------------------------------------------------
4749 Line folder with unicode 😃/file name with "spaces" and unicode 😃.php
4850 ------ -------------------------------------------------------------------
4951 4 Foo
@@ -56,11 +58,12 @@ public function dataFormatterOutputProvider(): iterable
5658 ];
5759
5860 yield [
59- 'One generic error ' ,
60- 1 ,
61- 0 ,
62- 1 ,
63- ' -- ---------------------
61+ 'message ' => 'One generic error ' ,
62+ 'exitCode ' => 1 ,
63+ 'numFileErrors ' => 0 ,
64+ 'numGenericErrors ' => 1 ,
65+ 'extraEnvVars ' => [],
66+ 'expected ' => ' -- ---------------------
6467 Error
6568 -- ---------------------
6669 first generic error
@@ -73,11 +76,12 @@ public function dataFormatterOutputProvider(): iterable
7376 ];
7477
7578 yield [
76- 'Multiple file errors ' ,
77- 1 ,
78- 4 ,
79- 0 ,
80- ' ------ -------------------------------------------------------------------
79+ 'message ' => 'Multiple file errors ' ,
80+ 'exitCode ' => 1 ,
81+ 'numFileErrors ' => 4 ,
82+ 'numGenericErrors ' => 0 ,
83+ 'extraEnvVars ' => [],
84+ 'expected ' => ' ------ -------------------------------------------------------------------
8185 Line folder with unicode 😃/file name with "spaces" and unicode 😃.php
8286 ------ -------------------------------------------------------------------
8387 2 Bar
@@ -100,11 +104,12 @@ public function dataFormatterOutputProvider(): iterable
100104 ];
101105
102106 yield [
103- 'Multiple generic errors ' ,
104- 1 ,
105- 0 ,
106- 2 ,
107- ' -- ----------------------
107+ 'message ' => 'Multiple generic errors ' ,
108+ 'exitCode ' => 1 ,
109+ 'numFileErrors ' => 0 ,
110+ 'numGenericErrors ' => 2 ,
111+ 'extraEnvVars ' => [],
112+ 'expected ' => ' -- ----------------------
108113 Error
109114 -- ----------------------
110115 first generic error
@@ -118,11 +123,12 @@ public function dataFormatterOutputProvider(): iterable
118123 ];
119124
120125 yield [
121- 'Multiple file, multiple generic errors ' ,
122- 1 ,
123- 4 ,
124- 2 ,
125- ' ------ -------------------------------------------------------------------
126+ 'message ' => 'Multiple file, multiple generic errors ' ,
127+ 'exitCode ' => 1 ,
128+ 'numFileErrors ' => 4 ,
129+ 'numGenericErrors ' => 2 ,
130+ 'extraEnvVars ' => [],
131+ 'expected ' => ' ------ -------------------------------------------------------------------
126132 Line folder with unicode 😃/file name with "spaces" and unicode 😃.php
127133 ------ -------------------------------------------------------------------
128134 2 Bar
@@ -148,6 +154,24 @@ public function dataFormatterOutputProvider(): iterable
148154
149155 [ERROR] Found 6 errors
150156
157+ ' ,
158+ ];
159+
160+ yield [
161+ 'message ' => 'One file error, called via Visual Studio Code ' ,
162+ 'exitCode ' => 1 ,
163+ 'numFileErrors ' => 1 ,
164+ 'numGenericErrors ' => 0 ,
165+ 'extraEnvVars ' => ['TERM_PROGRAM=vscode ' ],
166+ 'expected ' => ' ------ -------------------------------------------------------------------
167+ Line folder with unicode 😃/file name with "spaces" and unicode 😃.php
168+ ------ -------------------------------------------------------------------
169+ :4 Foo
170+ ------ -------------------------------------------------------------------
171+
172+
173+ [ERROR] Found 1 error
174+
151175 ' ,
152176 ];
153177 }
@@ -161,6 +185,7 @@ public function testFormatErrors(
161185 int $ exitCode ,
162186 int $ numFileErrors ,
163187 int $ numGenericErrors ,
188+ array $ extraEnvVars ,
164189 string $ expected ,
165190 ): void
166191 {
@@ -169,6 +194,10 @@ public function testFormatErrors(
169194 }
170195 $ formatter = $ this ->createErrorFormatter (null );
171196
197+ foreach ($ extraEnvVars as $ envVar ) {
198+ putenv ($ envVar );
199+ }
200+
172201 $ this ->assertSame ($ exitCode , $ formatter ->formatErrors (
173202 $ this ->getAnalysisResult ($ numFileErrors , $ numGenericErrors ),
174203 $ this ->getOutput (),
0 commit comments