Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
 /**
  * Tests Globby::compile() with genuine (non-mocked) Tokenizer and Builder instances
  */
 public function testCompile()
 {
     $factory = new UsingCompiledRegex(new LexerDataGenerator());
     $tokenizer = new Glob($factory);
     $builder = new Regex();
     $compiler = new Globby($tokenizer, $builder);
     $pattern = 'foo*bar.ba[zr]?[!1[:alpha:]4-59][^x]';
     $expected = '#^foo.*bar\\.ba[zr].[^1[:alpha:]4-59][^x]$#u';
     $result = $compiler->compile($pattern);
     $this->assertEquals($expected, $result);
 }