summaryrefslogtreecommitdiff
path: root/test/HTML5/Serializer/OutputRulesTest.php
diff options
context:
space:
mode:
authorMatt Farina <[email protected]>2014-02-11 20:21:34 -0500
committerMatt Farina <[email protected]>2014-02-11 20:21:34 -0500
commite21281f7c1d289d9237a34a906f9fec8195640d1 (patch)
tree186df6952a489e06380172c19a5139a3fc754e91 /test/HTML5/Serializer/OutputRulesTest.php
parent001243d8915bfad8e84c71134dabcbb7a0307bd3 (diff)
parentfe713d549d436b63e8367756f19cb456e60d2ff3 (diff)
Merge pull request #25 from goetas/patch-2
Removed quote conversion to entity inside content
Diffstat (limited to 'test/HTML5/Serializer/OutputRulesTest.php')
-rw-r--r--test/HTML5/Serializer/OutputRulesTest.php31
1 files changed, 20 insertions, 11 deletions
diff --git a/test/HTML5/Serializer/OutputRulesTest.php b/test/HTML5/Serializer/OutputRulesTest.php
index 0c85492..d04ebef 100644
--- a/test/HTML5/Serializer/OutputRulesTest.php
+++ b/test/HTML5/Serializer/OutputRulesTest.php
@@ -217,7 +217,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() {
@@ -236,24 +236,33 @@ class OutputRulesTest extends \HTML5\Tests\TestCase {
$this->assertEquals('foo', stream_get_contents($s, -1, 0));
}
- function testEnc() {
+ function getEncData(){
+ return array(
+ array(false, '&\'<>"', '&amp;\'&lt;&gt;"', '&amp;&apos;&lt;&gt;&quot;'),
+ array(false, 'This + is. a < test', 'This + is. a &lt; test', 'This &plus; is&period; a &lt; test'),
+ array(false, '.+#', '.+#', '&period;&plus;&num;'),
- // Test basic escaping of text.
- $tests = array(
- '&\'<>"' => '&amp;&#039;&lt;&gt;&quot;',
- 'This + is. a < test' => 'This + is. a &lt; test',
+ array(true, '.+#\'', '.+#\'', '&period;&plus;&num;&apos;'),
+ array(true, '&".<', '&amp;&quot;.<', '&amp;&quot;&period;&lt;'),
+ array(true, '&\'<>"', '&amp;\'<>&quot;', '&amp;&apos;&lt;&gt;&quot;'),
+ array(true, "\xc2\xa0\"'", '&nbsp;&quot;\'', '&nbsp;&quot;&apos;'),
);
+ }
+
+ /**
+ * Test basic escaping of text.
+ * @dataProvider getEncData
+ */
+ function testEnc($isAttribute, $test, $expected, $expectedEncoded) {
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, $isAttribute));
list($o, $s) = $this->getOutputRules(array('encode_entities' => TRUE));
$m = $this->getProtectedMethod('enc');
-
- $this->assertEquals('&period;&plus;&num;', $m->invoke($o, '.+#'));
+ $this->assertEquals($expectedEncoded, $m->invoke($o, $test, $isAttribute));
}
function testAttrs() {