Skip to content

Commit 5c3c4d0

Browse files
Leftover from 5e09cdc
1 parent 5e09cdc commit 5c3c4d0

File tree

3 files changed

+30
-30
lines changed

3 files changed

+30
-30
lines changed

tests/DifferTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -331,15 +331,15 @@ public function textProvider(): array
331331
public function testDiffToArrayInvalidFromType(): void
332332
{
333333
$this->expectException(InvalidArgumentException::class);
334-
$this->expectExceptionMessageRegExp('#^"from" must be an array or string\.$#');
334+
$this->expectExceptionMessageMatches('#^"from" must be an array or string\.$#');
335335

336336
$this->differ->diffToArray(null, '');
337337
}
338338

339339
public function testDiffInvalidToType(): void
340340
{
341341
$this->expectException(InvalidArgumentException::class);
342-
$this->expectExceptionMessageRegExp('#^"to" must be an array or string\.$#');
342+
$this->expectExceptionMessageMatches('#^"to" must be an array or string\.$#');
343343

344344
$this->differ->diffToArray('', new \stdClass);
345345
}
@@ -428,15 +428,15 @@ public function provideSplitStringByLinesCases(): array
428428
public function testConstructorInvalidArgInt(): void
429429
{
430430
$this->expectException(InvalidArgumentException::class);
431-
$this->expectExceptionMessageRegExp('/^Expected builder to be an instance of DiffOutputBuilderInterface, <null> or a string, got integer "1"\.$/');
431+
$this->expectExceptionMessageMatches('/^Expected builder to be an instance of DiffOutputBuilderInterface, <null> or a string, got integer "1"\.$/');
432432

433433
new Differ(1);
434434
}
435435

436436
public function testConstructorInvalidArgObject(): void
437437
{
438438
$this->expectException(InvalidArgumentException::class);
439-
$this->expectExceptionMessageRegExp('/^Expected builder to be an instance of DiffOutputBuilderInterface, <null> or a string, got instance of "SplFileInfo"\.$/');
439+
$this->expectExceptionMessageMatches('/^Expected builder to be an instance of DiffOutputBuilderInterface, <null> or a string, got instance of "SplFileInfo"\.$/');
440440

441441
new Differ(new \SplFileInfo(__FILE__));
442442
}

tests/Output/StrictUnifiedDiffOutputBuilderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ public function testEmptyDiff(): void
314314
public function testInvalidConfiguration(array $options, string $message): void
315315
{
316316
$this->expectException(ConfigurationException::class);
317-
$this->expectExceptionMessageRegExp(\sprintf('#^%s$#', \preg_quote($message, '#')));
317+
$this->expectExceptionMessageMatches(\sprintf('#^%s$#', \preg_quote($message, '#')));
318318

319319
new StrictUnifiedDiffOutputBuilder($options);
320320
}

tests/Utils/UnifiedDiffAssertTraitTest.php

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -60,39 +60,39 @@ public function provideValidCases(): array
6060
public function testNoLinebreakEnd(): void
6161
{
6262
$this->expectException(\UnexpectedValueException::class);
63-
$this->expectExceptionMessageRegExp(\sprintf('#^%s$#', \preg_quote('Expected diff to end with a line break, got "C".', '#')));
63+
$this->expectExceptionMessageMatches(\sprintf('#^%s$#', \preg_quote('Expected diff to end with a line break, got "C".', '#')));
6464

6565
$this->assertValidUnifiedDiffFormat("A\nB\nC");
6666
}
6767

6868
public function testInvalidStartWithoutHeader(): void
6969
{
7070
$this->expectException(\UnexpectedValueException::class);
71-
$this->expectExceptionMessageRegExp(\sprintf('#^%s$#', \preg_quote("Expected line to start with '@', '-' or '+', got \"A\n\". Line 1.", '#')));
71+
$this->expectExceptionMessageMatches(\sprintf('#^%s$#', \preg_quote("Expected line to start with '@', '-' or '+', got \"A\n\". Line 1.", '#')));
7272

7373
$this->assertValidUnifiedDiffFormat("A\n");
7474
}
7575

