public function testCompile() { $expected = '#foo.*bar#u'; $patternValue = 'foo*bar'; $patternTokens = [[Tokenizer::T_WORD, 1, 'foo'], [Tokenizer::T_WILDCARD_MULTI, 1, '*'], [Tokenizer::T_WORD, 1, 'bar']]; $this->tokenizer->expects($this->once())->method('parse')->with($patternValue)->will($this->returnValue($patternTokens)); $this->builder->expects($this->once())->method('createFromTokens')->with($patternTokens)->will($this->returnValue($expected)); $result = $this->compiler->compile($patternValue); $this->assertEquals($expected, $result); }
/** * @param string $pattern * @return string */ public function compile($pattern) { $tokens = $this->tokenizer->parse($pattern); $regex = $this->builder->createFromTokens($tokens); return $regex; }