/** * This test is primarily to ensure the correct match is chosen * when there are non-captured elements in the pattern. */ function testIndexSelectCorrectMatch() { $doc = "ALL FOOLS ARE FOO"; $pattern = '\\bFOO\\b'; $handler = $this->getMock('TestParserByteIndex'); $handler->expects($this->any())->method('ignore')->will($this->returnValue(true)); $matches = array(); preg_match('/' . $pattern . '/', $doc, $matches, PREG_OFFSET_CAPTURE); $handler->expects($this->once())->method('caught')->with("FOO", DOKU_LEXER_SPECIAL, $matches[0][1])->will($this->returnValue(true)); $lexer = new Doku_Lexer($handler, "ignore"); $lexer->addSpecialPattern($pattern, 'ignore', 'caught'); $this->assertTrue($lexer->parse($doc)); }
/** * This test is primarily to ensure the correct match is chosen * when there are non-captured elements in the pattern. */ function testIndexSelectCorrectMatch() { $doc = "ALL FOOLS ARE FOO"; $pattern = '\\bFOO\\b'; $handler = new MockTestParserByteIndex($this); $handler->setReturnValue("ignore", true); $handler->setReturnValue("caught", true); $matches = array(); preg_match('/' . $pattern . '/', $doc, $matches, PREG_OFFSET_CAPTURE); $handler->expectArgumentsAt(0, "caught", array("FOO", DOKU_LEXER_SPECIAL, $matches[0][1])); $handler->expectCallCount("caught", 1); $lexer = new Doku_Lexer($handler, "ignore"); $lexer->addSpecialPattern($pattern, 'ignore', 'caught'); $this->assertTrue($lexer->parse($doc)); $handler->tally(); }