7676
public function testInvalidStartHeader1(): void
7777
{
7878
$this->expectException(\UnexpectedValueException::class);
79-
$this->expectExceptionMessageRegExp(\sprintf('#^%s$#', \preg_quote("Line 1 indicates a header, so line 2 must start with \"+++\".\nLine 1: \"--- A\n\"\nLine 2: \"+ 1\n\".", '#')));
79+
$this->expectExceptionMessageMatches(\sprintf('#^%s$#', \preg_quote("Line 1 indicates a header, so line 2 must start with \"+++\".\nLine 1: \"--- A\n\"\nLine 2: \"+ 1\n\".", '#')));
8080

8181
$this->assertValidUnifiedDiffFormat("--- A\n+ 1\n");
8282
}
8383

8484
public function testInvalidStartHeader2(): void
8585
{
8686
$this->expectException(\UnexpectedValueException::class);
87-
$this->expectExceptionMessageRegExp(\sprintf('#^%s$#', \preg_quote("Header line does not match expected pattern, got \"+++ file X\n\". Line 2.", '#')));
87+
$this->expectExceptionMessageMatches(\sprintf('#^%s$#', \preg_quote("Header line does not match expected pattern, got \"+++ file X\n\". Line 2.", '#')));
8888

8989
$this->assertValidUnifiedDiffFormat("--- A\n+++ file\tX\n");
9090
}
9191

