summaryrefslogtreecommitdiff
path: root/test/HTML5/Serializer
diff options
context:
space:
mode:
authorAsmir Mustafic <[email protected]>2014-02-04 08:59:22 +0100
committerAsmir Mustafic <[email protected]>2014-02-04 08:59:22 +0100
commit6392531bdcc3fbbf6595fe44b752813589459213 (patch)
tree326f2f026e73a1b94cb24294d230e63ef522adcf /test/HTML5/Serializer
parentd6fc8917a347e0adf9bdaab9ac00a66bf7aa7fc5 (diff)
Test enc output rule
Diffstat (limited to 'test/HTML5/Serializer')
-rw-r--r--test/HTML5/Serializer/OutputRulesTest.php46
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('&lt;script&gt;alert(&quot;hi&quot;);&lt;/script&gt;', stream_get_contents($stream, -1, 0));
+ $this->assertEquals('&lt;script&gt;alert("hi");&lt;/script&gt;', 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(
- '&\'<>"' => '&amp;&#039;&lt;&gt;&quot;',
- 'This + is. a < test' => 'This + is. a &lt; test',
+ function getEncData(){
+ return array(
+ array('&\'<>"', '&amp;\'&lt;&gt;"'),
+ array('This + is. a < test', 'This + is. a &lt; test'),
+ array('.+#', '.+#'),
);
+ }
+
+ function getEncWithEntiyesData(){
+ return array(
+ array('.+#', '&period;&plus;&num;'),
+ );
+ }
+
+ /**
+ * 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('&period;&plus;&num;', $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() {