diff options
-rw-r--r-- | src/HTML5/Serializer.php | 2 | ||||
-rw-r--r-- | test/HTML5/SerializerTest.php | 24 | ||||
-rw-r--r-- | test/HTML5/TestCase.php | 12 |
3 files changed, 37 insertions, 1 deletions
diff --git a/src/HTML5/Serializer.php b/src/HTML5/Serializer.php index 207f848..e31bbbe 100644 --- a/src/HTML5/Serializer.php +++ b/src/HTML5/Serializer.php @@ -63,7 +63,7 @@ class Serializer { // faster than writing directly to a string, but it makes the interface // consistant and will keep memory consumption lower (2MB max for the file // buffer). - $stream = fopen('php://temp'); + $stream = fopen('php://temp', 'w'); $this->save($stream); return stream_get_contents($stream, -1, 0); } diff --git a/test/HTML5/SerializerTest.php b/test/HTML5/SerializerTest.php new file mode 100644 index 0000000..5eb44eb --- /dev/null +++ b/test/HTML5/SerializerTest.php @@ -0,0 +1,24 @@ +<?php + +namespace HTML5\Tests; + +use \HTML5\Serializer; + +require_once 'TestCase.php'; + +class SerializerTest extends TestCase { + public function testBasicDocument() { + $html = '<!DOCTYPE html><html><body>test</body></html>'; + + $dom = \HTML5::parse($html); + + $this->assertTrue($dom instanceof \DOMDocument, "Canary"); + + $ser = new \HTML5\Serializer($dom); + + $out = $ser->saveHTML(); + + $this->assertTrue(count($out) >= count($html)); + + } +} diff --git a/test/HTML5/TestCase.php b/test/HTML5/TestCase.php new file mode 100644 index 0000000..b5c18e0 --- /dev/null +++ b/test/HTML5/TestCase.php @@ -0,0 +1,12 @@ +<?php +namespace HTML5\Tests; + +require_once 'PHPUnit/Autoload.php'; +require_once __DIR__ . '/../../vendor/autoload.php'; + +class TestCase extends \PHPUnit_Framework_TestCase { + + public function testFoo() { + // Placeholder. Why is PHPUnit emitting warnings about no tests? + } +} |