Skip to content

Commit 8bf4038

Browse files
committed
Add edge case
1 parent e6259a4 commit 8bf4038

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

tests/unit/Util/FileMatcherTest.php

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ public static function provideWildcard(): Generator
6969
'/path/foo/baz' => true,
7070
'/path/baz.php' => true,
7171
'/path/foo/baz/boo.php' => true,
72-
'/path/example/file.php' => false,
72+
'/path/example/file.php' => true,
7373
'/' => false,
74-
'' => false,
7574
],
7675
];
7776

@@ -81,9 +80,8 @@ public static function provideWildcard(): Generator
8180
'/path/foo/bar' => true,
8281
'/path/foo/baz' => true,
8382
'/path/foo/baz/boo.php' => true,
84-
'/path/example/file.php' => false,
83+
'/path/example/file.php' => true,
8584
'/' => false,
86-
'' => false,
8785
],
8886
];
8987
yield 'segment directory wildcard' => [
@@ -138,7 +136,7 @@ public static function provideGlobstar(): Generator
138136
[
139137
'/foo' => true,
140138
'/foo/bar' => true,
141-
'/' => false,
139+
'/' => true, // matches zero or more
142140
],
143141
];
144142

@@ -177,7 +175,11 @@ public static function provideGlobstar(): Generator
177175
],
178176
];
179177

180-
yield 'segment globstar with wildcard' => [
178+
// PHPUnit will match ALL directories within `/foo` with `/foo/A**`
179+
// however it will NOT match anything with `/foo/Aa**`
180+
//
181+
// This is likely a bug and so we could consider "fixing" it
182+
yield 'EDGE: segment globstar with wildcard' => [
181183
new FileMatcherPattern('/foo/emm/**/*ar'),
182184
[
183185
'/foo/emm/bar' => true,
@@ -512,7 +514,7 @@ public static function provideCharacterGroup(): Generator
512514
*/
513515
public static function provideRelativePathSegments(): Generator
514516
{
515-
yield 'equivalence class expressions' => [
517+
yield 'dot dot' => [
516518
new FileMatcherPattern('/a/../a/c'),
517519
[
518520
'/a/a/c' => true,
@@ -529,10 +531,15 @@ private static function assertMap(FileMatcherPattern $pattern, array $matchMap):
529531
foreach ($matchMap as $candidate => $shouldMatch) {
530532
$matches = FileMatcher::match($candidate, $pattern);
531533
if ($matches === $shouldMatch) {
532-
$this->addToAssertionCount(1);
534+
self::assertTrue(true);
533535
continue;
534536
}
535-
self::fail(sprintf('Expected the pattern "%s" to match path "%s"', $pattern->path, $candidate));
537+
self::fail(sprintf(
538+
'Expected the pattern "%s" %s match path "%s"',
539+
$pattern->path,
540+
$shouldMatch ? 'to' : 'to not',
541+
$candidate
542+
));
536543
}
537544
}
538545
}

0 commit comments

Comments
 (0)