diff options
Diffstat (limited to 'test/HTML5')
-rw-r--r-- | test/HTML5/Serializer/OutputRulesTest.php | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/test/HTML5/Serializer/OutputRulesTest.php b/test/HTML5/Serializer/OutputRulesTest.php index 61e2d50..9c20a7f 100644 --- a/test/HTML5/Serializer/OutputRulesTest.php +++ b/test/HTML5/Serializer/OutputRulesTest.php @@ -22,7 +22,7 @@ class OutputRulesTest extends \HTML5\Tests\TestCase { /** * Using reflection we make a protected method accessible for testing. - * + * * @param string $name * The name of the method on the Traverser class to test. * @@ -216,7 +216,7 @@ class OutputRulesTest extends \HTML5\Tests\TestCase { $item = $dom->getElementById('foo'); $r->text($item->firstChild); - $this->assertEquals('<script>alert("hi");</script>', stream_get_contents($stream, -1, 0)); + $this->assertEquals('<script>alert("hi");</script>', stream_get_contents($stream, -1, 0)); } function testNl() { @@ -235,24 +235,42 @@ class OutputRulesTest extends \HTML5\Tests\TestCase { $this->assertEquals('foo', stream_get_contents($s, -1, 0)); } - function testEnc() { - - // Test basic escaping of text. - $tests = array( - '&\'<>"' => '&'<>"', - 'This + is. a < test' => 'This + is. a < test', + function getEncData(){ + return array( + array('&\'<>"', '&\'<>"'), + array('This + is. a < test', 'This + is. a < test'), + array('.+#', '.+#'), ); + } + + function getEncWithEntiyesData(){ + return array( + array('.+#', '.+#'), + ); + } + + /** + * Test basic escaping of text. + * @dataProvider getEncData + */ + function testEnc($test, $expected) { list($o, $s) = $this->getOutputRules(); $m = $this->getProtectedMethod('enc'); - foreach ($tests as $test => $expected) { - $this->assertEquals($expected, $m->invoke($o, $test)); - } + $this->assertEquals($expected, $m->invoke($o, $test)); - list($o, $s) = $this->getOutputRules(array('encode_entities' => TRUE)); - $m = $this->getProtectedMethod('enc'); + } + + /** + * Test basic escaping of text. + * @dataProvider getEncWithEntiyesData + */ + function testEncWithEntities($test, $expected) { - $this->assertEquals('.+#', $m->invoke($o, '.+#')); + list($o, $s) = $this->getOutputRules(array('encode_entities' => TRUE)); + $m = $this->getProtectedMethod('enc'); + + $this->assertEquals($expected, $m->invoke($o, $test)); } function testAttrs() { |