File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,6 +27,6 @@ final class ByRegexTaskName implements iTaskMatcher {
2727 public function __construct (public string $ regex ) {}
2828
2929 public function matches (Task $ task ) : bool {
30- return preg_match ($ this ->regex , $ task ->getName ()) === 1 ;
30+ return $ this -> regex !== '' && preg_match ($ this ->regex , $ task ->getName ()) === 1 ;
3131 }
32- }
32+ }
Original file line number Diff line number Diff line change @@ -49,6 +49,15 @@ public function testMatches() : void {
4949 self ::assertFalse ($ this ->sut ->matches ($ task4 ));
5050 }
5151
52+ public function testMatches_canReturnFalse_whenRegexIsEmpty () : void {
53+ $ this ->sut ->regex = '' ;
54+
55+ $ task1 = $ this ->createMock (Task::class);
56+ $ task1 ->expects (self ::never ())->method ('getName ' );
57+
58+ self ::assertFalse ($ this ->sut ->matches ($ task1 ));
59+ }
60+
5261 public function test__construct () : void {
5362 $ regex = 'some regex ' ;
5463
You can’t perform that action at this time.
0 commit comments