diff --git a/src/Coduo/PHPMatcher/Matcher/TextMatcher.php b/src/Coduo/PHPMatcher/Matcher/TextMatcher.php index 4a5d0de6..431941b1 100644 --- a/src/Coduo/PHPMatcher/Matcher/TextMatcher.php +++ b/src/Coduo/PHPMatcher/Matcher/TextMatcher.php @@ -79,6 +79,10 @@ public function canMatch($pattern) return false; } + if (mb_strlen($pattern) !== 6 && false !== mb_strpos($pattern, '@null@')) { + return false; + } + return true; } diff --git a/tests/Coduo/PHPMatcher/Matcher/TextMatcherTest.php b/tests/Coduo/PHPMatcher/Matcher/TextMatcherTest.php index 79f2800f..343ed336 100644 --- a/tests/Coduo/PHPMatcher/Matcher/TextMatcherTest.php +++ b/tests/Coduo/PHPMatcher/Matcher/TextMatcherTest.php @@ -37,6 +37,20 @@ public function setUp() ); } + public function test_can_match_general_strings() + { + $this->assertTrue($this->matcher->canMatch('')); + $this->assertTrue($this->matcher->canMatch('String with text')); + $this->assertTrue($this->matcher->canMatch('String with text, @number@ and @*@')); + } + + public function test_cannot_match_null_as_part_of_pattern() + { + $this->assertFalse($this->matcher->canMatch("Using @null@ inside other text")); + $this->assertFalse($this->matcher->canMatch("@null@ at start of pattern")); + $this->assertFalse($this->matcher->canMatch("pattern ends with @null@")); + } + /** * @dataProvider matchingData */ diff --git a/text-matcher-bug.php b/text-matcher-bug.php new file mode 100644 index 00000000..e69de29b