From 3caf2aa846bc2bd6cec0d4442f5a4b486c6da29b Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Wed, 26 Jun 2013 16:42:04 -0400 Subject: Added a bunch of serializer tests to test fragments. --- test/HTML5/Serializer/SerializerTest.php | 44 +++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/HTML5/Serializer/SerializerTest.php b/test/HTML5/Serializer/SerializerTest.php index bc4e443..7cfe44f 100644 --- a/test/HTML5/Serializer/SerializerTest.php +++ b/test/HTML5/Serializer/SerializerTest.php @@ -84,6 +84,14 @@ class SerializerTest extends \HTML5\Tests\TestCase { $res = $this->cycle(''); $this->assertRegExp('||', $res); + // Should have content. + $res = $this->cycleFragment('
FOO
'); + $this->assertRegExp('|
FOO
|', $res); + + // Should be empty + $res = $this->cycleFragment(''); + $this->assertRegExp('||', $res); + // Should have no closing tag. $res = $this->cycle('
'); $this->assertRegExp('|
|', $res); @@ -100,21 +108,45 @@ class SerializerTest extends \HTML5\Tests\TestCase { $res = $this->cycle('
FOO
'); $this->assertRegExp('|
FOO
|', $res); + + $res = $this->cycleFragment('
FOO
'); + $this->assertRegExp('|
FOO
|', $res); + + // XXX: Note that spec does NOT require attrs in the same order. + $res = $this->cycleFragment('
FOO
'); + $this->assertRegExp('|
FOO
|', $res); + + $res = $this->cycleFragment('
FOO
'); + $this->assertRegExp('|
FOO
|', $res); } public function testPCData() { $res = $this->cycle('This is a test.'); $this->assertRegExp('|This is a test.|', $res); - $res = $this->cycle($this->prepareHtml('This + $res = $this->cycleFragment('This is a test.'); + $this->assertRegExp('|This is a test.|', $res); + + $res = $this->cycle('This + is + a + test.'); + + // Check that newlines are there, but don't count spaces. + $this->assertRegExp('|This\n\s*is\n\s*a\n\s*test.|', $res); + + $res = $this->cycleFragment('This is a - test.')); + test.'); // Check that newlines are there, but don't count spaces. $this->assertRegExp('|This\n\s*is\n\s*a\n\s*test.|', $res); - $res = $this->cycle($this->prepareHtml('This is a test.')); + $res = $this->cycle('This is a test.'); + $this->assertRegExp('|This is a test.|', $res); + + $res = $this->cycleFragment('This is a test.'); $this->assertRegExp('|This is a test.|', $res); } @@ -124,6 +156,12 @@ class SerializerTest extends \HTML5\Tests\TestCase { $res = $this->cycle(''); $this->assertRegExp('|div>div>div|', $res); + + $res = $this->cycleFragment(''); + $this->assertRegExp('|2 < 1|', $res); + + $res = $this->cycleFragment(''); + $this->assertRegExp('|div>div>div|', $res); } public function testEntities() { -- cgit v1.2.3