예제 #1
0
 /**
  * All pattern expressions are converted to tokens using a genuine (i.e. non-mocked) Lexer instance.
  *
  * @dataProvider patternTokenProvider
  */
 public function testParse($pattern, $expected)
 {
     $factory = new UsingCompiledRegex(new LexerDataGenerator());
     $tokenizer = new Glob($factory);
     $tokens = $tokenizer->parse($pattern);
     $this->assertEquals($expected, $tokens);
 }
예제 #2
0
 public function testParseWithRemainingPushedStates()
 {
     $this->setExpectedException(TokenizeException::CLASS, 'Premature end of pattern');
     $pattern = '[';
     $lexer = $this->getMock(StatefulLexer::CLASS);
     $lexer->expects($this->once())->method('lex')->will($this->returnValue([]));
     $lexer->expects($this->once())->method('hasPushedStates')->will($this->returnValue(true));
     $this->lexerFactory->expects($this->once())->method('createLexer')->will($this->returnValue($lexer));
     $this->tokenizer->parse($pattern);
 }