createMock(ParseError::class);
$errorHandler->method("emit")->willReturn(true);
// initialize a stack of open elements, possibly with an open element
$stack = new OpenElementsStack();
if ($open) {
$stack[] = (new \DOMDocument)->createElement($open);
}
// initialize the data stream and tokenizer
$data = new Data($input, "STDIN", $errorHandler);
$tokenizer = new Tokenizer($data, $stack, $errorHandler);
$tokenizer->state = $state;
// perform the test
$actual = [];
do {
$t = $tokenizer->createToken();
$actual[] = $t;
} while (!($t instanceof EOFToken));
array_pop($actual);
$actual = $this->combineCharacterTokens($actual);
$this->assertEquals($expected, $actual);
}
public function provideStandardTokenizerTests() {
$tests = [];
$blacklist = ["pendingSpecChanges.test", "xmlViolation.test"];
foreach (new \GlobIterator(\dW\HTML5\BASE."tests/html5lib-tests/tokenizer/test*.test", \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::CURRENT_AS_PATHNAME) as $file) {
if (!in_array(basename($file), $blacklist)) {
$tests[] = $file;
}
}
return $this->makeTokenTests(...$tests);
}
}