Exemplo n.º 1
0
 function testIndexLookbehindNotEqual()
 {
     $doc = "aaa<file>bcd</file>eee";
     $handler = $this->getMock('TestParserByteIndex');
     $handler->expects($this->any())->method('ignore')->will($this->returnValue(true));
     $handler->expects($this->at(1))->method('caught')->with("<file>", DOKU_LEXER_ENTER, strpos($doc, '<file>'))->will($this->returnValue(true));
     $handler->expects($this->at(2))->method('caught')->with("b", DOKU_LEXER_SPECIAL, strpos($doc, 'b'))->will($this->returnValue(true));
     $handler->expects($this->at(3))->method('caught')->with("c", DOKU_LEXER_MATCHED, strpos($doc, 'c'))->will($this->returnValue(true));
     $handler->expects($this->at(4))->method('caught')->with("d", DOKU_LEXER_UNMATCHED, strpos($doc, 'd'))->will($this->returnValue(true));
     $handler->expects($this->at(5))->method('caught')->with("</file>", DOKU_LEXER_EXIT, strpos($doc, '</file>'))->will($this->returnValue(true));
     $lexer = new Doku_Lexer($handler, 'ignore');
     $lexer->addEntryPattern('<file>', 'ignore', 'caught');
     $lexer->addExitPattern('(?<!c)</file>', 'caught');
     $lexer->addSpecialPattern('b', 'caught', 'special');
     $lexer->mapHandler('special', 'caught');
     $lexer->addPattern('c', 'caught');
     $this->assertTrue($lexer->parse($doc));
 }
Exemplo n.º 2
0
 function testIndexLookbehindNotEqual()
 {
     $doc = "aaa<file>bcd</file>eee";
     $handler = new MockTestParserByteIndex($this);
     $handler->setReturnValue("ignore", true);
     $handler->setReturnValue("caught", true);
     $handler->expectArgumentsAt(0, "caught", array("<file>", DOKU_LEXER_ENTER, strpos($doc, '<file>')));
     $handler->expectArgumentsAt(1, "caught", array("b", DOKU_LEXER_SPECIAL, strpos($doc, 'b')));
     $handler->expectArgumentsAt(2, "caught", array("c", DOKU_LEXER_MATCHED, strpos($doc, 'c')));
     $handler->expectArgumentsAt(3, "caught", array("d", DOKU_LEXER_UNMATCHED, strpos($doc, 'd')));
     $handler->expectArgumentsAt(4, "caught", array("</file>", DOKU_LEXER_EXIT, strpos($doc, '</file>')));
     $handler->expectCallCount("caught", 5);
     $lexer = new Doku_Lexer($handler, "ignore");
     $lexer->addEntryPattern('<file>', "ignore", "caught");
     $lexer->addExitPattern("(?<!c)</file>", "caught");
     $lexer->addSpecialPattern('b', 'caught', 'special');
     $lexer->mapHandler('special', 'caught');
     $lexer->addPattern('c', 'caught');
     $this->assertTrue($lexer->parse($doc));
     $handler->tally();
 }