public function testMatch() { $regex = '#^foo.*bar$#u'; $this->compiler->expects($this->once())->method('compile')->with($this->patternValue)->will($this->returnValue($regex)); $this->assertTrue($this->pattern->match('foo-bar')); $this->assertFalse($this->pattern->match('-foo-bar')); $this->assertFalse($this->pattern->match('foo-bar-')); }
/** * Compile step. This utilises the internal Compiler instance to translate the pattern to a regular expression. * * @return string A regular expression constructed from the pattern held by this instance */ protected function compile() { $regex = $this->compiler->compile($this->pattern); return $regex; }