From 6d8d52cf7c157d10df37cceaa80e6931f1e2b623 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Tue, 4 Jun 2013 21:20:31 -0400 Subject: Added a serializer test for a file on the system. --- test/HTML5/Serializer/SerializerTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test/HTML5') diff --git a/test/HTML5/Serializer/SerializerTest.php b/test/HTML5/Serializer/SerializerTest.php index 234cca4..2c59474 100644 --- a/test/HTML5/Serializer/SerializerTest.php +++ b/test/HTML5/Serializer/SerializerTest.php @@ -60,6 +60,7 @@ class SerializerTest extends \HTML5\Tests\TestCase { $dom = \HTML5::loadHTML($html); $this->assertTrue($dom instanceof \DOMDocument, "Canary"); + // Test saving to a stream. $ser = new Serializer($dom, \HTML5::options()); $out = fopen("php://temp", "w"); $ser->save($out); @@ -67,6 +68,14 @@ class SerializerTest extends \HTML5\Tests\TestCase { rewind($out); $res = stream_get_contents($out); $this->assertTrue(count($res) >= count($html)); + + // Test saving to a file on the file system. + $tmpfname = tempnam(sys_get_temp_dir(), "html5-php"); + $ser = new Serializer($dom, \HTML5::options()); + $ser->save($tmpfname); + $content = file_get_contents($tmpfname); + $this->assertRegExp('|test|', $content); + unlink($tmpfname); } public function testElements() { -- cgit v1.2.3