summaryrefslogtreecommitdiff
path: root/test/HTML5/Parser
diff options
context:
space:
mode:
authorAsmir Mustafic <[email protected]>2014-05-12 08:44:29 +0200
committerAsmir Mustafic <[email protected]>2014-05-12 08:44:29 +0200
commitee034afa09131fa0352e3133febc84e67e57be63 (patch)
tree8ea2f217cadb7a7caa32b7483894ca76c5c2d96b /test/HTML5/Parser
parentfbc3c7e214a4bbbc9e88eb574414a91a0faa2176 (diff)
PRS-4 tests
Diffstat (limited to 'test/HTML5/Parser')
-rw-r--r--test/HTML5/Parser/CharacterReferenceTest.php5
-rw-r--r--test/HTML5/Parser/DOMTreeBuilderTest.php16
-rw-r--r--test/HTML5/Parser/EventStack.php3
-rw-r--r--test/HTML5/Parser/FileInputStreamTest.php6
-rw-r--r--test/HTML5/Parser/ScannerTest.php2
-rw-r--r--test/HTML5/Parser/StringInputStreamTest.php16
-rw-r--r--test/HTML5/Parser/TokenizerTest.php20
-rw-r--r--test/HTML5/Parser/TreeBuildingRulesTest.php9
8 files changed, 39 insertions, 38 deletions
diff --git a/test/HTML5/Parser/CharacterReferenceTest.php b/test/HTML5/Parser/CharacterReferenceTest.php
index b530f1c..c568d03 100644
--- a/test/HTML5/Parser/CharacterReferenceTest.php
+++ b/test/HTML5/Parser/CharacterReferenceTest.php
@@ -3,10 +3,9 @@
* @file
* Test the Scanner. This requires the InputStream tests are all good.
*/
-namespace HTML5\Parser;
-
-require_once __DIR__ . '/../TestCase.php';
+namespace HTML5\Tests\Parser;
+use HTML5\Parser\CharacterReference;
class CharacterReferenceTest extends \HTML5\Tests\TestCase {
public function testLookupName() {
$this->assertEquals('&', CharacterReference::lookupName('amp'));
diff --git a/test/HTML5/Parser/DOMTreeBuilderTest.php b/test/HTML5/Parser/DOMTreeBuilderTest.php
index 6eeafe8..55ff6b1 100644
--- a/test/HTML5/Parser/DOMTreeBuilderTest.php
+++ b/test/HTML5/Parser/DOMTreeBuilderTest.php
@@ -3,11 +3,13 @@
* @file
* Test the Tree Builder.
*/
-namespace HTML5\Parser;
+namespace HTML5\Tests\Parser;
use HTML5\Elements;
-
-require_once __DIR__ . '/../TestCase.php';
+use HTML5\Parser\StringInputStream;
+use HTML5\Parser\Scanner;
+use HTML5\Parser\Tokenizer;
+use HTML5\Parser\DOMTreeBuilder;
/**
* These tests are functional, not necessarily unit tests.
@@ -108,7 +110,7 @@ class DOMTreeBuilderTest extends \HTML5\Tests\TestCase {
<svg width='150' viewbox='2'>
<rect textlength='2'/>
<animatecolor>foo</animatecolor>
- </svg>
+ </svg>
</body></html>";
$doc = $this->parse($html);
$root = $doc->documentElement;
@@ -208,7 +210,7 @@ class DOMTreeBuilderTest extends \HTML5\Tests\TestCase {
$html = "<!DOCTYPE html><html><math><![CDATA[test";
$doc = $this->parse($html);
- // We're JUST testing that we can access errors. Actual testing of
+ // We're JUST testing that we can access errors. Actual testing of
// error messages happen in the Tokenizer's tests.
$this->assertGreaterThan(0, count($doc->errors));
$this->assertTrue(is_string($doc->errors[0]));
@@ -344,9 +346,7 @@ class DOMTreeBuilderTest extends \HTML5\Tests\TestCase {
$this->assertEquals('div', $div->tagName);
$this->assertEquals('foo', $div->textContent);
}
-}
-
-class InstructionProcessorMock implements \HTML5\InstructionProcessor {
+}class InstructionProcessorMock implements \HTML5\InstructionProcessor {
public $name = NULL;
public $data = NULL;
diff --git a/test/HTML5/Parser/EventStack.php b/test/HTML5/Parser/EventStack.php
index 1f56ea9..ffa4f12 100644
--- a/test/HTML5/Parser/EventStack.php
+++ b/test/HTML5/Parser/EventStack.php
@@ -1,7 +1,8 @@
<?php
-namespace HTML5\Parser;
+namespace HTML5\Tests\Parser;
use HTML5\Elements;
+use HTML5\Parser\EventHandler;
/**
* This testing class gathers events from a parser and builds a stack of events.
diff --git a/test/HTML5/Parser/FileInputStreamTest.php b/test/HTML5/Parser/FileInputStreamTest.php
index 2ee2440..80078ff 100644
--- a/test/HTML5/Parser/FileInputStreamTest.php
+++ b/test/HTML5/Parser/FileInputStreamTest.php
@@ -1,10 +1,8 @@
<?php
-namespace HTML5\Tests;
+namespace HTML5\Tests\Parser;
use \HTML5\Parser\FileInputStream;
-require_once __DIR__ . '/../TestCase.php';
-
class FileInputStreamTest extends \HTML5\Tests\TestCase {
function testConstruct() {
@@ -61,7 +59,7 @@ class FileInputStreamTest extends \HTML5\Tests\TestCase {
$this->assertEquals(2, $s->columnOffset());
$s->next();
$this->assertEquals(3, $s->columnOffset());
-
+
// Make sure we get to the second line
$s->next(); $s->next(); $s->next(); $s->next();
$s->next(); $s->next(); $s->next(); $s->next();
diff --git a/test/HTML5/Parser/ScannerTest.php b/test/HTML5/Parser/ScannerTest.php
index 1c9b009..e5077d8 100644
--- a/test/HTML5/Parser/ScannerTest.php
+++ b/test/HTML5/Parser/ScannerTest.php
@@ -8,8 +8,6 @@ namespace HTML5\Tests\Parser;
use \HTML5\Parser\StringInputStream;
use \HTML5\Parser\Scanner;
-require_once __DIR__ . '/../TestCase.php';
-
class ScannerTest extends \HTML5\Tests\TestCase {
/**
diff --git a/test/HTML5/Parser/StringInputStreamTest.php b/test/HTML5/Parser/StringInputStreamTest.php
index 46c70c4..8d46bf2 100644
--- a/test/HTML5/Parser/StringInputStreamTest.php
+++ b/test/HTML5/Parser/StringInputStreamTest.php
@@ -1,10 +1,8 @@
<?php
-namespace HTML5\Tests;
+namespace HTML5\Tests\Parser;
use \HTML5\Parser\StringInputStream;
-require_once __DIR__ . '/../TestCase.php';
-
class StringInputStreamTest extends \HTML5\Tests\TestCase {
/**
@@ -218,7 +216,7 @@ class StringInputStreamTest extends \HTML5\Tests\TestCase {
}
// MPB:
- // It appears that iconv just leaves these alone. Not sure what to
+ // It appears that iconv just leaves these alone. Not sure what to
// do.
/*
$converted = array(
@@ -263,19 +261,19 @@ class StringInputStreamTest extends \HTML5\Tests\TestCase {
$this->invalidParseErrorTestHandler("\x1D", 1, 'U+001D (C0 control)');
$this->invalidParseErrorTestHandler("\x1E", 1, 'U+001E (C0 control)');
$this->invalidParseErrorTestHandler("\x1F", 1, 'U+001F (C0 control)');
-
+
// DEL (U+007F)
$this->invalidParseErrorTestHandler("\x7F", 1, 'U+007F');
-
+
// C1 Controls
$this->invalidParseErrorTestHandler("\xC2\x80", 1, 'U+0080 (C1 control)');
$this->invalidParseErrorTestHandler("\xC2\x9F", 1, 'U+009F (C1 control)');
$this->invalidParseErrorTestHandler("\xC2\xA0", 0, 'U+00A0 (first codepoint above highest C1 control)');
-
+
// Charcters surrounding surrogates
$this->invalidParseErrorTestHandler("\xED\x9F\xBF", 0, 'U+D7FF (one codepoint below lowest surrogate codepoint)');
$this->invalidParseErrorTestHandler("\xEF\xBF\xBD", 0, 'U+DE00 (one codepoint above highest surrogate codepoint)');
-
+
// Permanent noncharacters
$this->invalidParseErrorTestHandler("\xEF\xB7\x90", 1, 'U+FDD0 (permanent noncharacter)');
$this->invalidParseErrorTestHandler("\xEF\xB7\xAF", 1, 'U+FDEF (permanent noncharacter)');
@@ -325,7 +323,7 @@ class StringInputStreamTest extends \HTML5\Tests\TestCase {
$this->invalidParseErrorTestHandler("\xED\xB0\x80", 1, 'U+DC00 (UTF-16 surrogate character)');
$this->invalidParseErrorTestHandler("\xED\xBE\x80", 1, 'U+DF80 (UTF-16 surrogate character)');
$this->invalidParseErrorTestHandler("\xED\xBF\xBF", 1, 'U+DFFF (UTF-16 surrogate character)');
-
+
// Paired UTF-16 surrogates
$this->invalidParseErrorTestHandler("\xED\xA0\x80\xED\xB0\x80", 2, 'U+D800 U+DC00 (paired UTF-16 surrogates)');
$this->invalidParseErrorTestHandler("\xED\xA0\x80\xED\xBF\xBF", 2, 'U+D800 U+DFFF (paired UTF-16 surrogates)');
diff --git a/test/HTML5/Parser/TokenizerTest.php b/test/HTML5/Parser/TokenizerTest.php
index edc427c..f7f1228 100644
--- a/test/HTML5/Parser/TokenizerTest.php
+++ b/test/HTML5/Parser/TokenizerTest.php
@@ -1,9 +1,11 @@
<?php
-namespace HTML5\Parser;
-require_once __DIR__ . '/../TestCase.php';
-require 'EventStack.php';
+namespace HTML5\Tests\Parser;
-class TokenizerTest extends \HTML5\Tests\TestCase {
+use HTML5\Parser\UTF8Utils;
+use HTML5\Parser\StringInputStream;
+use HTML5\Parser\Scanner;
+use HTML5\Parser\Tokenizer;
+require 'EventStack.php';class TokenizerTest extends \HTML5\Tests\TestCase {
// ================================================================
// Additional assertions.
// ================================================================
@@ -109,7 +111,7 @@ class TokenizerTest extends \HTML5\Tests\TestCase {
$e1 = $events->get(0);
$this->assertEquals('error', $e1['name']);
- // FIXME: Once the text processor is done, need to verify that the
+ // FIXME: Once the text processor is done, need to verify that the
// tokens are transformed correctly into text.
}
@@ -139,12 +141,12 @@ class TokenizerTest extends \HTML5\Tests\TestCase {
$succeed = array(
'</a>' => 'a',
'</test>' => 'test',
- '</test
+ '</test
>' => 'test',
'</thisIsTheTagThatDoesntEndItJustGoesOnAndOnMyFriend>' =>
'thisIsTheTagThatDoesntEndItJustGoesOnAndOnMyFriend',
// See 8.2.4.10, which requires this and does not say error.
- '</a<b>' => 'a<b',
+ '</a<b>' => 'a<b',
);
$this->isAllGood('endTag', 2, $succeed);
@@ -271,8 +273,8 @@ class TokenizerTest extends \HTML5\Tests\TestCase {
public function testProcessorInstruction() {
$good = array(
'<?hph ?>' => 'hph',
- '<?hph echo "Hello World"; ?>' => array('hph', 'echo "Hello World"; '),
- "<?hph \necho 'Hello World';\n?>" => array('hph', "echo 'Hello World';\n"),
+ '<?hph echo "Hello World"; ?>' => array('hph', 'echo "Hello World"; '),
+ "<?hph \necho 'Hello World';\n?>" => array('hph', "echo 'Hello World';\n"),
);
$this->isAllGood('pi', 2, $good);
}
diff --git a/test/HTML5/Parser/TreeBuildingRulesTest.php b/test/HTML5/Parser/TreeBuildingRulesTest.php
index a247cea..b285073 100644
--- a/test/HTML5/Parser/TreeBuildingRulesTest.php
+++ b/test/HTML5/Parser/TreeBuildingRulesTest.php
@@ -3,11 +3,16 @@
* @file
* Test the Tree Builder's special-case rules.
*/
-namespace HTML5\Parser;
+namespace HTML5\Tests\Parser;
use HTML5\Elements;
+use HTML5\Parser\TreeBuildingRules;
+use HTML5\Parser\Tokenizer;
+use HTML5\Parser\Scanner;
+use HTML5\Parser\StringInputStream;
+use HTML5\Parser\DOMTreeBuilder;
+
-require_once __DIR__ . '/../TestCase.php';
/**
* These tests are functional, not necessarily unit tests.