diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/HTML5/Parser/EventStack.php | 4 | ||||
-rw-r--r-- | test/HTML5/Parser/TokenizerTest.php | 35 |
2 files changed, 38 insertions, 1 deletions
diff --git a/test/HTML5/Parser/EventStack.php b/test/HTML5/Parser/EventStack.php index 4d82629..478ae60 100644 --- a/test/HTML5/Parser/EventStack.php +++ b/test/HTML5/Parser/EventStack.php @@ -52,6 +52,10 @@ class EventStack implements EventHandler { $this->store('comment', array($cdata)); } + public function cdata($data) { + $this->store('cdata', func_get_args()); + } + public function text($cdata) { //fprintf(STDOUT, "Received TEXT event with: " . $cdata); $this->store('text', array($cdata)); diff --git a/test/HTML5/Parser/TokenizerTest.php b/test/HTML5/Parser/TokenizerTest.php index ead02d0..40259ea 100644 --- a/test/HTML5/Parser/TokenizerTest.php +++ b/test/HTML5/Parser/TokenizerTest.php @@ -90,10 +90,17 @@ class TokenizerTest extends \HTML5\Tests\TestCase { $bogus = array( '</+this is a bogus comment. +>', '<!+this is a bogus comment. !>', + '<!D OCTYPE foo bar>', '<!DOCTYEP foo bar>', + '<![CADATA[ TEST ]]>', + '<![CDATA Hello ]]>', + '<![CDATA[ Hello [[>', + '<!CDATA[[ test ]]>', + '<![CDATA[', + '<![CDATA[hellooooo hello', ); foreach ($bogus as $str) { - $events = $this->parse($str . ' '); + $events = $this->parse($str); $e0 = $events->get(0); $this->assertEquals('error', $e0['name']); $e1 = $events->get(1); @@ -182,6 +189,7 @@ class TokenizerTest extends \HTML5\Tests\TestCase { '<!-->' => '', '<!--Hello' => 'Hello', "<!--\0Hello" => UTF8Utils::FFFD . 'Hello', + '<!--' => '', ); foreach ($fail as $test => $expected) { $events = $this->parse($test); @@ -194,4 +202,29 @@ class TokenizerTest extends \HTML5\Tests\TestCase { } } + + public function testCDATASection() { + $good = array( + '<![CDATA[ This is a test. ]]>' => ' This is a test. ', + '<![CDATA[CDATA]]>' => 'CDATA', + '<![CDATA[ ]] > ]]>' => ' ]] > ', + '<![CDATA[ ]]>' => ' ', + ); + foreach ($good as $test => $expects) { + $events = $this->parse($test); + $e1 = $events->get(0); + $this->assertEquals('cdata', $e1['name'], "CDATA section for " . $test . print_r($events, TRUE)); + $this->assertEquals($expects, $e1['data'][0], "CDATA section for " . $test); + } + } + + public function testText() { + $good = array( + 'a<br>b', + '<a>test</a>', + 'a<![[ test ]]>b', + 'a&b', + ); + $this->markTestIncomplete("Need tag parsing first."); + } } |