@@ -29,8 +29,12 @@ public function testExceptionIfPathIsNotAbsolute(): void
29
29
#[DataProvider('provideQuestionMark ' )]
30
30
#[DataProvider('provideCharacterGroup ' )]
31
31
#[DataProvider('provideRelativePathSegments ' )]
32
- public function testMatch (FileMatcherPattern $ pattern , array $ matchMap ): void
32
+ public function testMatch (FileMatcherPattern $ pattern , array $ matchMap, ? string $ skip = null ): void
33
33
{
34
+ if ($ skip ) {
35
+ self ::markTestSkipped ($ skip );
36
+ }
37
+
34
38
self ::assertMap ($ pattern , $ matchMap );
35
39
}
36
40
@@ -175,8 +179,6 @@ public static function provideGlobstar(): Generator
175
179
],
176
180
];
177
181
178
- // TODO: this edge case
179
- return ;
180
182
// PHPUnit will match ALL directories within `/foo` with `/foo/A**`
181
183
// however it will NOT match anything with `/foo/Aa**`
182
184
//
@@ -193,6 +195,7 @@ public static function provideGlobstar(): Generator
193
195
'/baz/emm/foo/bad ' => false ,
194
196
'/baz/emm/foo/bad/boo ' => false ,
195
197
],
198
+ 'PHPUnit edge case ' ,
196
199
];
197
200
}
198
201
@@ -290,6 +293,10 @@ public static function provideQuestionMark(): Generator
290
293
*/
291
294
public static function provideCharacterGroup (): Generator
292
295
{
296
+ // TODO: POSIX will interpret an unterminated [ group as a literal while
297
+ // Regex will crash -- we'd need to look ahead to see if the [ is
298
+ // terminated if we continue using Regex.
299
+ //
293
300
yield 'unterminated char group ' => [
294
301
new FileMatcherPattern ('/[AB ' ),
295
302
[
@@ -298,6 +305,7 @@ public static function provideCharacterGroup(): Generator
298
305
'/[AB ' => true ,
299
306
'/[AB/foo ' => true ,
300
307
],
308
+ 'Unterminated square bracket ' ,
301
309
];
302
310
yield 'single char leaf ' => [
303
311
new FileMatcherPattern ('/[A] ' ),
@@ -310,7 +318,7 @@ public static function provideCharacterGroup(): Generator
310
318
new FileMatcherPattern ('/a/[B]/c ' ),
311
319
[
312
320
'/a ' => false ,
313
- '/a/B ' => true ,
321
+ '/a/B ' => false ,
314
322
'/a/B/c ' => true ,
315
323
'/a/Z/c ' => false ,
316
324
],
@@ -319,7 +327,7 @@ public static function provideCharacterGroup(): Generator
319
327
new FileMatcherPattern ('/a/[ABC]/c ' ),
320
328
[
321
329
'/a ' => false ,
322
- '/a/A ' => true ,
330
+ '/a/A ' => false ,
323
331
'/a/B/c ' => true ,
324
332
'/a/C/c ' => true ,
325
333
'/a/Z/c ' => false ,
@@ -338,7 +346,6 @@ public static function provideCharacterGroup(): Generator
338
346
];
339
347
340
348
// https://man7.org/linux/man-pages/man7/glob.7.html
341
- // example from glob manpage
342
349
yield 'square bracket in char group ' => [
343
350
new FileMatcherPattern ('/[][!] ' ),
344
351
[
@@ -349,6 +356,7 @@ public static function provideCharacterGroup(): Generator
349
356
'/a ' => false ,
350
357
'/ ' => false ,
351
358
],
359
+ 'Unterminated square bracket 2 ' ,
352
360
];
353
361
354
362
yield 'match ranges ' => [
@@ -380,8 +388,10 @@ public static function provideCharacterGroup(): Generator
380
388
yield 'dash in group ' => [
381
389
new FileMatcherPattern ('/a/[-]/c ' ),
382
390
[
383
- '/a/- ' => true ,
384
- '/a/-/fo ' => true ,
391
+ '/a/- ' => false ,
392
+ '/a/-/c ' => true ,
393
+ '/a/-/ca/d ' => false ,
394
+ '/a/-/c/da ' => true ,
385
395
'/a/a/fo ' => false ,
386
396
],
387
397
];
@@ -390,26 +400,27 @@ public static function provideCharacterGroup(): Generator
390
400
new FileMatcherPattern ('/a/[-a-c]/c ' ),
391
401
[
392
402
'/a/a ' => false ,
393
- '/a/- ' => true ,
403
+ '/a/- ' => false ,
404
+ '/a/-/c ' => true ,
394
405
'/a/d ' => false ,
395
406
'/a/-b/c ' => false ,
396
- '/a/a/fo ' => true ,
397
- '/a/c/fo ' => true ,
398
- '/a/d/fo ' => false ,
407
+ '/a/a/c/ fo ' => true ,
408
+ '/a/c/fo ' => false ,
409
+ '/a/d/c ' => false ,
399
410
],
400
411
];
401
412
402
413
yield 'range infix dash ' => [
403
414
new FileMatcherPattern ('/a/[a-c-e-f]/c ' ),
404
415
[
405
416
'/a/a ' => false ,
406
- '/a/- ' => true ,
407
- '/a/-/a ' => true ,
408
- '/a/c/a ' => true ,
409
- '/a/a/a ' => true ,
410
- '/a/d/a ' => false ,
411
- '/a/e/a ' => true ,
412
- '/a/g/a ' => false ,
417
+ '/a/-/c ' => true ,
418
+ '/a/-/a ' => false ,
419
+ '/a/c/c ' => true ,
420
+ '/a/a/c ' => true ,
421
+ '/a/d/c ' => false ,
422
+ '/a/e/c ' => true ,
423
+ '/a/g/c ' => false ,
413
424
'/a/-/c ' => true ,
414
425
],
415
426
];
@@ -418,13 +429,13 @@ public static function provideCharacterGroup(): Generator
418
429
new FileMatcherPattern ('/a/[a-ce-f-]/c ' ),
419
430
[
420
431
'/a/a ' => false ,
421
- '/a/- ' => true ,
422
- '/a/-/a ' => true ,
423
- '/a/c/a ' => true ,
424
- '/a/a/a ' => true ,
425
- '/a/d/a ' => false ,
426
- '/a/e/a ' => true ,
427
- '/a/g/a ' => false ,
432
+ '/a/-/c ' => true ,
433
+ '/a/-/c ' => true ,
434
+ '/a/c/c ' => true ,
435
+ '/a/a/c ' => true ,
436
+ '/a/d/c ' => false ,
437
+ '/a/e/c ' => true ,
438
+ '/a/g/c ' => false ,
428
439
'/a/-/c ' => true ,
429
440
],
430
441
];
@@ -433,30 +444,30 @@ public static function provideCharacterGroup(): Generator
433
444
new FileMatcherPattern ('/a/[!a]/c ' ),
434
445
[
435
446
'/a/a ' => false ,
436
- '/a/a/b ' => false ,
437
- '/a/b/b ' => true ,
438
- '/a/0/b ' => true ,
439
- '/a/0a/b ' => false ,
447
+ '/a/a/c ' => false ,
448
+ '/a/b/c ' => true ,
449
+ '/a/0/c ' => true ,
450
+ '/a/0a/c ' => false ,
440
451
]
441
452
];
442
453
443
454
yield 'complementation multi char ' => [
444
455
new FileMatcherPattern ('/a/[!abc]/c ' ),
445
456
[
446
- '/a/a/b ' => false ,
447
- '/a/b/b ' => false ,
448
- '/a/c/b ' => false ,
449
- '/a/d/b ' => true ,
457
+ '/a/a/c ' => false ,
458
+ '/a/b/c ' => false ,
459
+ '/a/c/c ' => false ,
460
+ '/a/d/c ' => true ,
450
461
]
451
462
];
452
463
453
464
yield 'complementation range ' => [
454
465
new FileMatcherPattern ('/a/[!a-c]/c ' ),
455
466
[
456
- '/a/a/b ' => false ,
457
- '/a/b/b ' => false ,
458
- '/a/c/b ' => false ,
459
- '/a/d/b ' => true ,
467
+ '/a/a/c ' => false ,
468
+ '/a/b/c ' => false ,
469
+ '/a/c/c ' => false ,
470
+ '/a/d/c ' => true ,
460
471
]
461
472
];
462
473
@@ -466,7 +477,8 @@ public static function provideCharacterGroup(): Generator
466
477
'/a/[!a-c]/c ' => true ,
467
478
'/a/[!a-c]/c/d ' => true ,
468
479
'/b/[!a-c]/c/d ' => false ,
469
- ]
480
+ ],
481
+ 'Regex escaping ' ,
470
482
];
471
483
472
484
// TODO: test all the character clases
@@ -479,7 +491,8 @@ public static function provideCharacterGroup(): Generator
479
491
'/a/1/c ' => true ,
480
492
'/a/2/c ' => true ,
481
493
'/b/!/c ' => false ,
482
- ]
494
+ ],
495
+ 'Named character classes ' ,
483
496
];
484
497
485
498
// TODO: all of these?
@@ -492,7 +505,8 @@ public static function provideCharacterGroup(): Generator
492
505
[
493
506
'/a/á/c ' => true ,
494
507
'/a/a/c ' => false ,
495
- ]
508
+ ],
509
+ 'Collating symbols ' ,
496
510
];
497
511
498
512
// TODO: all of these?
@@ -506,8 +520,8 @@ public static function provideCharacterGroup(): Generator
506
520
[
507
521
'/a/á/c ' => true ,
508
522
'/a/a/c ' => true ,
509
- ]
510
-
523
+ ],
524
+ ' Equaivalence class expressions ' ,
511
525
];
512
526
}
513
527
@@ -522,8 +536,8 @@ public static function provideRelativePathSegments(): Generator
522
536
[
523
537
'/a/a/c ' => true ,
524
538
'/a/b/c ' => true ,
525
- ]
526
-
539
+ ],
540
+ ' Relative path segments ' ,
527
541
];
528
542
}
529
543
/**
0 commit comments