@@ -36,6 +36,7 @@ public static function dataFormatterOutputProvider(): iterable
36
36
0 ,
37
37
0 ,
38
38
0 ,
39
+ false ,
39
40
[],
40
41
];
41
42
@@ -44,6 +45,7 @@ public static function dataFormatterOutputProvider(): iterable
44
45
1 ,
45
46
1 ,
46
47
0 ,
48
+ false ,
47
49
[
48
50
[
49
51
'message ' => '#^Foo$# ' ,
@@ -58,6 +60,7 @@ public static function dataFormatterOutputProvider(): iterable
58
60
1 ,
59
61
4 ,
60
62
0 ,
63
+ false ,
61
64
[
62
65
[
63
66
'message ' => "#^Bar \nBar2$# " ,
@@ -87,6 +90,7 @@ public static function dataFormatterOutputProvider(): iterable
87
90
1 ,
88
91
4 ,
89
92
2 ,
93
+ false ,
90
94
[
91
95
[
92
96
'message ' => "#^Bar \nBar2$# " ,
@@ -110,6 +114,36 @@ public static function dataFormatterOutputProvider(): iterable
110
114
],
111
115
],
112
116
];
117
+
118
+ yield [
119
+ 'Multiple file, multiple generic errors (raw messages) ' ,
120
+ 1 ,
121
+ 4 ,
122
+ 2 ,
123
+ true ,
124
+ [
125
+ [
126
+ 'rawMessage ' => "Bar \nBar2 " ,
127
+ 'count ' => 1 ,
128
+ 'path ' => 'folder with unicode 😃/file name with "spaces" and unicode 😃.php ' ,
129
+ ],
130
+ [
131
+ 'rawMessage ' => 'Foo ' ,
132
+ 'count ' => 1 ,
133
+ 'path ' => 'folder with unicode 😃/file name with "spaces" and unicode 😃.php ' ,
134
+ ],
135
+ [
136
+ 'rawMessage ' => "Bar \nBar2 " ,
137
+ 'count ' => 1 ,
138
+ 'path ' => 'foo.php ' ,
139
+ ],
140
+ [
141
+ 'rawMessage ' => 'Foo<Bar> ' ,
142
+ 'count ' => 1 ,
143
+ 'path ' => 'foo.php ' ,
144
+ ],
145
+ ],
146
+ ];
113
147
}
114
148
115
149
/**
@@ -121,10 +155,11 @@ public function testFormatErrors(
121
155
int $ exitCode ,
122
156
int $ numFileErrors ,
123
157
int $ numGenericErrors ,
158
+ bool $ useRawMessage ,
124
159
array $ expected ,
125
160
): void
126
161
{
127
- $ formatter = new BaselineNeonErrorFormatter (new SimpleRelativePathHelper (self ::DIRECTORY_PATH ));
162
+ $ formatter = new BaselineNeonErrorFormatter (new SimpleRelativePathHelper (self ::DIRECTORY_PATH ), $ useRawMessage );
128
163
129
164
$ this ->assertSame ($ exitCode , $ formatter ->formatErrors (
130
165
$ this ->getAnalysisResult ($ numFileErrors , $ numGenericErrors ),
@@ -137,7 +172,7 @@ public function testFormatErrors(
137
172
138
173
public function testFormatErrorMessagesRegexEscape (): void
139
174
{
140
- $ formatter = new BaselineNeonErrorFormatter (new SimpleRelativePathHelper (self ::DIRECTORY_PATH ));
175
+ $ formatter = new BaselineNeonErrorFormatter (new SimpleRelativePathHelper (self ::DIRECTORY_PATH ), false );
141
176
142
177
$ result = new AnalysisResult (
143
178
[new Error ('Escape Regex with file # ~ \' () ' , 'Testfile ' )],
@@ -176,11 +211,51 @@ public function testFormatErrorMessagesRegexEscape(): void
176
211
);
177
212
}
178
213
179
- public function testEscapeDiNeon (): void
214
+ /**
215
+ * @return iterable<int, array{Error, bool, array<string, string|int>}>
216
+ */
217
+ public static function dataEscapeDiNeon (): iterable
218
+ {
219
+ yield [
220
+ new Error ('Test %value% ' , 'Testfile ' ),
221
+ false ,
222
+ [
223
+ 'message ' => '#^Test %%value%%$# ' ,
224
+ 'count ' => 1 ,
225
+ 'path ' => 'Testfile ' ,
226
+ ],
227
+ ];
228
+
229
+ yield [
230
+ new Error ('Test %value% ' , 'Testfile ' ),
231
+ true ,
232
+ [
233
+ 'rawMessage ' => 'Test %%value%% ' ,
234
+ 'count ' => 1 ,
235
+ 'path ' => 'Testfile ' ,
236
+ ],
237
+ ];
238
+
239
+ yield [
240
+ new Error ('@Foo ' , 'Testfile ' ),
241
+ true ,
242
+ [
243
+ 'rawMessage ' => '@@Foo ' ,
244
+ 'count ' => 1 ,
245
+ 'path ' => 'Testfile ' ,
246
+ ],
247
+ ];
248
+ }
249
+
250
+ /**
251
+ * @param array<string, string|int> $expected
252
+ */
253
+ #[DataProvider('dataEscapeDiNeon ' )]
254
+ public function testEscapeDiNeon (Error $ error , bool $ useRawMessage , array $ expected ): void
180
255
{
181
- $ formatter = new BaselineNeonErrorFormatter (new SimpleRelativePathHelper (self ::DIRECTORY_PATH ));
256
+ $ formatter = new BaselineNeonErrorFormatter (new SimpleRelativePathHelper (self ::DIRECTORY_PATH ), $ useRawMessage );
182
257
$ result = new AnalysisResult (
183
- [new Error ( ' Test %value% ' , ' Testfile ' ) ],
258
+ [$ error ],
184
259
[],
185
260
[],
186
261
[],
@@ -203,11 +278,7 @@ public function testEscapeDiNeon(): void
203
278
Neon::encode ([
204
279
'parameters ' => [
205
280
'ignoreErrors ' => [
206
- [
207
- 'message ' => '#^Test %%value%%$# ' ,
208
- 'count ' => 1 ,
209
- 'path ' => 'Testfile ' ,
210
- ],
281
+ $ expected ,
211
282
],
212
283
],
213
284
], Neon::BLOCK ),
@@ -245,7 +316,7 @@ public static function outputOrderingProvider(): Generator
245
316
#[DataProvider('outputOrderingProvider ' )]
246
317
public function testOutputOrdering (array $ errors ): void
247
318
{
248
- $ formatter = new BaselineNeonErrorFormatter (new SimpleRelativePathHelper (self ::DIRECTORY_PATH ));
319
+ $ formatter = new BaselineNeonErrorFormatter (new SimpleRelativePathHelper (self ::DIRECTORY_PATH ), false );
249
320
$ result = new AnalysisResult (
250
321
$ errors ,
251
322
[],
@@ -404,7 +475,7 @@ public function testEndOfFileNewlines(
404
475
int $ expectedNewlinesCount ,
405
476
): void
406
477
{
407
- $ formatter = new BaselineNeonErrorFormatter (new SimpleRelativePathHelper (self ::DIRECTORY_PATH ));
478
+ $ formatter = new BaselineNeonErrorFormatter (new SimpleRelativePathHelper (self ::DIRECTORY_PATH ), false );
408
479
$ result = new AnalysisResult (
409
480
$ errors ,
410
481
[],
@@ -468,6 +539,7 @@ public static function dataFormatErrorsWithIdentifiers(): iterable
468
539
6 ,
469
540
))->withIdentifier ('argument.type ' ),
470
541
],
542
+ false ,
471
543
[
472
544
'parameters ' => [
473
545
'ignoreErrors ' => [
@@ -515,6 +587,7 @@ public static function dataFormatErrorsWithIdentifiers(): iterable
515
587
5 ,
516
588
))->withIdentifier ('argument.type ' ),
517
589
],
590
+ false ,
518
591
[
519
592
'parameters ' => [
520
593
'ignoreErrors ' => [
@@ -545,16 +618,59 @@ public static function dataFormatErrorsWithIdentifiers(): iterable
545
618
],
546
619
],
547
620
];
621
+
622
+ yield [
623
+ [
624
+ new Error (
625
+ 'Foo ' ,
626
+ __DIR__ . '/Foo.php ' ,
627
+ 5 ,
628
+ ),
629
+ new Error (
630
+ 'Foo ' ,
631
+ __DIR__ . '/Foo.php ' ,
632
+ 5 ,
633
+ ),
634
+ (new Error (
635
+ 'Foo with identifier ' ,
636
+ __DIR__ . '/Foo.php ' ,
637
+ 5 ,
638
+ ))->withIdentifier ('argument.type ' ),
639
+ (new Error (
640
+ 'Foo with identifier ' ,
641
+ __DIR__ . '/Foo.php ' ,
642
+ 6 ,
643
+ ))->withIdentifier ('argument.type ' ),
644
+ ],
645
+ true ,
646
+ [
647
+ 'parameters ' => [
648
+ 'ignoreErrors ' => [
649
+ [
650
+ 'rawMessage ' => 'Foo ' ,
651
+ 'count ' => 2 ,
652
+ 'path ' => 'Foo.php ' ,
653
+ ],
654
+ [
655
+ 'rawMessage ' => 'Foo with identifier ' ,
656
+ 'identifier ' => 'argument.type ' ,
657
+ 'count ' => 2 ,
658
+ 'path ' => 'Foo.php ' ,
659
+ ],
660
+ ],
661
+ ],
662
+ ],
663
+ ];
548
664
}
549
665
550
666
/**
551
667
* @param list<Error> $errors
552
668
* @param mixed[] $expectedOutput
553
669
*/
554
670
#[DataProvider('dataFormatErrorsWithIdentifiers ' )]
555
- public function testFormatErrorsWithIdentifiers (array $ errors , array $ expectedOutput ): void
671
+ public function testFormatErrorsWithIdentifiers (array $ errors , bool $ useRawMessage , array $ expectedOutput ): void
556
672
{
557
- $ formatter = new BaselineNeonErrorFormatter (new SimpleRelativePathHelper (__DIR__ ));
673
+ $ formatter = new BaselineNeonErrorFormatter (new SimpleRelativePathHelper (__DIR__ ), $ useRawMessage );
558
674
$ formatter ->formatErrors (
559
675
new AnalysisResult (
560
676
$ errors ,
0 commit comments