9292
public function testInvalidStartHeader3(): void
9393
{
9494
$this->expectException(\UnexpectedValueException::class);
95-
$this->expectExceptionMessageRegExp(\sprintf('#^%s$#', \preg_quote('Date of header line does not match expected pattern, got "[invalid date]". Line 1.', '#')));
95+
$this->expectExceptionMessageMatches(\sprintf('#^%s$#', \preg_quote('Date of header line does not match expected pattern, got "[invalid date]". Line 1.', '#')));
9696

9797
$this->assertValidUnifiedDiffFormat(
9898
"--- Original\t[invalid date]
@@ -108,7 +108,7 @@ public function testInvalidStartHeader3(): void
108108
public function testInvalidStartHeader4(): void
109109
{
110110
$this->expectException(\UnexpectedValueException::class);
111-
$this->expectExceptionMessageRegExp(\sprintf('#^%s$#', \preg_quote("Expected header line to start with \"+++ \", got \"+++INVALID\n\". Line 2.", '#')));
111+
$this->expectExceptionMessageMatches(\sprintf('#^%s$#', \preg_quote("Expected header line to start with \"+++ \", got \"+++INVALID\n\". Line 2.", '#')));
112112

113113
$this->assertValidUnifiedDiffFormat(
114114
'--- Original
@@ -124,7 +124,7 @@ public function testInvalidStartHeader4(): void
124124
public function testInvalidLine1(): void
125125
{
126126
$this->expectException(\UnexpectedValueException::class);
127-
$this->expectExceptionMessageRegExp(\sprintf('#^%s$#', \preg_quote("Expected line to start with '@', '-' or '+', got \"1\n\". Line 5.", '#')));
127+
$this->expectExceptionMessageMatches(\sprintf('#^%s$#', \preg_quote("Expected line to start with '@', '-' or '+', got \"1\n\". Line 5.", '#')));
128128

129129
$this->assertValidUnifiedDiffFormat(
130130
'--- Original
@@ -140,7 +140,7 @@ public function testInvalidLine1(): void
140140
public function testInvalidLine2(): void
141141
{
142142
$this->expectException(\UnexpectedValueException::class);
143-
$this->expectExceptionMessageRegExp(\sprintf('#^%s$#', \preg_quote('Expected string length of minimal 2, got 1. Line 4.', '#')));
143+
$this->expectExceptionMessageMatches(\sprintf('#^%s$#', \preg_quote('Expected string length of minimal 2, got 1. Line 4.', '#')));
144144

145145
$this->assertValidUnifiedDiffFormat(
146146
'--- Original
@@ -155,7 +155,7 @@ public function testInvalidLine2(): void
155155
public function testHunkInvalidFormat(): void
156156
{
157157
$this->expectException(\UnexpectedValueException::class);
158-
$this->expectExceptionMessageRegExp(\sprintf('#^%s$#', \preg_quote("Hunk header line does not match expected pattern, got \"@@ INVALID -1,1 +1,1 @@\n\". Line 3.", '#')));
158+
$this->expectExceptionMessageMatches(\sprintf('#^%s$#', \preg_quote("Hunk header line does not match expected pattern, got \"@@ INVALID -1,1 +1,1 @@\n\". Line 3.", '#')));
159159

160160
$this->assertValidUnifiedDiffFormat(
161161
'--- Original
@@ -170,7 +170,7 @@ public function testHunkInvalidFormat(): void
170170
public function testHunkOverlapFrom(): void
171171
{
172172
$this->expectException(\UnexpectedValueException::class);
173-
$this->expectExceptionMessageRegExp(\sprintf('#^%s$#', \preg_quote('Unexpected new hunk; "from" (\'-\') start overlaps previous hunk. Line 6.', '#')));
173+
$this->expectExceptionMessageMatches(\sprintf('#^%s$#', \preg_quote('Unexpected new hunk; "from" (\'-\') start overlaps previous hunk. Line 6.', '#')));
174174

175175
$this->assertValidUnifiedDiffFormat(
176176
'--- Original
@@ -188,7 +188,7 @@ public function testHunkOverlapFrom(): void
188188
public function testHunkOverlapTo(): void
189189
{
190190
$this->expectException(\UnexpectedValueException::class);
191-
$this->expectExceptionMessageRegExp(\sprintf('#^%s$#', \preg_quote('Unexpected new hunk; "to" (\'+\') start overlaps previous hunk. Line 6.', '#')));
191+
$this->expectExceptionMessageMatches(\sprintf('#^%s$#', \preg_quote('Unexpected new hunk; "to" (\'+\') start overlaps previous hunk. Line 6.', '#')));
192192

193193
$this->assertValidUnifiedDiffFormat(
194194
'--- Original
@@ -206,7 +206,7 @@ public function testHunkOverlapTo(): void
206206
public function testExpectHunk1(): void
207207
{
208208
$this->expectException(\UnexpectedValueException::class);
209-
$this->expectExceptionMessageRegExp(\sprintf('#^%s$#', \preg_quote('Expected hunk start (\'@\'), got "+". Line 6.', '#')));
209+
$this->expectExceptionMessageMatches(\sprintf('#^%s$#', \preg_quote('Expected hunk start (\'@\'), got "+". Line 6.', '#')));
210210

211211
$this->assertValidUnifiedDiffFormat(
212212
'--- Original
@@ -222,7 +222,7 @@ public function testExpectHunk1(): void
222222
public function testExpectHunk2(): void
223223
{
224224
$this->expectException(\UnexpectedValueException::class);
225-
$this->expectExceptionMessageRegExp(\sprintf('#^%s$#', \preg_quote('Unexpected hunk start (\'@\'). Line 6.', '#')));
225+
$this->expectExceptionMessageMatches(\sprintf('#^%s$#', \preg_quote('Unexpected hunk start (\'@\'). Line 6.', '#')));
226226

227227
$this->assertValidUnifiedDiffFormat(
228228
'--- Original
@@ -238,7 +238,7 @@ public function testExpectHunk2(): void
238238
public function testMisplacedLineAfterComments1(): void
239239
{
240240
$this->expectException(\UnexpectedValueException::class);
241-
$this->expectExceptionMessageRegExp(\sprintf('#^%s$#', \preg_quote('Unexpected line as 2 "No newline" markers have found, ". Line 8.', '#')));
241+
$this->expectExceptionMessageMatches(\sprintf('#^%s$#', \preg_quote('Unexpected line as 2 "No newline" markers have found, ". Line 8.', '#')));
242242

243243
$this->assertValidUnifiedDiffFormat(
244244
'--- Original
@@ -256,7 +256,7 @@ public function testMisplacedLineAfterComments1(): void
256256
public function testMisplacedLineAfterComments2(): void
257257
{
258258
$this->expectException(\UnexpectedValueException::class);
259-
$this->expectExceptionMessageRegExp(\sprintf('#^%s$#', \preg_quote('Unexpected line as 2 "No newline" markers have found, ". Line 7.', '#')));
259+
$this->expectExceptionMessageMatches(\sprintf('#^%s$#', \preg_quote('Unexpected line as 2 "No newline" markers have found, ". Line 7.', '#')));
260260

261261
$this->assertValidUnifiedDiffFormat(
262262
'--- Original
@@ -273,7 +273,7 @@ public function testMisplacedLineAfterComments2(): void
273273
public function testMisplacedLineAfterComments3(): void
274274
{
275275
$this->expectException(\UnexpectedValueException::class);
276-
$this->expectExceptionMessageRegExp(\sprintf('#^%s$#', \preg_quote('Unexpected line as 2 "No newline" markers have found, ". Line 7.', '#')));
276+
$this->expectExceptionMessageMatches(\sprintf('#^%s$#', \preg_quote('Unexpected line as 2 "No newline" markers have found, ". Line 7.', '#')));
277277

278278
$this->assertValidUnifiedDiffFormat(
279279
'--- Original
@@ -290,7 +290,7 @@ public function testMisplacedLineAfterComments3(): void
290290
public function testMisplacedComment(): void
291291
{
292292
$this->expectException(\UnexpectedValueException::class);
293-
$this->expectExceptionMessageRegExp(\sprintf('#^%s$#', \preg_quote('Unexpected "\ No newline at end of file", it must be preceded by \'+\' or \'-\' line. Line 1.', '#')));
293+
$this->expectExceptionMessageMatches(\sprintf('#^%s$#', \preg_quote('Unexpected "\ No newline at end of file", it must be preceded by \'+\' or \'-\' line. Line 1.', '#')));
294294

295295
$this->assertValidUnifiedDiffFormat(
296296
'\ No newline at end of file
@@ -301,7 +301,7 @@ public function testMisplacedComment(): void
301301
public function testUnexpectedDuplicateNoNewLineEOF(): void
302302
{
303303
$this->expectException(\UnexpectedValueException::class);
304-
$this->expectExceptionMessageRegExp(\sprintf('#^%s$#', \preg_quote('Unexpected "\\ No newline at end of file", "\\" was already closed. Line 8.', '#')));
304+
$this->expectExceptionMessageMatches(\sprintf('#^%s$#', \preg_quote('Unexpected "\\ No newline at end of file", "\\" was already closed. Line 8.', '#')));
305305

306306
$this->assertValidUnifiedDiffFormat(
307307
'--- Original
@@ -319,7 +319,7 @@ public function testUnexpectedDuplicateNoNewLineEOF(): void
319319
public function testFromAfterClose(): void
320320
{
321321
$this->expectException(\UnexpectedValueException::class);
322-
$this->expectExceptionMessageRegExp(\sprintf('#^%s$#', \preg_quote('Not expected from (\'-\'), already closed by "\ No newline at end of file". Line 6.', '#')));
322+
$this->expectExceptionMessageMatches(\sprintf('#^%s$#', \preg_quote('Not expected from (\'-\'), already closed by "\ No newline at end of file". Line 6.', '#')));
323323

324324
$this->assertValidUnifiedDiffFormat(
325325
'--- Original
@@ -336,7 +336,7 @@ public function testFromAfterClose(): void
336336
public function testSameAfterFromClose(): void
337337
{
338338
$this->expectException(\UnexpectedValueException::class);
339-
$this->expectExceptionMessageRegExp(\sprintf('#^%s$#', \preg_quote('Not expected same (\' \'), \'-\' already closed by "\ No newline at end of file". Line 6.', '#')));
339+
$this->expectExceptionMessageMatches(\sprintf('#^%s$#', \preg_quote('Not expected same (\' \'), \'-\' already closed by "\ No newline at end of file". Line 6.', '#')));
340340

341341
$this->assertValidUnifiedDiffFormat(
342342
'--- Original
@@ -353,7 +353,7 @@ public function testSameAfterFromClose(): void
353353
public function testToAfterClose(): void
354354
{
355355
$this->expectException(\UnexpectedValueException::class);
356-
$this->expectExceptionMessageRegExp(\sprintf('#^%s$#', \preg_quote('Not expected to (\'+\'), already closed by "\ No newline at end of file". Line 6.', '#')));
356+
$this->expectExceptionMessageMatches(\sprintf('#^%s$#', \preg_quote('Not expected to (\'+\'), already closed by "\ No newline at end of file". Line 6.', '#')));
357357

358358
$this->assertValidUnifiedDiffFormat(
359359
'--- Original
@@ -370,7 +370,7 @@ public function testToAfterClose(): void
370370
public function testSameAfterToClose(): void
371371
{
372372
$this->expectException(\UnexpectedValueException::class);
373-
$this->expectExceptionMessageRegExp(\sprintf('#^%s$#', \preg_quote('Not expected same (\' \'), \'+\' already closed by "\ No newline at end of file". Line 6.', '#')));
373+
$this->expectExceptionMessageMatches(\sprintf('#^%s$#', \preg_quote('Not expected same (\' \'), \'+\' already closed by "\ No newline at end of file". Line 6.', '#')));
374374

375375
$this->assertValidUnifiedDiffFormat(
376376
'--- Original
@@ -387,7 +387,7 @@ public function testSameAfterToClose(): void
387387
public function testUnexpectedEOFFromMissingLines(): void
388388
{
389389
$this->expectException(\UnexpectedValueException::class);
390-
$this->expectExceptionMessageRegExp(\sprintf('#^%s$#', \preg_quote('Unexpected EOF, number of lines in hunk "from" (\'-\')) mismatched. Line 7.', '#')));
390+
$this->expectExceptionMessageMatches(\sprintf('#^%s$#', \preg_quote('Unexpected EOF, number of lines in hunk "from" (\'-\')) mismatched. Line 7.', '#')));
391391

392392
$this->assertValidUnifiedDiffFormat(
393393
'--- Original
@@ -403,7 +403,7 @@ public function testUnexpectedEOFFromMissingLines(): void
403403
public function testUnexpectedEOFToMissingLines(): void
404404
{
405405
$this->expectException(\UnexpectedValueException::class);
406-
$this->expectExceptionMessageRegExp(\sprintf('#^%s$#', \preg_quote('Unexpected EOF, number of lines in hunk "to" (\'+\')) mismatched. Line 7.', '#')));
406+
$this->expectExceptionMessageMatches(\sprintf('#^%s$#', \preg_quote('Unexpected EOF, number of lines in hunk "to" (\'+\')) mismatched. Line 7.', '#')));
407407

408408
$this->assertValidUnifiedDiffFormat(
409409
'--- Original
@@ -419,7 +419,7 @@ public function testUnexpectedEOFToMissingLines(): void
419419
public function testUnexpectedEOFBothFromAndToMissingLines(): void
420420
{
421421
$this->expectException(\UnexpectedValueException::class);
422-
$this->expectExceptionMessageRegExp(\sprintf('#^%s$#', \preg_quote('Unexpected EOF, number of lines in hunk "from" (\'-\')) and "to" (\'+\') mismatched. Line 7.', '#')));
422+
$this->expectExceptionMessageMatches(\sprintf('#^%s$#', \preg_quote('Unexpected EOF, number of lines in hunk "from" (\'-\')) and "to" (\'+\') mismatched. Line 7.', '#')));
423423

424424
$this->assertValidUnifiedDiffFormat(
425425
'--- Original

0 commit comments

Comments
 (0)