| 148 |
lars |
1 |
<?php
|
|
|
2 |
namespace Hamcrest\Text;
|
|
|
3 |
|
|
|
4 |
class MatchesPatternTest extends \Hamcrest\AbstractMatcherTest
|
|
|
5 |
{
|
|
|
6 |
|
|
|
7 |
protected function createMatcher()
|
|
|
8 |
{
|
|
|
9 |
return matchesPattern('/o+b/');
|
|
|
10 |
}
|
|
|
11 |
|
|
|
12 |
public function testEvaluatesToTrueIfArgumentmatchesPattern()
|
|
|
13 |
{
|
|
|
14 |
assertThat('foobar', matchesPattern('/o+b/'));
|
|
|
15 |
assertThat('foobar', matchesPattern('/^foo/'));
|
|
|
16 |
assertThat('foobar', matchesPattern('/ba*r$/'));
|
|
|
17 |
assertThat('foobar', matchesPattern('/^foobar$/'));
|
|
|
18 |
}
|
|
|
19 |
|
|
|
20 |
public function testEvaluatesToFalseIfArgumentDoesntMatchRegex()
|
|
|
21 |
{
|
|
|
22 |
assertThat('foobar', not(matchesPattern('/^foob$/')));
|
|
|
23 |
assertThat('foobar', not(matchesPattern('/oobe/')));
|
|
|
24 |
}
|
|
|
25 |
|
|
|
26 |
public function testHasAReadableDescription()
|
|
|
27 |
{
|
|
|
28 |
$this->assertDescription('a string matching "pattern"', matchesPattern('pattern'));
|
|
|
29 |
}
|
|
|
30 |
}
|