aboutsummaryrefslogtreecommitdiffstats
path: root/tests/text_formatter
diff options
context:
space:
mode:
Diffstat (limited to 'tests/text_formatter')
-rw-r--r--tests/text_formatter/s9e/factory_test.php15
-rw-r--r--tests/text_formatter/s9e/fixtures/preserve_comments.xml28
2 files changed, 43 insertions, 0 deletions
diff --git a/tests/text_formatter/s9e/factory_test.php b/tests/text_formatter/s9e/factory_test.php
index 9f7551ef14..8382097544 100644
--- a/tests/text_formatter/s9e/factory_test.php
+++ b/tests/text_formatter/s9e/factory_test.php
@@ -179,6 +179,21 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case
}
/**
+ * @testdox Preserves comments in custom BBCodes
+ */
+ public function test_preserve_comments()
+ {
+ $fixture = __DIR__ . '/fixtures/preserve_comments.xml';
+ $container = $this->get_test_case_helpers()->set_s9e_services(null, $fixture);
+ $parser = $container->get('text_formatter.parser');
+ $renderer = $container->get('text_formatter.renderer');
+
+ $original = '[X]';
+ $expected = '<!-- comment -->';
+ $this->assertSame($expected, $renderer->render($parser->parse($original)));
+ }
+
+ /**
* @testdox Accepts unsafe custom BBCodes
*/
public function test_unsafe_bbcode()
diff --git a/tests/text_formatter/s9e/fixtures/preserve_comments.xml b/tests/text_formatter/s9e/fixtures/preserve_comments.xml
new file mode 100644
index 0000000000..f81d366aad
--- /dev/null
+++ b/tests/text_formatter/s9e/fixtures/preserve_comments.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<dataset>
+ <table name="phpbb_bbcodes">
+ <column>bbcode_id</column>
+ <column>bbcode_tag</column>
+ <column>bbcode_helpline</column>
+ <column>display_on_posting</column>
+ <column>bbcode_match</column>
+ <column>bbcode_tpl</column>
+ <column>first_pass_match</column>
+ <column>first_pass_replace</column>
+ <column>second_pass_match</column>
+ <column>second_pass_replace</column>
+
+ <row>
+ <value>13</value>
+ <value>X</value>
+ <value></value>
+ <value>1</value>
+ <value>[X][/X]</value>
+ <value><![CDATA[<!-- comment -->]]></value>
+ <value><![CDATA[!\[x\]\[/x\]!i]]></value>
+ <value><![CDATA[[x:$uid][/x:$uid]]]></value>
+ <value><![CDATA[[x:$uid][/x:$uid]]]></value>
+ <value></value>
+ </row>
+ </table>
+</dataset>