aboutsummaryrefslogtreecommitdiffstats
path: root/tests/text_reparser
diff options
context:
space:
mode:
Diffstat (limited to 'tests/text_reparser')
-rw-r--r--tests/text_reparser/plugins/contact_admin_info_test.php96
-rw-r--r--tests/text_reparser/plugins/fixtures/contact_admin_info.xml23
-rw-r--r--tests/text_reparser/plugins/fixtures/forums.xml113
-rw-r--r--tests/text_reparser/plugins/fixtures/groups.xml69
-rw-r--r--tests/text_reparser/plugins/fixtures/poll_options.xml133
-rw-r--r--tests/text_reparser/plugins/fixtures/polls.xml98
-rw-r--r--tests/text_reparser/plugins/fixtures/posts.xml91
-rw-r--r--tests/text_reparser/plugins/fixtures/privmsgs.xml113
-rw-r--r--tests/text_reparser/plugins/fixtures/users.xml91
-rw-r--r--tests/text_reparser/plugins/forum_description_test.php26
-rw-r--r--tests/text_reparser/plugins/forum_rules_test.php26
-rw-r--r--tests/text_reparser/plugins/group_description_test.php26
-rw-r--r--tests/text_reparser/plugins/pm_text_test.php26
-rw-r--r--tests/text_reparser/plugins/poll_option_test.php130
-rw-r--r--tests/text_reparser/plugins/poll_title_test.php26
-rw-r--r--tests/text_reparser/plugins/post_text_test.php26
-rw-r--r--tests/text_reparser/plugins/test_row_based_plugin.php151
-rw-r--r--tests/text_reparser/plugins/user_signature_test.php26
18 files changed, 1290 insertions, 0 deletions
diff --git a/tests/text_reparser/plugins/contact_admin_info_test.php b/tests/text_reparser/plugins/contact_admin_info_test.php
new file mode 100644
index 0000000000..1dc03834b6
--- /dev/null
+++ b/tests/text_reparser/plugins/contact_admin_info_test.php
@@ -0,0 +1,96 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+require_once __DIR__ . '/../../../phpBB/includes/functions.php';
+require_once __DIR__ . '/../../../phpBB/includes/functions_content.php';
+require_once __DIR__ . '/../../test_framework/phpbb_database_test_case.php';
+
+class phpbb_textreparser_contact_admin_info_test extends phpbb_database_test_case
+{
+ protected $db;
+
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(__DIR__ . '/fixtures/contact_admin_info.xml');
+ }
+
+ protected function get_reparser()
+ {
+ return new \phpbb\textreparser\plugins\contact_admin_info(new \phpbb\config\db_text($this->db, CONFIG_TEXT_TABLE));
+ }
+
+ protected function get_rows()
+ {
+ $sql = 'SELECT config_name, config_value
+ FROM ' . CONFIG_TEXT_TABLE . '
+ ORDER BY config_name';
+ $result = $this->db->sql_query($sql);
+ $rows = $this->db->sql_fetchrowset($result);
+ $this->db->sql_freeresult($result);
+
+ return $rows;
+ }
+
+ public function setUp()
+ {
+ global $config;
+ if (!isset($config))
+ {
+ $config = new \phpbb\config\config(array());
+ }
+ $this->get_test_case_helpers()->set_s9e_services();
+ $this->db = $this->new_dbal();
+ parent::setUp();
+ }
+
+ public function test_get_max_id()
+ {
+ $reparser = $this->get_reparser();
+ $this->assertEquals(1, $reparser->get_max_id());
+ }
+
+ public function test_dry_run()
+ {
+ $old_rows = $this->get_rows();
+ $reparser = $this->get_reparser();
+ $reparser->disable_save();
+ $reparser->reparse_range(1, 1);
+ $new_rows = $this->get_rows();
+ $this->assertEquals($old_rows, $new_rows);
+ }
+
+ public function test_reparse()
+ {
+ $reparser = $this->get_reparser();
+ $reparser->enable_save();
+ $reparser->reparse_range(1, 1);
+ $expected = array(
+ array(
+ 'config_name' => 'contact_admin_info',
+ 'config_value' => '<r><EMAIL email="admin@example.org"><s>[email]</s>admin@example.org<e>[/email]</e></EMAIL></r>',
+ ),
+ array(
+ 'config_name' => 'contact_admin_info_bitfield',
+ 'config_value' => 'ACA=',
+ ),
+ array(
+ 'config_name' => 'contact_admin_info_flags',
+ 'config_value' => '7',
+ ),
+ array(
+ 'config_name' => 'contact_admin_info_uid',
+ 'config_value' => '1a2hbwf5',
+ ),
+ );
+ $this->assertEquals($expected, $this->get_rows());
+ }
+}
diff --git a/tests/text_reparser/plugins/fixtures/contact_admin_info.xml b/tests/text_reparser/plugins/fixtures/contact_admin_info.xml
new file mode 100644
index 0000000000..13cd82b1a4
--- /dev/null
+++ b/tests/text_reparser/plugins/fixtures/contact_admin_info.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<dataset>
+ <table name="phpbb_config_text">
+ <column>config_name</column>
+ <column>config_value</column>
+ <row>
+ <value>contact_admin_info</value>
+ <value>[email:1a2hbwf5]admin@example&#46;org[/email:1a2hbwf5]</value>
+ </row>
+ <row>
+ <value>contact_admin_info_uid</value>
+ <value>1a2hbwf5</value>
+ </row>
+ <row>
+ <value>contact_admin_info_bitfield</value>
+ <value>ACA=</value>
+ </row>
+ <row>
+ <value>contact_admin_info_flags</value>
+ <value>7</value>
+ </row>
+ </table>
+</dataset>
diff --git a/tests/text_reparser/plugins/fixtures/forums.xml b/tests/text_reparser/plugins/fixtures/forums.xml
new file mode 100644
index 0000000000..c12c8d6d48
--- /dev/null
+++ b/tests/text_reparser/plugins/fixtures/forums.xml
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<dataset>
+ <table name="phpbb_forums">
+ <column>forum_id</column>
+ <column>forum_parents</column>
+ <column>forum_desc</column>
+ <column>forum_desc_uid</column>
+ <column>forum_desc_options</column>
+ <column>forum_rules</column>
+ <column>forum_rules_uid</column>
+ <column>forum_rules_options</column>
+ <row>
+ <value>1</value>
+ <value></value>
+ <value>This row should be [b]ignored[/b]</value>
+ <value>abcd1234</value>
+ <value>0</value>
+ <value>This row should be [b]ignored[/b]</value>
+ <value>abcd1234</value>
+ <value>0</value>
+ </row>
+ <row>
+ <value>2</value>
+ <value></value>
+ <value>[b]Not bold[/b] :) http://example.org</value>
+ <value>abcd1234</value>
+ <value>0</value>
+ <value>[b]Not bold[/b] :) http://example.org</value>
+ <value>abcd1234</value>
+ <value>0</value>
+ </row>
+ <row>
+ <value>3</value>
+ <value></value>
+ <value>[b:abcd1234]Bold[/b:abcd1234] :) http://example.org</value>
+ <value>abcd1234</value>
+ <value>1</value>
+ <value>[b:abcd1234]Bold[/b:abcd1234] :) http://example.org</value>
+ <value>abcd1234</value>
+ <value>1</value>
+ </row>
+ <row>
+ <value>4</value>
+ <value></value>
+ <value><![CDATA[[b]Not bold[/b] <!-- s:) --><img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" /><!-- s:) --> http://example.org]]></value>
+ <value>abcd1234</value>
+ <value>2</value>
+ <value><![CDATA[[b]Not bold[/b] <!-- s:) --><img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" /><!-- s:) --> http://example.org]]></value>
+ <value>abcd1234</value>
+ <value>2</value>
+ </row>
+ <row>
+ <value>5</value>
+ <value></value>
+ <value><![CDATA[[b]Not bold[/b] :) <!-- m --><a class="postlink" href="http://example.org">http://example.org</a><!-- m -->]]></value>
+ <value>abcd1234</value>
+ <value>4</value>
+ <value><![CDATA[[b]Not bold[/b] :) <!-- m --><a class="postlink" href="http://example.org">http://example.org</a><!-- m -->]]></value>
+ <value>abcd1234</value>
+ <value>4</value>
+ </row>
+ <row>
+ <value>6</value>
+ <value></value>
+ <value><![CDATA[[flash=123,345:abcd1234]http&#58;//example&#46;org/flash&#46;swf[/flash:abcd1234]]]></value>
+ <value>abcd1234</value>
+ <value>1</value>
+ <value><![CDATA[[flash=123,345:abcd1234]http&#58;//example&#46;org/flash&#46;swf[/flash:abcd1234]]]></value>
+ <value>abcd1234</value>
+ <value>1</value>
+ </row>
+ <row>
+ <value>7</value>
+ <value></value>
+ <value><![CDATA[[flash=123,345]http://example.org/flash.swf[/flash]]]></value>
+ <value>abcd1234</value>
+ <value>0</value>
+ <value><![CDATA[[flash=123,345]http://example.org/flash.swf[/flash]]]></value>
+ <value>abcd1234</value>
+ <value>0</value>
+ </row>
+ <row>
+ <value>8</value>
+ <value></value>
+ <value><![CDATA[[img:abcd1234]http&#58;//example&#46;org/img&#46;png[/img:abcd1234]]]></value>
+ <value>abcd1234</value>
+ <value>1</value>
+ <value><![CDATA[[img:abcd1234]http&#58;//example&#46;org/img&#46;png[/img:abcd1234]]]></value>
+ <value>abcd1234</value>
+ <value>1</value>
+ </row>
+ <row>
+ <value>9</value>
+ <value></value>
+ <value><![CDATA[[img]http://example.org/img.png[/img]]]></value>
+ <value>abcd1234</value>
+ <value>0</value>
+ <value><![CDATA[[img]http://example.org/img.png[/img]]]></value>
+ <value>abcd1234</value>
+ <value>0</value>
+ </row>
+ <row>
+ <value>1000</value>
+ <value></value>
+ <value>This row should be [b]ignored[/b]</value>
+ <value>abcd1234</value>
+ <value>0</value>
+ <value>This row should be [b]ignored[/b]</value>
+ <value>abcd1234</value>
+ <value>0</value>
+ </row>
+ </table>
+</dataset>
diff --git a/tests/text_reparser/plugins/fixtures/groups.xml b/tests/text_reparser/plugins/fixtures/groups.xml
new file mode 100644
index 0000000000..15151426bc
--- /dev/null
+++ b/tests/text_reparser/plugins/fixtures/groups.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<dataset>
+ <table name="phpbb_groups">
+ <column>group_id</column>
+ <column>group_desc</column>
+ <column>group_desc_options</column>
+ <column>group_desc_uid</column>
+ <row>
+ <value>1</value>
+ <value>This row should be [b]ignored[/b]</value>
+ <value>7</value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>[b]Not bold[/b] :) http://example.org</value>
+ <value>0</value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>3</value>
+ <value>[b:abcd1234]Bold[/b:abcd1234] :) http://example.org</value>
+ <value>1</value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>4</value>
+ <value><![CDATA[[b]Not bold[/b] <!-- s:) --><img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" /><!-- s:) --> http://example.org]]></value>
+ <value>2</value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>5</value>
+ <value><![CDATA[[b]Not bold[/b] :) <!-- m --><a class="postlink" href="http://example.org">http://example.org</a><!-- m -->]]></value>
+ <value>4</value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>6</value>
+ <value><![CDATA[[flash=123,345:abcd1234]http&#58;//example&#46;org/flash&#46;swf[/flash:abcd1234]]]></value>
+ <value>1</value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>7</value>
+ <value><![CDATA[[flash=123,345]http://example.org/flash.swf[/flash]]]></value>
+ <value>1</value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>8</value>
+ <value><![CDATA[[img:abcd1234]http&#58;//example&#46;org/img&#46;png[/img:abcd1234]]]></value>
+ <value>1</value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>9</value>
+ <value><![CDATA[[img]http://example.org/img.png[/img]]]></value>
+ <value>1</value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>1000</value>
+ <value>This row should be [b]ignored[/b]</value>
+ <value>7</value>
+ <value>abcd1234</value>
+ </row>
+ </table>
+</dataset>
diff --git a/tests/text_reparser/plugins/fixtures/poll_options.xml b/tests/text_reparser/plugins/fixtures/poll_options.xml
new file mode 100644
index 0000000000..48ba024315
--- /dev/null
+++ b/tests/text_reparser/plugins/fixtures/poll_options.xml
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<dataset>
+ <table name="phpbb_poll_options">
+ <column>poll_option_id</column>
+ <column>topic_id</column>
+ <column>poll_option_text</column>
+ <row>
+ <value>1</value>
+ <value>1</value>
+ <value>This row should be [b]ignored[/b]</value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>1</value>
+ <value>This row should be [b:abcd1234]ignored[/b:abcd1234]</value>
+ </row>
+ <row>
+ <value>1</value>
+ <value>2</value>
+ <value>[b:abcd1234]Bold[/b:abcd1234]</value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>2</value>
+ <value><![CDATA[<!-- s:) --><img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" /><!-- s:) -->]]></value>
+ </row>
+ <row>
+ <value>3</value>
+ <value>2</value>
+ <value><![CDATA[<!-- m --><a class="postlink" href="http://example.org">http://example.org</a><!-- m -->]]></value>
+ </row>
+ <row>
+ <value>1</value>
+ <value>11</value>
+ <value>[b:abcd1234]Bold[/b:abcd1234] :) http://example.org</value>
+ </row>
+ <row>
+ <value>1</value>
+ <value>12</value>
+ <value><![CDATA[[b]Not bold[/b] <!-- s:) --><img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" /><!-- s:) --> http://example.org]]></value>
+ </row>
+ <row>
+ <value>1</value>
+ <value>13</value>
+ <value><![CDATA[[b]Not bold[/b] :) <!-- m --><a class="postlink" href="http://example.org">http://example.org</a><!-- m -->]]></value>
+ </row>
+ <row>
+ <value>1</value>
+ <value>123</value>
+ <value>This row should be [b]ignored[/b]</value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>123</value>
+ <value>This row should be [b:abcd1234]ignored[/b:abcd1234]</value>
+ </row>
+ </table>
+ <table name="phpbb_posts">
+ <column>post_id</column>
+ <column>enable_bbcode</column>
+ <column>enable_smilies</column>
+ <column>enable_magic_url</column>
+ <column>post_text</column>
+ <column>bbcode_uid</column>
+ <row>
+ <value>1</value>
+ <value>1</value>
+ <value>1</value>
+ <value>1</value>
+ <value></value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>11</value>
+ <value>1</value>
+ <value>0</value>
+ <value>0</value>
+ <value></value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>12</value>
+ <value>0</value>
+ <value>1</value>
+ <value>0</value>
+ <value></value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>13</value>
+ <value>0</value>
+ <value>0</value>
+ <value>1</value>
+ <value></value>
+ <value>abcd1234</value>
+ </row>
+ </table>
+ <table name="phpbb_topics">
+ <column>topic_id</column>
+ <column>topic_first_post_id</column>
+ <column>poll_title</column>
+ <row>
+ <value>1</value>
+ <value>1</value>
+ <value>This row should be [b]ignored[/b]</value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>1</value>
+ <value>This row should be [b]ignored[/b]</value>
+ </row>
+ <row>
+ <value>11</value>
+ <value>11</value>
+ <value>BBCode</value>
+ </row>
+ <row>
+ <value>12</value>
+ <value>12</value>
+ <value>Smilies</value>
+ </row>
+ <row>
+ <value>13</value>
+ <value>13</value>
+ <value>Magic URLs</value>
+ </row>
+ <row>
+ <value>123</value>
+ <value>1</value>
+ <value>This row should be [b]ignored[/b]</value>
+ </row>
+ </table>
+</dataset>
diff --git a/tests/text_reparser/plugins/fixtures/polls.xml b/tests/text_reparser/plugins/fixtures/polls.xml
new file mode 100644
index 0000000000..2960d640a9
--- /dev/null
+++ b/tests/text_reparser/plugins/fixtures/polls.xml
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<dataset>
+ <table name="phpbb_posts">
+ <column>post_id</column>
+ <column>enable_bbcode</column>
+ <column>enable_smilies</column>
+ <column>enable_magic_url</column>
+ <column>post_text</column>
+ <column>bbcode_uid</column>
+ <row>
+ <value>1</value>
+ <value>0</value>
+ <value>0</value>
+ <value>0</value>
+ <value></value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>1</value>
+ <value>0</value>
+ <value>0</value>
+ <value></value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>3</value>
+ <value>0</value>
+ <value>1</value>
+ <value>0</value>
+ <value></value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>4</value>
+ <value>0</value>
+ <value>0</value>
+ <value>1</value>
+ <value></value>
+ <value>abcd1234</value>
+ </row>
+ </table>
+ <table name="phpbb_topics">
+ <column>topic_id</column>
+ <column>topic_first_post_id</column>
+ <column>poll_title</column>
+ <row>
+ <value>1</value>
+ <value>1</value>
+ <value>This row should be [b]ignored[/b]</value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>1</value>
+ <value>[b]Not bold[/b] :) http://example.org</value>
+ </row>
+ <row>
+ <value>3</value>
+ <value>2</value>
+ <value>[b:abcd1234]Bold[/b:abcd1234] :) http://example.org</value>
+ </row>
+ <row>
+ <value>4</value>
+ <value>3</value>
+ <value><![CDATA[[b]Not bold[/b] <!-- s:) --><img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" /><!-- s:) --> http://example.org]]></value>
+ </row>
+ <row>
+ <value>5</value>
+ <value>4</value>
+ <value><![CDATA[[b]Not bold[/b] :) <!-- m --><a class="postlink" href="http://example.org">http://example.org</a><!-- m -->]]></value>
+ </row>
+ <row>
+ <value>6</value>
+ <value>2</value>
+ <value><![CDATA[[flash=123,345:abcd1234]http&#58;//example&#46;org/flash&#46;swf[/flash:abcd1234]]]></value>
+ </row>
+ <row>
+ <value>7</value>
+ <value>1</value>
+ <value><![CDATA[[flash=123,345]http://example.org/flash.swf[/flash]]]></value>
+ </row>
+ <row>
+ <value>8</value>
+ <value>2</value>
+ <value><![CDATA[[img:abcd1234]http&#58;//example&#46;org/img&#46;png[/img:abcd1234]]]></value>
+ </row>
+ <row>
+ <value>9</value>
+ <value>1</value>
+ <value><![CDATA[[img]http://example.org/img.png[/img]]]></value>
+ </row>
+ <row>
+ <value>1000</value>
+ <value>1</value>
+ <value>This row should be [b]ignored[/b]</value>
+ </row>
+ </table>
+</dataset>
diff --git a/tests/text_reparser/plugins/fixtures/posts.xml b/tests/text_reparser/plugins/fixtures/posts.xml
new file mode 100644
index 0000000000..ec31747ed9
--- /dev/null
+++ b/tests/text_reparser/plugins/fixtures/posts.xml
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<dataset>
+ <table name="phpbb_posts">
+ <column>post_id</column>
+ <column>enable_bbcode</column>
+ <column>enable_smilies</column>
+ <column>enable_magic_url</column>
+ <column>post_text</column>
+ <column>bbcode_uid</column>
+ <row>
+ <value>1</value>
+ <value>1</value>
+ <value>1</value>
+ <value>1</value>
+ <value>This row should be [b]ignored[/b]</value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>0</value>
+ <value>0</value>
+ <value>0</value>
+ <value>[b]Not bold[/b] :) http://example.org</value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>3</value>
+ <value>1</value>
+ <value>0</value>
+ <value>0</value>
+ <value>[b:abcd1234]Bold[/b:abcd1234] :) http://example.org</value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>4</value>
+ <value>0</value>
+ <value>1</value>
+ <value>0</value>
+ <value><![CDATA[[b]Not bold[/b] <!-- s:) --><img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" /><!-- s:) --> http://example.org]]></value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>5</value>
+ <value>0</value>
+ <value>0</value>
+ <value>1</value>
+ <value><![CDATA[[b]Not bold[/b] :) <!-- m --><a class="postlink" href="http://example.org">http://example.org</a><!-- m -->]]></value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>6</value>
+ <value>1</value>
+ <value>1</value>
+ <value>0</value>
+ <value><![CDATA[[flash=123,345:abcd1234]http&#58;//example&#46;org/flash&#46;swf[/flash:abcd1234]]]></value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>7</value>
+ <value>1</value>
+ <value>1</value>
+ <value>0</value>
+ <value><![CDATA[[flash=123,345]http://example.org/flash.swf[/flash]]]></value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>8</value>
+ <value>1</value>
+ <value>1</value>
+ <value>0</value>
+ <value><![CDATA[[img:abcd1234]http&#58;//example&#46;org/img&#46;png[/img:abcd1234]]]></value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>9</value>
+ <value>1</value>
+ <value>1</value>
+ <value>0</value>
+ <value><![CDATA[[img]http://example.org/img.png[/img]]]></value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>1000</value>
+ <value>1</value>
+ <value>1</value>
+ <value>1</value>
+ <value>This row should be [b]ignored[/b]</value>
+ <value>abcd1234</value>
+ </row>
+ </table>
+</dataset>
diff --git a/tests/text_reparser/plugins/fixtures/privmsgs.xml b/tests/text_reparser/plugins/fixtures/privmsgs.xml
new file mode 100644
index 0000000000..4049b9890a
--- /dev/null
+++ b/tests/text_reparser/plugins/fixtures/privmsgs.xml
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<dataset>
+ <table name="phpbb_privmsgs">
+ <column>msg_id</column>
+ <column>enable_bbcode</column>
+ <column>enable_smilies</column>
+ <column>enable_magic_url</column>
+ <column>message_text</column>
+ <column>bbcode_uid</column>
+ <column>to_address</column>
+ <column>bcc_address</column>
+ <row>
+ <value>1</value>
+ <value>1</value>
+ <value>1</value>
+ <value>1</value>
+ <value>This row should be [b]ignored[/b]</value>
+ <value>abcd1234</value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>0</value>
+ <value>0</value>
+ <value>0</value>
+ <value>[b]Not bold[/b] :) http://example.org</value>
+ <value>abcd1234</value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>3</value>
+ <value>1</value>
+ <value>0</value>
+ <value>0</value>
+ <value>[b:abcd1234]Bold[/b:abcd1234] :) http://example.org</value>
+ <value>abcd1234</value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>4</value>
+ <value>0</value>
+ <value>1</value>
+ <value>0</value>
+ <value><![CDATA[[b]Not bold[/b] <!-- s:) --><img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" /><!-- s:) --> http://example.org]]></value>
+ <value>abcd1234</value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>5</value>
+ <value>0</value>
+ <value>0</value>
+ <value>1</value>
+ <value><![CDATA[[b]Not bold[/b] :) <!-- m --><a class="postlink" href="http://example.org">http://example.org</a><!-- m -->]]></value>
+ <value>abcd1234</value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>6</value>
+ <value>1</value>
+ <value>1</value>
+ <value>0</value>
+ <value><![CDATA[[flash=123,345:abcd1234]http&#58;//example&#46;org/flash&#46;swf[/flash:abcd1234]]]></value>
+ <value>abcd1234</value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>7</value>
+ <value>1</value>
+ <value>1</value>
+ <value>0</value>
+ <value><![CDATA[[flash=123,345]http://example.org/flash.swf[/flash]]]></value>
+ <value>abcd1234</value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>8</value>
+ <value>1</value>
+ <value>1</value>
+ <value>0</value>
+ <value><![CDATA[[img:abcd1234]http&#58;//example&#46;org/img&#46;png[/img:abcd1234]]]></value>
+ <value>abcd1234</value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>9</value>
+ <value>1</value>
+ <value>1</value>
+ <value>0</value>
+ <value><![CDATA[[img]http://example.org/img.png[/img]]]></value>
+ <value>abcd1234</value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>1000</value>
+ <value>1</value>
+ <value>1</value>
+ <value>1</value>
+ <value>This row should be [b]ignored[/b]</value>
+ <value>abcd1234</value>
+ <value></value>
+ <value></value>
+ </row>
+ </table>
+</dataset>
diff --git a/tests/text_reparser/plugins/fixtures/users.xml b/tests/text_reparser/plugins/fixtures/users.xml
new file mode 100644
index 0000000000..60c623b6b1
--- /dev/null
+++ b/tests/text_reparser/plugins/fixtures/users.xml
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<dataset>
+ <table name="phpbb_users">
+ <column>user_id</column>
+ <column>user_permissions</column>
+ <column>username_clean</column>
+ <column>user_options</column>
+ <column>user_sig</column>
+ <column>user_sig_bbcode_uid</column>
+ <row>
+ <value>1</value>
+ <value></value>
+ <value>user1</value>
+ <value>230271</value>
+ <value>This row should be [b]ignored[/b]</value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>2</value>
+ <value></value>
+ <value>user2</value>
+ <value>895</value>
+ <value>[b]Not bold[/b] :) http://example.org</value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>3</value>
+ <value></value>
+ <value>user3</value>
+ <value>33663</value>
+ <value>[b:abcd1234]Bold[/b:abcd1234] :) http://example.org</value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>4</value>
+ <value></value>
+ <value>user4</value>
+ <value>66431</value>
+ <value><![CDATA[[b]Not bold[/b] <!-- s:) --><img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" /><!-- s:) --> http://example.org]]></value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>5</value>
+ <value></value>
+ <value>user5</value>
+ <value>131967</value>
+ <value><![CDATA[[b]Not bold[/b] :) <!-- m --><a class="postlink" href="http://example.org">http://example.org</a><!-- m -->]]></value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>6</value>
+ <value></value>
+ <value>user6</value>
+ <value>99199</value>
+ <value><![CDATA[[flash=123,345:abcd1234]http&#58;//example&#46;org/flash&#46;swf[/flash:abcd1234]]]></value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>7</value>
+ <value></value>
+ <value>user7</value>
+ <value>99199</value>
+ <value><![CDATA[[flash=123,345]http://example.org/flash.swf[/flash]]]></value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>8</value>
+ <value></value>
+ <value>user8</value>
+ <value>99199</value>
+ <value><![CDATA[[img:abcd1234]http&#58;//example&#46;org/img&#46;png[/img:abcd1234]]]></value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>9</value>
+ <value></value>
+ <value>user9</value>
+ <value>99199</value>
+ <value><![CDATA[[img]http://example.org/img.png[/img]]]></value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>1000</value>
+ <value></value>
+ <value>user1000</value>
+ <value>230271</value>
+ <value>This row should be [b]ignored[/b]</value>
+ <value>abcd1234</value>
+ </row>
+ </table>
+</dataset>
diff --git a/tests/text_reparser/plugins/forum_description_test.php b/tests/text_reparser/plugins/forum_description_test.php
new file mode 100644
index 0000000000..57166e6a3c
--- /dev/null
+++ b/tests/text_reparser/plugins/forum_description_test.php
@@ -0,0 +1,26 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+include_once __DIR__ . '/test_row_based_plugin.php';
+
+class phpbb_textreparser_forum_description_test extends phpbb_textreparser_test_row_based_plugin
+{
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(__DIR__ . '/fixtures/forums.xml');
+ }
+
+ protected function get_reparser()
+ {
+ return new \phpbb\textreparser\plugins\forum_description($this->db, FORUMS_TABLE);
+ }
+}
diff --git a/tests/text_reparser/plugins/forum_rules_test.php b/tests/text_reparser/plugins/forum_rules_test.php
new file mode 100644
index 0000000000..72e4e98876
--- /dev/null
+++ b/tests/text_reparser/plugins/forum_rules_test.php
@@ -0,0 +1,26 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+include_once __DIR__ . '/test_row_based_plugin.php';
+
+class phpbb_textreparser_forum_rules_test extends phpbb_textreparser_test_row_based_plugin
+{
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(__DIR__ . '/fixtures/forums.xml');
+ }
+
+ protected function get_reparser()
+ {
+ return new \phpbb\textreparser\plugins\forum_rules($this->db, FORUMS_TABLE);
+ }
+}
diff --git a/tests/text_reparser/plugins/group_description_test.php b/tests/text_reparser/plugins/group_description_test.php
new file mode 100644
index 0000000000..babfc7e02f
--- /dev/null
+++ b/tests/text_reparser/plugins/group_description_test.php
@@ -0,0 +1,26 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+include_once __DIR__ . '/test_row_based_plugin.php';
+
+class phpbb_textreparser_group_description_test extends phpbb_textreparser_test_row_based_plugin
+{
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(__DIR__ . '/fixtures/groups.xml');
+ }
+
+ protected function get_reparser()
+ {
+ return new \phpbb\textreparser\plugins\group_description($this->db, GROUPS_TABLE);
+ }
+}
diff --git a/tests/text_reparser/plugins/pm_text_test.php b/tests/text_reparser/plugins/pm_text_test.php
new file mode 100644
index 0000000000..6dc1a9cb4c
--- /dev/null
+++ b/tests/text_reparser/plugins/pm_text_test.php
@@ -0,0 +1,26 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+include_once __DIR__ . '/test_row_based_plugin.php';
+
+class phpbb_textreparser_pm_text_test extends phpbb_textreparser_test_row_based_plugin
+{
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(__DIR__ . '/fixtures/privmsgs.xml');
+ }
+
+ protected function get_reparser()
+ {
+ return new \phpbb\textreparser\plugins\pm_text($this->db, PRIVMSGS_TABLE);
+ }
+}
diff --git a/tests/text_reparser/plugins/poll_option_test.php b/tests/text_reparser/plugins/poll_option_test.php
new file mode 100644
index 0000000000..dfa3a030ed
--- /dev/null
+++ b/tests/text_reparser/plugins/poll_option_test.php
@@ -0,0 +1,130 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+require_once __DIR__ . '/../../../phpBB/includes/functions.php';
+require_once __DIR__ . '/../../../phpBB/includes/functions_content.php';
+require_once __DIR__ . '/../../test_framework/phpbb_database_test_case.php';
+
+class phpbb_textreparser_poll_option_test extends phpbb_database_test_case
+{
+ protected $db;
+
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(__DIR__ . '/fixtures/poll_options.xml');
+ }
+
+ protected function get_reparser()
+ {
+ return new \phpbb\textreparser\plugins\poll_option($this->db);
+ }
+
+ protected function get_rows()
+ {
+ $sql = 'SELECT topic_id, poll_option_id, poll_option_text
+ FROM ' . POLL_OPTIONS_TABLE . '
+ ORDER BY topic_id, poll_option_id';
+ $result = $this->db->sql_query($sql);
+ $rows = $this->db->sql_fetchrowset($result);
+ $this->db->sql_freeresult($result);
+
+ return $rows;
+ }
+
+ public function setUp()
+ {
+ global $config;
+ if (!isset($config))
+ {
+ $config = new \phpbb\config\config(array());
+ }
+ $this->get_test_case_helpers()->set_s9e_services();
+ $this->db = $this->new_dbal();
+ parent::setUp();
+ }
+
+ public function test_get_max_id()
+ {
+ $reparser = $this->get_reparser();
+ $this->assertEquals(123, $reparser->get_max_id());
+ }
+
+ public function test_dry_run()
+ {
+ $old_rows = $this->get_rows();
+ $reparser = $this->get_reparser();
+ $reparser->disable_save();
+ $reparser->reparse_range(1, 1);
+ $new_rows = $this->get_rows();
+ $this->assertEquals($old_rows, $new_rows);
+ }
+
+ public function testReparse()
+ {
+ $reparser = $this->get_reparser();
+ $reparser->enable_save();
+ $reparser->reparse_range(2, 13);
+ $expected = array(
+ array(
+ 'topic_id' => 1,
+ 'poll_option_id' => 1,
+ 'poll_option_text' => 'This row should be [b]ignored[/b]',
+ ),
+ array(
+ 'topic_id' => 1,
+ 'poll_option_id' => 2,
+ 'poll_option_text' => 'This row should be [b:abcd1234]ignored[/b:abcd1234]',
+ ),
+ array(
+ 'topic_id' => 2,
+ 'poll_option_id' => 1,
+ 'poll_option_text' => '<r><B><s>[b]</s>Bold<e>[/b]</e></B></r>',
+ ),
+ array(
+ 'topic_id' => 2,
+ 'poll_option_id' => 2,
+ 'poll_option_text' => '<r><E>:)</E></r>',
+ ),
+ array(
+ 'topic_id' => 2,
+ 'poll_option_id' => 3,
+ 'poll_option_text' => '<r><URL url="http://example.org">http://example.org</URL></r>',
+ ),
+ array(
+ 'topic_id' => 11,
+ 'poll_option_id' => 1,
+ 'poll_option_text' => '<r><B><s>[b]</s>Bold<e>[/b]</e></B> :) http://example.org</r>',
+ ),
+ array(
+ 'topic_id' => 12,
+ 'poll_option_id' => 1,
+ 'poll_option_text' => '<r>[b]Not bold[/b] <E>:)</E> http://example.org</r>',
+ ),
+ array(
+ 'topic_id' => 13,
+ 'poll_option_id' => 1,
+ 'poll_option_text' => '<r>[b]Not bold[/b] :) <URL url="http://example.org">http://example.org</URL></r>',
+ ),
+ array(
+ 'topic_id' => 123,
+ 'poll_option_id' => 1,
+ 'poll_option_text' => 'This row should be [b]ignored[/b]',
+ ),
+ array(
+ 'topic_id' => 123,
+ 'poll_option_id' => 2,
+ 'poll_option_text' => 'This row should be [b:abcd1234]ignored[/b:abcd1234]',
+ ),
+ );
+ $this->assertEquals($expected, $this->get_rows());
+ }
+}
diff --git a/tests/text_reparser/plugins/poll_title_test.php b/tests/text_reparser/plugins/poll_title_test.php
new file mode 100644
index 0000000000..046b6019c8
--- /dev/null
+++ b/tests/text_reparser/plugins/poll_title_test.php
@@ -0,0 +1,26 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+include_once __DIR__ . '/test_row_based_plugin.php';
+
+class phpbb_textreparser_poll_title_test extends phpbb_textreparser_test_row_based_plugin
+{
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(__DIR__ . '/fixtures/polls.xml');
+ }
+
+ protected function get_reparser()
+ {
+ return new \phpbb\textreparser\plugins\poll_title($this->db, TOPICS_TABLE);
+ }
+}
diff --git a/tests/text_reparser/plugins/post_text_test.php b/tests/text_reparser/plugins/post_text_test.php
new file mode 100644
index 0000000000..8ea71e65f5
--- /dev/null
+++ b/tests/text_reparser/plugins/post_text_test.php
@@ -0,0 +1,26 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+include_once __DIR__ . '/test_row_based_plugin.php';
+
+class phpbb_textreparser_post_text_test extends phpbb_textreparser_test_row_based_plugin
+{
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(__DIR__ . '/fixtures/posts.xml');
+ }
+
+ protected function get_reparser()
+ {
+ return new \phpbb\textreparser\plugins\post_text($this->db, POSTS_TABLE);
+ }
+}
diff --git a/tests/text_reparser/plugins/test_row_based_plugin.php b/tests/text_reparser/plugins/test_row_based_plugin.php
new file mode 100644
index 0000000000..e8218dfdd6
--- /dev/null
+++ b/tests/text_reparser/plugins/test_row_based_plugin.php
@@ -0,0 +1,151 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+require_once __DIR__ . '/../../../phpBB/includes/functions.php';
+require_once __DIR__ . '/../../../phpBB/includes/functions_content.php';
+require_once __DIR__ . '/../../test_framework/phpbb_database_test_case.php';
+
+abstract class phpbb_textreparser_test_row_based_plugin extends phpbb_database_test_case
+{
+ protected $db;
+
+ abstract protected function get_reparser();
+
+ protected function get_rows(array $ids)
+ {
+ $reparser = $this->get_reparser();
+ $columns = $reparser->get_columns();
+
+ $reflection_reparser = new ReflectionClass(get_class($reparser));
+ $table_property = $reflection_reparser->getProperty('table');
+ $table_property->setAccessible(true);
+
+ $sql = 'SELECT ' . $columns['id'] . ' AS id, ' . $columns['text'] . ' AS text
+ FROM ' . $table_property->getValue($reparser) . '
+ WHERE ' . $this->db->sql_in_set($columns['id'], $ids) . '
+ ORDER BY id';
+ $result = $this->db->sql_query($sql);
+ $rows = $this->db->sql_fetchrowset($result);
+ $this->db->sql_freeresult($result);
+
+ return $rows;
+ }
+
+ public function setUp()
+ {
+ global $config;
+ if (!isset($config))
+ {
+ $config = new \phpbb\config\config(array());
+ }
+ $this->get_test_case_helpers()->set_s9e_services();
+ $this->db = $this->new_dbal();
+ parent::setUp();
+ }
+
+ public function test_get_max_id()
+ {
+ $reparser = $this->get_reparser();
+ $this->assertEquals(1000, $reparser->get_max_id());
+ }
+
+ public function test_dry_run()
+ {
+ $old_rows = $this->get_rows(array(1));
+ $reparser = $this->get_reparser();
+ $reparser->disable_save();
+ $reparser->reparse_range(1, 1);
+ $new_rows = $this->get_rows(array(1));
+ $this->assertEquals($old_rows, $new_rows);
+ }
+
+ /**
+ * @dataProvider get_reparse_tests
+ */
+ public function test_reparse($min_id, $max_id, $expected)
+ {
+ $reparser = $this->get_reparser();
+ $reparser->reparse_range($min_id, $max_id);
+
+ $ids = array();
+ foreach ($expected as $row)
+ {
+ $ids[] = $row['id'];
+ }
+
+ $this->assertEquals($expected, $this->get_rows($ids));
+ }
+
+ public function get_reparse_tests()
+ {
+ return array(
+ array(
+ 2,
+ 5,
+ array(
+ array(
+ 'id' => '1',
+ 'text' => 'This row should be [b]ignored[/b]',
+ ),
+ array(
+ 'id' => '2',
+ 'text' => '<t>[b]Not bold[/b] :) http://example.org</t>',
+ ),
+ array(
+ 'id' => '3',
+ 'text' => '<r><B><s>[b]</s>Bold<e>[/b]</e></B> :) http://example.org</r>',
+ ),
+ array(
+ 'id' => '4',
+ 'text' => '<r>[b]Not bold[/b] <E>:)</E> http://example.org</r>',
+ ),
+ array(
+ 'id' => '5',
+ 'text' => '<r>[b]Not bold[/b] :) <URL url="http://example.org">http://example.org</URL></r>',
+ ),
+ array(
+ 'id' => '1000',
+ 'text' => 'This row should be [b]ignored[/b]',
+ ),
+ )
+ ),
+ array(
+ 6,
+ 7,
+ array(
+ array(
+ 'id' => '6',
+ 'text' => '<r><FLASH height="345" url="http://example.org/flash.swf" width="123"><s>[flash=123,345]</s>http://example.org/flash.swf<e>[/flash]</e></FLASH></r>',
+ ),
+ array(
+ 'id' => '7',
+ 'text' => '<t>[flash=123,345]http://example.org/flash.swf[/flash]</t>',
+ ),
+ )
+ ),
+ array(
+ 8,
+ 9,
+ array(
+ array(
+ 'id' => '8',
+ 'text' => '<r><IMG src="http://example.org/img.png"><s>[img]</s>http://example.org/img.png<e>[/img]</e></IMG></r>',
+ ),
+ array(
+ 'id' => '9',
+ 'text' => '<t>[img]http://example.org/img.png[/img]</t>',
+ ),
+ )
+ ),
+ );
+ }
+}
diff --git a/tests/text_reparser/plugins/user_signature_test.php b/tests/text_reparser/plugins/user_signature_test.php
new file mode 100644
index 0000000000..5b66f2788a
--- /dev/null
+++ b/tests/text_reparser/plugins/user_signature_test.php
@@ -0,0 +1,26 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+include_once __DIR__ . '/test_row_based_plugin.php';
+
+class phpbb_textreparser_user_signature_test extends phpbb_textreparser_test_row_based_plugin
+{
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(__DIR__ . '/fixtures/users.xml');
+ }
+
+ protected function get_reparser()
+ {
+ return new \phpbb\textreparser\plugins\user_signature($this->db, USERS_TABLE);
+ }
+}