1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

[ticket/13803] Moved tests to a subdir

PHPBB3-13803
This commit is contained in:
JoshyPHP
2015-05-29 17:36:06 +02:00
parent c8052ea823
commit 132282634f
18 changed files with 9 additions and 9 deletions

View File

@@ -0,0 +1,81 @@
<?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));
}
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 testReparse()
{
$reparser = $this->get_reparser();
$reparser->reparse_range(1, 1);
$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);
$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, $rows);
}
}

View File

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

View File

@@ -0,0 +1,91 @@
<?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_rules</column>
<column>forum_rules_uid</column>
<row>
<value>1</value>
<value></value>
<value>This row should be [b]ignored[/b]</value>
<value>abcd1234</value>
<value>This row should be [b]ignored[/b]</value>
<value>abcd1234</value>
</row>
<row>
<value>2</value>
<value></value>
<value>[b]Not bold[/b] :) http://example.org</value>
<value>abcd1234</value>
<value>[b]Not bold[/b] :) http://example.org</value>
<value>abcd1234</value>
</row>
<row>
<value>3</value>
<value></value>
<value>[b:abcd1234]Bold[/b:abcd1234] :) http://example.org</value>
<value>abcd1234</value>
<value>[b:abcd1234]Bold[/b:abcd1234] :) http://example.org</value>
<value>abcd1234</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><![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><![CDATA[[b]Not bold[/b] :) <!-- m --><a class="postlink" href="http://example.org">http://example.org</a><!-- m -->]]></value>
<value>abcd1234</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><![CDATA[[flash=123,345:abcd1234]http&#58;//example&#46;org/flash&#46;swf[/flash:abcd1234]]]></value>
<value>abcd1234</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><![CDATA[[flash=123,345]http://example.org/flash.swf[/flash]]]></value>
<value>abcd1234</value>
<value><![CDATA[[flash=123,345]http://example.org/flash.swf[/flash]]]></value>
<value>abcd1234</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><![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><![CDATA[[img]http://example.org/img.png[/img]]]></value>
<value>abcd1234</value>
<value><![CDATA[[img]http://example.org/img.png[/img]]]></value>
<value>abcd1234</value>
</row>
<row>
<value>1000</value>
<value></value>
<value>This row should be [b]ignored[/b]</value>
<value>abcd1234</value>
<value>This row should be [b]ignored[/b]</value>
<value>abcd1234</value>
</row>
</table>
</dataset>

View File

@@ -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>7</value>
<value>abcd1234</value>
</row>
<row>
<value>7</value>
<value><![CDATA[[flash=123,345]http://example.org/flash.swf[/flash]]]></value>
<value>7</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>7</value>
<value>abcd1234</value>
</row>
<row>
<value>9</value>
<value><![CDATA[[img]http://example.org/img.png[/img]]]></value>
<value>7</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>

View File

@@ -0,0 +1,73 @@
<?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>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>post_text</column>
<column>bbcode_uid</column>
<row>
<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>123</value>
<value>1</value>
<value>This row should be [b]ignored[/b]</value>
</row>
</table>
</dataset>

View File

@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8" ?>
<dataset>
<table name="phpbb_posts">
<column>post_id</column>
<column>post_text</column>
<column>bbcode_uid</column>
<row>
<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>1</value>
<value>[b:abcd1234]Bold[/b:abcd1234] :) http://example.org</value>
</row>
<row>
<value>4</value>
<value>1</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>1</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>1</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>1</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>

View File

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

View File

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

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

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

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

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

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

View File

@@ -0,0 +1,100 @@
<?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);
}
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 testReparse()
{
$reparser = $this->get_reparser();
$reparser->reparse_range(2, 3);
$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);
$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' => 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, $rows);
}
}

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

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

View File

@@ -0,0 +1,129 @@
<?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();
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());
}
/**
* @dataProvider getReparseTests
*/
public function testReparse($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'];
}
$columns = $reparser->get_columns();
$sql = 'SELECT ' . $columns['id'] . ' AS id, ' . $columns['text'] . ' AS text
FROM ' . $reparser->get_table_name() . '
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);
$this->assertEquals($expected, $rows);
}
public function getReparseTests()
{
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>',
),
)
),
);
}
}

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