Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Coduo/PHPMatcher/Matcher/TextMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ public function canMatch($pattern)
return false;
}

if (mb_strlen($pattern) !== 6 && false !== mb_strpos($pattern, '@null@')) {
return false;
}

return true;
}

Expand Down
14 changes: 14 additions & 0 deletions tests/Coduo/PHPMatcher/Matcher/TextMatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
Empty file added text-matcher-bug.php
Empty file.