MatchesPatternTest.php 859 B

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