summaryrefslogtreecommitdiff
path: root/test/HTML5/Parser
diff options
context:
space:
mode:
authorTechnosophos <[email protected]>2013-04-16 17:40:24 -0500
committerTechnosophos <[email protected]>2013-04-16 17:40:24 -0500
commit3761c75e004964cb2b75afedaddd9a3dd3dc426c (patch)
tree0767e1f735fa7b1c14da65ebdc08274975d12430 /test/HTML5/Parser
parent186ee9d481aded712459a4371619fcdbd33b443a (diff)
Working on simple tags.
Diffstat (limited to 'test/HTML5/Parser')
-rw-r--r--test/HTML5/Parser/TokenizerTest.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/HTML5/Parser/TokenizerTest.php b/test/HTML5/Parser/TokenizerTest.php
index c4c66e7..3065cbb 100644
--- a/test/HTML5/Parser/TokenizerTest.php
+++ b/test/HTML5/Parser/TokenizerTest.php
@@ -273,6 +273,50 @@ class TokenizerTest extends \HTML5\Tests\TestCase {
}
}
+ /**
+ * This tests just simple tags.
+ */
+ public function testSimpleTags() {
+ $open = array(
+ '<foo>' => 'foo',
+ '<foo >' => 'foo',
+ "<foo\n\n\n\n>" => 'foo',
+ '<foo:bar>' => 'foo:bar',
+ );
+ foreach ($open 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));
+ }
+ $selfClose= array(
+ '<foo/>' => 'foo',
+ '<foo />' => 'foo',
+ "<foo\n\n\n\n/>" => 'foo',
+ '<foo:bar/>' => 'foo:bar',
+ );
+ foreach ($selfClose as $test => $expects) {
+ $events = $this->parse($test);
+ $this->assertEquals(3, $events->depth(), "Counting events for '$test'" . print_r($events, TRUE));
+ $this->assertEventEquals('startTag', $expects, $events->get(0));
+ $this->assertEventEquals('endTag', $expects, $events->get(1));
+ }
+
+ $bad = array(
+ '<foo' => 'foo',
+ '<foo ' => 'foo',
+ '<foo/' => 'foo',
+ '<foo /' => 'foo',
+ );
+
+ foreach ($bad as $test => $expects) {
+ $events = $this->parse($test);
+ //fprintf(STDOUT, $test . PHP_EOL);
+ $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',