From 40cf562d10ad605bc7cd113cfeb9329c19a20204 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Fri, 3 May 2013 16:05:39 -0400 Subject: Tests and comments for new lines in the traverser. --- test/HTML5/Serializer/TraverserTest.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'test/HTML5') diff --git a/test/HTML5/Serializer/TraverserTest.php b/test/HTML5/Serializer/TraverserTest.php index adc56ea..0226f5e 100644 --- a/test/HTML5/Serializer/TraverserTest.php +++ b/test/HTML5/Serializer/TraverserTest.php @@ -37,6 +37,20 @@ class TraverserTest extends \HTML5\Tests\TestCase { return $method; } + function getTraverser() { + $stream = fopen('php://temp', 'w'); + + // Using the existing parser (libxml). + // @todo switch to the html5 parser. + $dom = new \DOMDocument(); + $dom->loadHTML($this->markup); + + $t = new Traverser($dom, $stream); + + // We return both the traverser and stream so we can pull from it. + return array($t, $stream); + } + function testConstruct() { // The traverser needs a place to write the output to. In our case we @@ -52,4 +66,12 @@ class TraverserTest extends \HTML5\Tests\TestCase { $this->assertInstanceOf('\HTML5\Serializer\Traverser', $t); } + + function testNl() { + list($t, $s) = $this->getTraverser(); + + $m = $this->getProtectedMethod('nl'); + $m->invoke($t); + $this->assertEquals(PHP_EOL, stream_get_contents($s, -1, 0)); + } } \ No newline at end of file -- cgit v1.2.3