[ticket/13803] Added user_signature tests

PHPBB3-13803
This commit is contained in:
JoshyPHP 2015-05-06 21:32:39 +02:00
parent 212fc277b4
commit a870f8f860
8 changed files with 138 additions and 16 deletions

View file

@ -21,22 +21,16 @@ 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'];
}
}

View file

@ -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>

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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;

View file

@ -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);
}
}