diff options
Diffstat (limited to 'test/HTML5')
-rw-r--r-- | test/HTML5/Html5Test.php | 1 | ||||
-rw-r--r-- | test/HTML5/Serializer/OutputRulesTest.php | 78 | ||||
-rw-r--r-- | test/HTML5/Serializer/TraverserTest.php | 7 |
3 files changed, 38 insertions, 48 deletions
diff --git a/test/HTML5/Html5Test.php b/test/HTML5/Html5Test.php index 844d7fc..6511ae5 100644 --- a/test/HTML5/Html5Test.php +++ b/test/HTML5/Html5Test.php @@ -79,7 +79,6 @@ class Html5Test extends TestCase { public function testConfig() { $options = \HTML5::options(); $this->assertEquals(FALSE, $options['encode_entities']); - $this->assertEquals('\HTML5\Serializer\OutputRules', $options['output_rules']); \HTML5::setOption('foo', 'bar'); \HTML5::setOption('encode_entities', TRUE); diff --git a/test/HTML5/Serializer/OutputRulesTest.php b/test/HTML5/Serializer/OutputRulesTest.php index 425c269..5d35ea8 100644 --- a/test/HTML5/Serializer/OutputRulesTest.php +++ b/test/HTML5/Serializer/OutputRulesTest.php @@ -47,22 +47,20 @@ class OutputRulesTest extends \HTML5\Tests\TestCase { $options = $options + \HTML5::options(); $stream = fopen('php://temp', 'w'); $dom = \HTML5::loadHTML($this->markup); - $t = new Traverser($dom, $stream, $options); - $p = $this->getTraverserProtectedProperty('rules'); - $o = $p->getValue($t); + $r = new OutputRules($stream, $options); + $t = new Traverser($dom, $stream, $r, $options); - return array($o, $stream); + return array($r, $stream); } function testDocument() { $dom = \HTML5::loadHTML('<!doctype html><html lang="en"><body>foo</body></html>'); $stream = fopen('php://temp', 'w'); - $t = new Traverser($dom, $stream, \HTML5::options()); - $p = $this->getTraverserProtectedProperty('rules'); - $o = $p->getValue($t); + $r = new OutputRules($stream, \HTML5::options()); + $t = new Traverser($dom, $stream, $r, \HTML5::options()); - $o->document($dom); + $r->document($dom); $this->assertEquals("<!DOCTYPE html>\n<html lang=\"en\"><body>foo</body></html>\n", stream_get_contents($stream, -1, 0)); } @@ -70,16 +68,14 @@ class OutputRulesTest extends \HTML5\Tests\TestCase { $dom = \HTML5::loadHTML('<!doctype html><html lang="en"><body>foo</body></html>'); $stream = fopen('php://temp', 'w'); - $t = new Traverser($dom, $stream, \HTML5::options()); - $p = $this->getTraverserProtectedProperty('rules'); - $o = $p->getValue($t); + $r = new OutputRules($stream, \HTML5::options()); + $t = new Traverser($dom, $stream, $r, \HTML5::options()); $m = $this->getProtectedMethod('doctype'); - $m->invoke($o, 'foo'); + $m->invoke($r, 'foo'); $this->assertEquals("<!DOCTYPE html>\n", stream_get_contents($stream, -1, 0)); } - function testElement() { $dom = \HTML5::loadHTML('<!doctype html> <html lang="en"> @@ -94,12 +90,11 @@ class OutputRulesTest extends \HTML5\Tests\TestCase { </html>'); $stream = fopen('php://temp', 'w'); - $t = new Traverser($dom, $stream, \HTML5::options()); - $p = $this->getTraverserProtectedProperty('rules'); - $o = $p->getValue($t); + $r = new OutputRules($stream, \HTML5::options()); + $t = new Traverser($dom, $stream, $r, \HTML5::options()); $list = $dom->getElementsByTagName('div'); - $o->element($list->item(0)); + $r->element($list->item(0)); $this->assertEquals('<div id="foo" class="bar baz">foo bar baz</div>', stream_get_contents($stream, -1, 0)); } @@ -112,13 +107,12 @@ class OutputRulesTest extends \HTML5\Tests\TestCase { </html>'); $stream = fopen('php://temp', 'w'); - $t = new Traverser($dom, $stream, \HTML5::options()); - $p = $this->getTraverserProtectedProperty('rules'); - $o = $p->getValue($t); + $r = new OutputRules($stream, \HTML5::options()); + $t = new Traverser($dom, $stream, $r, \HTML5::options()); $list = $dom->getElementsByTagName('div'); $m = $this->getProtectedMethod('openTag'); - $m->invoke($o, $list->item(0)); + $m->invoke($r, $list->item(0)); $this->assertEquals('<div id="foo" class="bar baz">', stream_get_contents($stream, -1, 0)); } @@ -131,12 +125,11 @@ class OutputRulesTest extends \HTML5\Tests\TestCase { </html>'); $stream = fopen('php://temp', 'w'); - $t = new Traverser($dom, $stream, \HTML5::options()); - $p = $this->getTraverserProtectedProperty('rules'); - $o = $p->getValue($t); + $r = new OutputRules($stream, \HTML5::options()); + $t = new Traverser($dom, $stream, $r, \HTML5::options()); $list = $dom->getElementsByTagName('div'); - $o->cdata($list->item(0)->childNodes->item(0)); + $r->cdata($list->item(0)->childNodes->item(0)); $this->assertEquals('<![CDATA[bar]]>', stream_get_contents($stream, -1, 0)); } @@ -149,12 +142,11 @@ class OutputRulesTest extends \HTML5\Tests\TestCase { </html>'); $stream = fopen('php://temp', 'w'); - $t = new Traverser($dom, $stream, \HTML5::options()); - $p = $this->getTraverserProtectedProperty('rules'); - $o = $p->getValue($t); + $r = new OutputRules($stream, \HTML5::options()); + $t = new Traverser($dom, $stream, $r, \HTML5::options()); $list = $dom->getElementsByTagName('div'); - $o->comment($list->item(0)->childNodes->item(0)); + $r->comment($list->item(0)->childNodes->item(0)); $this->assertEquals('<!-- foo -->', stream_get_contents($stream, -1, 0)); } @@ -167,12 +159,11 @@ class OutputRulesTest extends \HTML5\Tests\TestCase { </html>'); $stream = fopen('php://temp', 'w'); - $t = new Traverser($dom, $stream, \HTML5::options()); - $p = $this->getTraverserProtectedProperty('rules'); - $o = $p->getValue($t); + $r = new OutputRules($stream, \HTML5::options()); + $t = new Traverser($dom, $stream, $r, \HTML5::options()); $list = $dom->getElementsByTagName('script'); - $o->text($list->item(0)->childNodes->item(0)); + $r->text($list->item(0)->childNodes->item(0)); $this->assertEquals('baz();', stream_get_contents($stream, -1, 0)); } @@ -221,14 +212,13 @@ class OutputRulesTest extends \HTML5\Tests\TestCase { </html>'); $stream = fopen('php://temp', 'w'); - $t = new Traverser($dom, $stream, \HTML5::options()); - $p = $this->getTraverserProtectedProperty('rules'); - $o = $p->getValue($t); + $r = new OutputRules($stream, \HTML5::options()); + $t = new Traverser($dom, $stream, $r, \HTML5::options()); $list = $dom->getElementsByTagName('div'); $m = $this->getProtectedMethod('attrs'); - $m->invoke($o, $list->item(0)); + $m->invoke($r, $list->item(0)); $content = stream_get_contents($stream, -1, 0); $this->assertEquals(' id="foo" class="bar baz" disabled', $content); @@ -251,12 +241,11 @@ class OutputRulesTest extends \HTML5\Tests\TestCase { </html>'); $stream = fopen('php://temp', 'w'); - $t = new Traverser($dom, $stream, \HTML5::options()); - $p = $this->getTraverserProtectedProperty('rules'); - $o = $p->getValue($t); + $r = new OutputRules($stream, \HTML5::options()); + $t = new Traverser($dom, $stream, $r, \HTML5::options()); $list = $dom->getElementsByTagName('svg'); - $o->element($list->item(0)); + $r->element($list->item(0)); $contents = stream_get_contents($stream, -1, 0); $this->assertRegExp('|<svg width="150" height="100" viewBox="0 0 3 2">|', $contents); $this->assertRegExp('|<rect width="1" height="2" x="0" fill="#008d46" />|', $contents); @@ -279,12 +268,11 @@ class OutputRulesTest extends \HTML5\Tests\TestCase { </html>'); $stream = fopen('php://temp', 'w'); - $t = new Traverser($dom, $stream, \HTML5::options()); - $p = $this->getTraverserProtectedProperty('rules'); - $o = $p->getValue($t); + $r = new OutputRules($stream, \HTML5::options()); + $t = new Traverser($dom, $stream, $r, \HTML5::options()); $list = $dom->getElementsByTagName('math'); - $o->element($list->item(0)); + $r->element($list->item(0)); $content = stream_get_contents($stream, -1, 0); $this->assertRegExp('|<math>|', $content); $this->assertRegExp('|<csymbol definitionURL="http://www.example.com/mathops/multiops.html#plusminus">|', $content); diff --git a/test/HTML5/Serializer/TraverserTest.php b/test/HTML5/Serializer/TraverserTest.php index 872922d..6fa5c1e 100644 --- a/test/HTML5/Serializer/TraverserTest.php +++ b/test/HTML5/Serializer/TraverserTest.php @@ -1,6 +1,7 @@ <?php namespace HTML5\Tests; +use \HTML5\Serializer\OutputRules; use \HTML5\Serializer\Traverser; use \HTML5\Parser; @@ -50,9 +51,10 @@ class TraverserTest extends \HTML5\Tests\TestCase { // use a stream in temp space. $stream = fopen('php://temp', 'w'); + $r = new OutputRules($stream, \HTML5::options()); $dom = \HTML5::loadHTML($this->markup); - $t = new Traverser($dom, $stream, \HTML5::options()); + $t = new Traverser($dom, $stream, $r, \HTML5::options()); $this->assertInstanceOf('\HTML5\Serializer\Traverser', $t); } @@ -67,7 +69,8 @@ class TraverserTest extends \HTML5\Tests\TestCase { $this->assertInstanceOf('\DOMDocumentFragment', $dom); $stream = fopen('php://temp', 'w'); - $t = new Traverser($dom, $stream, \HTML5::options()); + $r = new OutputRules($stream, \HTML5::options()); + $t = new Traverser($dom, $stream, $r, \HTML5::options()); $out = $t->walk(); $this->assertEquals($html, stream_get_contents($stream, -1, 0)); |