summaryrefslogtreecommitdiff
path: root/test/HTML5/Parser
diff options
context:
space:
mode:
authorTechnosophos <[email protected]>2013-04-18 11:11:56 -0500
committerTechnosophos <[email protected]>2013-04-18 11:11:56 -0500
commit16916cc975700e35c0aaced9f1c604f8acd78c96 (patch)
tree247de06bee81ef10137267111891fcde9c739e94 /test/HTML5/Parser
parenta2960d3c4d088440b75d317a14af4d8f7b2bf3a3 (diff)
Well-formed attribute values are working.
Diffstat (limited to 'test/HTML5/Parser')
-rw-r--r--test/HTML5/Parser/TokenizerTest.php58
1 files changed, 33 insertions, 25 deletions
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(
'&amp;' => '&',
@@ -322,22 +325,27 @@ class TokenizerTest extends \HTML5\Tests\TestCase {
$good = array(
'<foo bar="baz">' => array('foo', array('bar' => 'baz'), FALSE),
'<foo bar=" baz ">' => array('foo', array('bar' => ' baz '), FALSE),
- '<foo bar="baz"/>' => array('foo', array('bar' => 'baz'), TRUE),
- '<foo BAR="baz"/>' => array('foo', array('bar' => 'baz'), TRUE),
- '<foo BAR="BAZ"/>' => array('foo', array('bar' => 'BAZ'), TRUE),
"<foo bar='baz'>" => array('foo', array('bar' => 'baz'), FALSE),
'<foo bar="A full sentence.">' => array('foo', array('bar' => 'A full sentence.'), FALSE),
"<foo a='1' b=\"2\">" => array('foo', array('a' => '1', 'b' => '2'), FALSE),
"<foo ns:bar='baz'>" => array('foo', array('ns:bar' => 'baz'), FALSE),
- "<foo a='blue&red'>" => array('foo', array('a' => 'blue&red'), FALSE),
"<foo a='blue&amp;red'>" => array('foo', array('a' => 'blue&red'), FALSE),
"<foo\nbar='baz'\n>" => array('foo', array('bar' => 'baz'), FALSE),
'<doe a deer>' => array('doe', array('a' => NULL, 'deer' => NULL), FALSE),
);
$this->isAllGood('startTag', 2, $good);
+ $withEnd = array(
+ '<foo bar="baz"/>' => array('foo', array('bar' => 'baz'), TRUE),
+ '<foo BAR="baz"/>' => array('foo', array('bar' => 'baz'), TRUE),
+ '<foo BAR="BAZ"/>' => array('foo', array('bar' => 'BAZ'), TRUE),
+ );
+ $this->isAllGood('startTag', 3, $withEnd);
+
/*
$bad = array(
+ // This will emit an entity lookup failure for &red.
+ "<foo a='blue&red'>" => array('foo', array('a' => 'blue&red'), FALSE),
'<foo b"="baz">' => array('foo', array('b"' => 'baz'), FALSE),
'<foo ="bar">' => array('foo', array('="bar"' => NULL), FALSE),
'<foo bar=/>' => array('foo', array('bar' => NULL), TRUE),