diff options
-rw-r--r-- | composer.json | 69 | ||||
-rw-r--r-- | phpunit.xml.dist | 2 | ||||
-rw-r--r-- | test/HTML5/ElementsTest.php | 2 | ||||
-rw-r--r-- | test/HTML5/Html5Test.php | 2 | ||||
-rw-r--r-- | test/HTML5/Parser/CharacterReferenceTest.php | 5 | ||||
-rw-r--r-- | test/HTML5/Parser/DOMTreeBuilderTest.php | 16 | ||||
-rw-r--r-- | test/HTML5/Parser/EventStack.php | 3 | ||||
-rw-r--r-- | test/HTML5/Parser/FileInputStreamTest.php | 6 | ||||
-rw-r--r-- | test/HTML5/Parser/ScannerTest.php | 2 | ||||
-rw-r--r-- | test/HTML5/Parser/StringInputStreamTest.php | 16 | ||||
-rw-r--r-- | test/HTML5/Parser/TokenizerTest.php | 20 | ||||
-rw-r--r-- | test/HTML5/Parser/TreeBuildingRulesTest.php | 9 | ||||
-rw-r--r-- | test/HTML5/Serializer/OutputRulesTest.php | 6 | ||||
-rw-r--r-- | test/HTML5/Serializer/TraverserTest.php | 6 | ||||
-rw-r--r-- | test/HTML5/TestCase.php | 3 |
15 files changed, 85 insertions, 82 deletions
diff --git a/composer.json b/composer.json index 6b88b8a..42e2a67 100644 --- a/composer.json +++ b/composer.json @@ -1,30 +1,43 @@ { - "name": "masterminds/html5", - "description": "An HTML5 parser and serializer.", - "type": "library", - "homepage": "http://masterminds.github.io/html5-php", - "license": "MIT", - "keywords": ["xml", "html", "html5", "dom", "parser", "serializer", "querypath"], - "authors": [ - { - "name": "Matt Butcher", - "email": "[email protected]" - }, - { - "name": "Matt Farina", - "email": "[email protected]" + "name" : "masterminds/html5", + "description" : "An HTML5 parser and serializer.", + "type" : "library", + "homepage" : "http://masterminds.github.io/html5-php", + "license" : "MIT", + "keywords" : [ + "xml", + "html", + "html5", + "dom", + "parser", + "serializer", + "querypath" + ], + "authors" : [{ + "name" : "Matt Butcher", + "email" : "[email protected]" + }, { + "name" : "Matt Farina", + "email" : "[email protected]" + } + ], + "require" : { + "ext-libxml" : "*", + "php" : ">=5.3.0" + }, + "require-dev" : { + "satooshi/php-coveralls" : "0.6.*", + "phpunit/phpunit" : "*", + "phpdocumentor/phpdocumentor" : "2.1.*" + }, + "autoload" : { + "psr-0" : { + "HTML5" : "src" + } + }, + "autoload-dev" : { + "psr-4" : { + "HTML5\\Tests\\" : "test/HTML5" + } } - ], - "require" : { - "ext-libxml" : "*", - "php" : ">=5.3.0" - }, - "require-dev": { - "satooshi/php-coveralls": "0.6.*", - "phpunit/phpunit" : "*", - "phpdocumentor/phpdocumentor": "2.1.*" - }, - "autoload": { - "psr-0": {"HTML5": "src"} - } -} +}
\ No newline at end of file diff --git a/phpunit.xml.dist b/phpunit.xml.dist index c145f8b..8dff222 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<phpunit colors="true"> +<phpunit colors="true" bootstrap="vendor/autoload.php"> <testsuites> <testsuite name="PHPUnit"> <directory>test/HTML5/</directory> diff --git a/test/HTML5/ElementsTest.php b/test/HTML5/ElementsTest.php index 64db413..3894ee8 100644 --- a/test/HTML5/ElementsTest.php +++ b/test/HTML5/ElementsTest.php @@ -3,8 +3,6 @@ namespace HTML5\Tests; use \HTML5\Elements; -require_once 'TestCase.php'; - class ElementsTest extends TestCase { public $html5Elements = array( diff --git a/test/HTML5/Html5Test.php b/test/HTML5/Html5Test.php index 4e7c300..ca2921f 100644 --- a/test/HTML5/Html5Test.php +++ b/test/HTML5/Html5Test.php @@ -1,8 +1,6 @@ <?php namespace HTML5\Tests; -require_once 'TestCase.php'; - class Html5Test extends TestCase { /** 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. diff --git a/test/HTML5/Serializer/OutputRulesTest.php b/test/HTML5/Serializer/OutputRulesTest.php index 61e2d50..51e6a0e 100644 --- a/test/HTML5/Serializer/OutputRulesTest.php +++ b/test/HTML5/Serializer/OutputRulesTest.php @@ -1,12 +1,10 @@ <?php -namespace HTML5\Tests; +namespace HTML5\Tests\Serializer; use \HTML5\Serializer\OutputRules; use \HTML5\Serializer\Traverser; use \HTML5\Parser; -require_once __DIR__ . '/../TestCase.php'; - class OutputRulesTest extends \HTML5\Tests\TestCase { protected $markup = '<!doctype html> @@ -22,7 +20,7 @@ class OutputRulesTest extends \HTML5\Tests\TestCase { /** * Using reflection we make a protected method accessible for testing. - * + * * @param string $name * The name of the method on the Traverser class to test. * diff --git a/test/HTML5/Serializer/TraverserTest.php b/test/HTML5/Serializer/TraverserTest.php index 5816bfc..7f5f5ed 100644 --- a/test/HTML5/Serializer/TraverserTest.php +++ b/test/HTML5/Serializer/TraverserTest.php @@ -1,12 +1,10 @@ <?php -namespace HTML5\Tests; +namespace HTML5\Tests\Serializer; use \HTML5\Serializer\OutputRules; use \HTML5\Serializer\Traverser; use \HTML5\Parser; -require_once __DIR__ . '/../TestCase.php'; - class TraverserTest extends \HTML5\Tests\TestCase { protected $markup = '<!doctype html> @@ -22,7 +20,7 @@ class TraverserTest extends \HTML5\Tests\TestCase { /** * Using reflection we make a protected method accessible for testing. - * + * * @param string $name * The name of the method on the Traverser class to test. * diff --git a/test/HTML5/TestCase.php b/test/HTML5/TestCase.php index 8d3148e..836614e 100644 --- a/test/HTML5/TestCase.php +++ b/test/HTML5/TestCase.php @@ -1,9 +1,6 @@ <?php namespace HTML5\Tests; -require_once 'PHPUnit/Autoload.php'; -require_once __DIR__ . '/../../vendor/autoload.php'; - class TestCase extends \PHPUnit_Framework_TestCase { const DOC_OPEN = '<!DOCTYPE html><html><head><title>test</title></head><body>'; const DOC_CLOSE = '</body></html>'; |