@@ -15,10 +15,32 @@ public function test_it_works_for_simple_strings(): void
15
15
$ this ->assertFalse ($ pattern ->matches ('Something else ' ));
16
16
}
17
17
18
- public function test_wildcard_is_for_alphanumeric (): void
18
+ /**
19
+ * @dataProvider providePatterns
20
+ */
21
+ public function test_wildcard_is_for_alphanumeric (string $ string , string $ pattern , bool $ expectedResult ): void
19
22
{
20
- $ pattern = new PatternString ('SoThisIsAnExample ' );
21
- $ this ->assertTrue ($ pattern ->matches ('*This* ' ));
22
- $ this ->assertFalse ($ pattern ->matches ('This* ' ));
23
+ $ this ->assertEquals ($ expectedResult , (new PatternString ($ string ))->matches ($ pattern ));
24
+ }
25
+
26
+ public function providePatterns (): array
27
+ {
28
+ return [
29
+ ['SoThisIsAnExample ' , '*This* ' , true ],
30
+ ['SoThisIsAnExample ' , 'This* ' , false ],
31
+ ['SoThisIsAnExample ' , '*This ' , false ],
32
+ ['SoThisIsAnExample ' , 'SoThisIsAnExample ' , true ],
33
+ ['SoThisIsAnExample ' , 'So????????Example ' , true ],
34
+ ['SoThisIsAnExample ' , '*SoThisIsAnExample ' , true ],
35
+ ['SoThisIsAnExample ' , 'SoThisIsAnExample* ' , true ],
36
+ ['SoThisIsAnExample ' , 'So*Example ' , true ],
37
+ ['SoThisIsAnExample ' , '*ThisIsAnExample ' , true ],
38
+ ['SoThisIsAnExample ' , 'SoThisIsAn* ' , true ],
39
+ ['Food\Vegetables\Roots\Carrot ' , 'Food\*\Roots ' , false ],
40
+ ['Food\Vegetables\Roots\Orange\Carrot ' , 'Food\*\Roots ' , false ],
41
+ ['Food\Vegetables\Carrot ' , '*\Vegetables ' , false ],
42
+ ['Food\Vegetables\Roots\Carrot ' , '*\Vegetables ' , false ],
43
+ ['Food\Vegetables\Roots\Orange\Carrot ' , '*\Vegetables ' , false ],
44
+ ];
23
45
}
24
46
}
0 commit comments