From 1a043159edbbf89c2963282dbc77423ca03b1f93 Mon Sep 17 00:00:00 2001 From: Technosophos Date: Wed, 17 Apr 2013 15:50:36 -0500 Subject: Updated Tokenizer tests with new tag tests. --- test/HTML5/Parser/TokenizerTest.php | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'test') diff --git a/test/HTML5/Parser/TokenizerTest.php b/test/HTML5/Parser/TokenizerTest.php index d988df1..d60681a 100644 --- a/test/HTML5/Parser/TokenizerTest.php +++ b/test/HTML5/Parser/TokenizerTest.php @@ -319,6 +319,44 @@ class TokenizerTest extends \HTML5\Tests\TestCase { } } + public function testTagAttributes() { + $good = array( + '' => array('foo', array('bar' => 'baz'), FALSE), + '' => array('foo', array('bar' => ' baz '), FALSE), + '' => array('foo', array('bar' => 'baz'), TRUE), + '' => array('foo', array('bar' => 'baz'), TRUE), + '' => array('foo', array('bar' => 'BAZ'), TRUE), + "" => array('foo', array('bar' => 'baz'), FALSE), + '' => array('foo', array('bar' => 'A full sentence.'), FALSE), + "" => array('foo', array('a' => '1', 'b' => '2'), FALSE), + "" => array('foo', array('ns:bar' => 'baz'), FALSE), + "" => array('foo', array('a' => 'blue&red'), FALSE), + "" => array('foo', array('a' => 'blue&red'), FALSE), + '' => array('foo', array('bar' => 'baz'), FALSE), + "" => array('foo', array('bar' => 'baz'), FALSE), + ); + foreach ($good as $test => $expects) { + $events = $this->parse($test); + $this->assertEquals(2, $events->depth(), "Counting events for '$test'" . print_r($events, TRUE)); + $this->assertEventEquals('startTag', $expects, $events->get(0)); + } + + $bad = array( + '' => array('foo', array('b"' => 'baz'), FALSE), + '' => array('foo', array('="bar"' => NULL), FALSE), + '' => array('foo', array('bar' => NULL), TRUE), + '' => array('foo', array('bar' => NULL), FALSE), + '' => array('foo', array('bar' => 'baz'), FALSE), + + ); + foreach ($bad as $test => $expects) { + $events = $this->parse($test); + $this->assertEquals(3, $events->depth(), "Counting events for '$test': " . print_r($events, TRUE)); + $this->assertEventError($events->get(0)); + $this->assertEventEquals('startTag', $expects, $events->get(1)); + } + } + public function testText() { $good = array( 'a
b', -- cgit v1.2.3