aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshyPHP <s9e.dev@gmail.com>2015-05-06 21:32:39 +0200
committerJoshyPHP <s9e.dev@gmail.com>2015-05-30 17:26:00 +0200
commita870f8f8603993a2d6a2443c8ad746212071f392 (patch)
treee85e418ac086de7fb68da60e1736b32ce12c4e7b
parent212fc277b481440a99ff0483e5fbc40c790e8dda (diff)
downloadforums-a870f8f8603993a2d6a2443c8ad746212071f392.tar
forums-a870f8f8603993a2d6a2443c8ad746212071f392.tar.gz
forums-a870f8f8603993a2d6a2443c8ad746212071f392.tar.bz2
forums-a870f8f8603993a2d6a2443c8ad746212071f392.tar.xz
forums-a870f8f8603993a2d6a2443c8ad746212071f392.zip
[ticket/13803] Added user_signature tests
PHPBB3-13803
-rw-r--r--phpBB/phpbb/textreparser/plugins/user_signature.php27
-rw-r--r--tests/text_reparser/fixtures/users.xml91
-rw-r--r--tests/text_reparser/forum_description_test.php2
-rw-r--r--tests/text_reparser/forum_rules_test.php2
-rw-r--r--tests/text_reparser/pm_text_test.php2
-rw-r--r--tests/text_reparser/post_text_test.php2
-rw-r--r--tests/text_reparser/test_row_based_plugin.php2
-rw-r--r--tests/text_reparser/user_signature_test.php26
8 files changed, 138 insertions, 16 deletions
diff --git a/phpBB/phpbb/textreparser/plugins/user_signature.php b/phpBB/phpbb/textreparser/plugins/user_signature.php
index db82d4089b..f657a45d38 100644
--- a/phpBB/phpbb/textreparser/plugins/user_signature.php
+++ b/phpBB/phpbb/textreparser/plugins/user_signature.php
@@ -22,21 +22,15 @@ class user_signature extends \phpbb\textreparser\row_based_plugin
protected $keyoptions;
/**
- * Constructor
- *
- * Retrieves and saves the bit numbers used for user options
- */
- public function __construct()
- {
- $class_vars = get_class_vars('phpbb\\user');
- $this->keyoptions = $class_vars['keyoptions'];
- }
-
- /**
* {@inheritdoc}
*/
protected function add_missing_fields(array $row)
{
+ if (!isset($this->keyoptions))
+ {
+ $this->save_keyoptions();
+ }
+
$options = $row['user_options'];
$row += array(
'enable_bbcode' => phpbb_optionget($this->keyoptions['sig_bbcode'], $options),
@@ -44,7 +38,7 @@ class user_signature extends \phpbb\textreparser\row_based_plugin
'enable_magic_url' => phpbb_optionget($this->keyoptions['sig_links'], $options),
);
- return $row;
+ return parent::add_missing_fields($row);
}
/**
@@ -67,4 +61,13 @@ class user_signature extends \phpbb\textreparser\row_based_plugin
{
return USERS_TABLE;
}
+
+ /**
+ * Save the keyoptions var from \phpbb\user
+ */
+ protected function save_keyoptions()
+ {
+ $class_vars = get_class_vars('phpbb\\user');
+ $this->keyoptions = $class_vars['keyoptions'];
+ }
}
diff --git a/tests/text_reparser/fixtures/users.xml b/tests/text_reparser/fixtures/users.xml
new file mode 100644
index 0000000000..60c623b6b1
--- /dev/null
+++ b/tests/text_reparser/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/forum_description_test.php b/tests/text_reparser/forum_description_test.php
index 66ed261a6f..3b739353cd 100644
--- a/tests/text_reparser/forum_description_test.php
+++ b/tests/text_reparser/forum_description_test.php
@@ -19,7 +19,7 @@ class phpbb_textreparser_forum_description_test extends phpbb_textreparser_test_
return $this->createXMLDataSet(__DIR__ . '/fixtures/forums.xml');
}
- public function get_reparser()
+ protected function get_reparser()
{
return new \phpbb\textreparser\plugins\forum_description($this->db);
}
diff --git a/tests/text_reparser/forum_rules_test.php b/tests/text_reparser/forum_rules_test.php
index c89f47cf8e..4c267c9014 100644
--- a/tests/text_reparser/forum_rules_test.php
+++ b/tests/text_reparser/forum_rules_test.php
@@ -19,7 +19,7 @@ class phpbb_textreparser_forum_rules_test extends phpbb_textreparser_test_row_ba
return $this->createXMLDataSet(__DIR__ . '/fixtures/forums.xml');
}
- public function get_reparser()
+ protected function get_reparser()
{
return new \phpbb\textreparser\plugins\forum_rules($this->db);
}
diff --git a/tests/text_reparser/pm_text_test.php b/tests/text_reparser/pm_text_test.php
index 6b409d27e3..3896a57e98 100644
--- a/tests/text_reparser/pm_text_test.php
+++ b/tests/text_reparser/pm_text_test.php
@@ -19,7 +19,7 @@ class phpbb_textreparser_pm_text_test extends phpbb_textreparser_test_row_based_
return $this->createXMLDataSet(__DIR__ . '/fixtures/privmsgs.xml');
}
- public function get_reparser()
+ protected function get_reparser()
{
return new \phpbb\textreparser\plugins\pm_text($this->db);
}
diff --git a/tests/text_reparser/post_text_test.php b/tests/text_reparser/post_text_test.php
index ac540f170c..0f934a06ee 100644
--- a/tests/text_reparser/post_text_test.php
+++ b/tests/text_reparser/post_text_test.php
@@ -19,7 +19,7 @@ class phpbb_textreparser_post_text_test extends phpbb_textreparser_test_row_base
return $this->createXMLDataSet(__DIR__ . '/fixtures/posts.xml');
}
- public function get_reparser()
+ protected function get_reparser()
{
return new \phpbb\textreparser\plugins\post_text($this->db);
}
diff --git a/tests/text_reparser/test_row_based_plugin.php b/tests/text_reparser/test_row_based_plugin.php
index 0258745bf2..4d4d64a56d 100644
--- a/tests/text_reparser/test_row_based_plugin.php
+++ b/tests/text_reparser/test_row_based_plugin.php
@@ -18,6 +18,8 @@ abstract class phpbb_textreparser_test_row_based_plugin extends phpbb_database_t
{
protected $db;
+ abstract protected function get_reparser();
+
public function setUp()
{
global $config;
diff --git a/tests/text_reparser/user_signature_test.php b/tests/text_reparser/user_signature_test.php
new file mode 100644
index 0000000000..ab830a303d
--- /dev/null
+++ b/tests/text_reparser/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);
+ }
+}