summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMatt Butcher <[email protected]>2013-05-30 09:23:26 -0500
committerMatt Butcher <[email protected]>2013-05-30 09:23:26 -0500
commitb1cbd9b4cd488471651751678cd90575bbb74bc9 (patch)
tree6dcf0afce7206b4372adc1a1ddbc25698b38e24f /test
parent0e149588548834bbfee7770fac8455cc404fb8ca (diff)
parentfffeafbfe08e306356acd50cf568ec5904da882c (diff)
Merge branch 'master' of github.com:Masterminds/html5-php
Diffstat (limited to 'test')
-rw-r--r--test/HTML5/Html5Test.html10
-rw-r--r--test/HTML5/Html5Test.php36
-rw-r--r--test/HTML5/Parser/TokenizerTest.php4
3 files changed, 48 insertions, 2 deletions
diff --git a/test/HTML5/Html5Test.html b/test/HTML5/Html5Test.html
new file mode 100644
index 0000000..cc30e6b
--- /dev/null
+++ b/test/HTML5/Html5Test.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <title>Test</title>
+ </head>
+ <body>
+ <p>This is a test.</p>
+ </body>
+</html> \ No newline at end of file
diff --git a/test/HTML5/Html5Test.php b/test/HTML5/Html5Test.php
new file mode 100644
index 0000000..2d6e005
--- /dev/null
+++ b/test/HTML5/Html5Test.php
@@ -0,0 +1,36 @@
+<?php
+namespace HTML5\Tests;
+
+require_once 'TestCase.php';
+
+class Html5Test extends TestCase {
+
+ public function testLoad() {
+ $dom = \HTML5::load(__DIR__ . '/Html5Test.html');
+ $this->assertInstanceOf('\DOMDocument', $dom);
+ $this->assertEmpty($dom->errors);
+ }
+
+ public function testLoadHTML() {
+ $contents = file_get_contents(__DIR__ . '/Html5Test.html');
+ $dom = \HTML5::loadHTML($contents);
+ $this->assertInstanceOf('\DOMDocument', $dom);
+ $this->assertEmpty($dom->errors);
+ }
+
+ // This test reads a document into a dom, turn the dom into a document,
+ // then tries to read that document again. This makes sure we are reading,
+ // and generating a document that works at a high level.
+ public function testItWorks() {
+ $dom = \HTML5::load(__DIR__ . '/Html5Test.html');
+ $this->assertInstanceOf('\DOMDocument', $dom);
+ $this->assertEmpty($dom->errors);
+
+ $saved = \HTML5::saveHTML($dom);
+
+ $dom2 = \HTML5::loadHTML($saved);
+ $this->assertInstanceOf('\DOMDocument', $dom2);
+ $this->assertEmpty($dom2->errors);
+ }
+
+}
diff --git a/test/HTML5/Parser/TokenizerTest.php b/test/HTML5/Parser/TokenizerTest.php
index 0692bc3..edc427c 100644
--- a/test/HTML5/Parser/TokenizerTest.php
+++ b/test/HTML5/Parser/TokenizerTest.php
@@ -1,6 +1,6 @@
<?php
namespace HTML5\Parser;
-require __DIR__ . '/../TestCase.php';
+require_once __DIR__ . '/../TestCase.php';
require 'EventStack.php';
class TokenizerTest extends \HTML5\Tests\TestCase {
@@ -18,7 +18,7 @@ class TokenizerTest extends \HTML5\Tests\TestCase {
public function assertEventEquals($type, $expects, $event) {
$this->assertEquals($type, $event['name'], "Event $type for " . print_r($event, TRUE));
if (is_array($expects)) {
- $this->assertEquals($expects, $event['data'], "Event $type should equal $expects: " . print_r($event, TRUE));
+ $this->assertEquals($expects, $event['data'], "Event $type should equal " . print_r($expects, TRUE) . ": " . print_r($event, TRUE));
}
else {
$this->assertEquals($expects, $event['data'][0], "Event $type should equal $expects: " . print_r($event, TRUE));