From 16916cc975700e35c0aaced9f1c604f8acd78c96 Mon Sep 17 00:00:00 2001 From: Technosophos Date: Thu, 18 Apr 2013 11:11:56 -0500 Subject: Well-formed attribute values are working. --- test/HTML5/Parser/TokenizerTest.php | 58 +++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 25 deletions(-) (limited to 'test/HTML5/Parser') diff --git a/test/HTML5/Parser/TokenizerTest.php b/test/HTML5/Parser/TokenizerTest.php index b70ca53..d525e56 100644 --- a/test/HTML5/Parser/TokenizerTest.php +++ b/test/HTML5/Parser/TokenizerTest.php @@ -32,6 +32,30 @@ class TokenizerTest extends \HTML5\Tests\TestCase { $this->assertEquals('error', $event['name'], "Expected error for event: " . print_r($event, TRUE)); } + /** + * Asserts that all of the tests are good. + * + * This loops through a map of tests/expectations and runs a few assertions on each test. + * + * Checks: + * - depth (if depth is > 0) + * - event name + * - matches on event 0. + */ + protected function isAllGood($name, $depth, $tests, $debug = FALSE) { + foreach ($tests as $try => $expects) { + if ($debug) { + fprintf(STDOUT, "%s expects %s\n", $try, print_r($expects, TRUE)); + } + $e = $this->parse($try); + if ($depth > 0) { + $this->assertEquals($depth, $e->depth(), "Expected depth $depth for test $try." . print_r($e, TRUE)); + } + $this->assertEventEquals($name, $expects, $e->get(0)); + } + } + + // ================================================================ // Utility functions. // ================================================================ @@ -60,27 +84,6 @@ class TokenizerTest extends \HTML5\Tests\TestCase { $this->assertEquals($spaces, $e1['data'][0]); } - /** - * Asserts that all of the tests are good. - * - * Checks: - * - depth (if depth is > 0) - * - event name - * - matches on event 0. - */ - protected function isAllGood($name, $depth, $tests, $debug = FALSE) { - foreach ($tests as $try => $expects) { - if ($debug) { - fprintf(STDOUT, "%s expects %s\n", $try, print_r($expects, TRUE)); - } - $e = $this->parse($try); - if ($depth > 0) { - $this->assertEquals($depth, $e->depth(), "Expected depth $depth for test $try." . print_r($e, TRUE)); - } - $this->assertEventEquals($name, $expects, $e->get(0)); - } - } - public function testCharacterReference() { $good = array( '&' => '&', @@ -322,22 +325,27 @@ class TokenizerTest extends \HTML5\Tests\TestCase { $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('doe', array('a' => NULL, 'deer' => NULL), FALSE), ); $this->isAllGood('startTag', 2, $good); + $withEnd = array( + '' => array('foo', array('bar' => 'baz'), TRUE), + '' => array('foo', array('bar' => 'baz'), TRUE), + '' => array('foo', array('bar' => 'BAZ'), TRUE), + ); + $this->isAllGood('startTag', 3, $withEnd); + /* $bad = array( + // This will emit an entity lookup failure for &red. + "" => array('foo', array('a' => 'blue&red'), FALSE), '' => array('foo', array('b"' => 'baz'), FALSE), '' => array('foo', array('="bar"' => NULL), FALSE), '' => array('foo', array('bar' => NULL), TRUE), -- cgit v1.2.3