Exemplo n.º 1
0
 public function invoke($test)
 {
     // this is totally the wrong interface to use, but
     // for now we need testing
     $tokenizer = new Tokenizer($test['data']);
     $GLOBALS['TIME'] -= get_microtime();
     if (isset($test['document-fragment'])) {
         $tokenizer->parseFragment($test['document-fragment']);
     } else {
         $tokenizer->parse();
     }
     $GLOBALS['TIME'] += get_microtime();
     $this->assertIdentical($test['document'], TestData::strDom($tokenizer->save()), $test);
 }
Exemplo n.º 2
0
    function testStrDom()
    {
        $dom = new DOMDocument();
        $dom->loadHTML('<!DOCTYPE html PUBLIC "http://foo" "http://bar"><html><body foo="bar" baz="1">foo<b>bar</b>asdf</body></html>');
        $this->assertIdentical(TestData::strDom($dom), <<<RESULT
| <!DOCTYPE html "http://foo" "http://bar">
| <html>
|   <body>
|     baz="1"
|     foo="bar"
|     "foo"
|     <b>
|       "bar"
|     "asdf"
RESULT
);
    }
Exemplo n.º 3
0
                echo $this->tokenDump($expect);
                echo "\nActual: \n";
                echo $this->tokenDump($result);
                echo "\n";
            }
        }
    }
    private function tokenDump($tokens)
    {
        $ret = '';
        foreach ($tokens as $i => $token) {
            $ret .= $i + 1 . ". {$token[0]}: {$token[1]}\n";
        }
        return $ret;
    }
    public function tokenize($test, $flag)
    {
        $flag = constant("HTML5Lib\\Tokenizer::{$flag}");
        if (!isset($test->lastStartTag)) {
            $test->lastStartTag = null;
        }
        $tokenizer = new TestableTokenizer($test->input, $flag, $test->lastStartTag);
        $GLOBALS['TIME'] -= get_microtime();
        $tokenizer->parse();
        $GLOBALS['TIME'] += get_microtime();
        return $tokenizer->outputTokens;
    }
}
// generate test suites for tokenizer
TestData::generateTestCases('HTML5Lib\\Tests\\TokenizerHarness', 'HTML5Lib\\Tests\\TokenizerTestOf', 'tokenizer', '*.test');