summaryrefslogtreecommitdiff
path: root/test/HTML5/Parser
diff options
context:
space:
mode:
authorTechnosophos <[email protected]>2013-04-17 15:50:36 -0500
committerTechnosophos <[email protected]>2013-04-17 15:50:36 -0500
commit1a043159edbbf89c2963282dbc77423ca03b1f93 (patch)
tree6b028775e6f41a2e6b0a5fd72197178435e8f142 /test/HTML5/Parser
parent080a5b3105ba574d99215874eb26620c5f8e1907 (diff)
Updated Tokenizer tests with new tag tests.
Diffstat (limited to 'test/HTML5/Parser')
-rw-r--r--test/HTML5/Parser/TokenizerTest.php38
1 files changed, 38 insertions, 0 deletions
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(
+ '<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 bar = "baz" >' => array('foo', array('bar' => 'baz'), FALSE),
+ "<foo\nbar='baz'\n>" => 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(
+ '<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),
+ '<foo bar=>' => array('foo', array('bar' => NULL), FALSE),
+ '<foo bar=baz>' => 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<br>b',