diff options
Diffstat (limited to 'tests/text_reparser')
22 files changed, 1499 insertions, 0 deletions
| diff --git a/tests/text_reparser/base_test.php b/tests/text_reparser/base_test.php new file mode 100644 index 0000000000..af2d56ea51 --- /dev/null +++ b/tests/text_reparser/base_test.php @@ -0,0 +1,69 @@ +<?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__ . '/../test_framework/phpbb_database_test_case.php'; + +class phpbb_textreparser_base_test extends phpbb_database_test_case +{ +	protected $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 getDataSet() +	{ +		return $this->createXMLDataSet(__DIR__ . '/fixtures/base.xml'); +	} + +	protected function get_reparser() +	{ +		return new \phpbb\textreparser\plugins\post_text($this->db, POSTS_TABLE); +	} + +	protected function get_rows(array $ids) +	{ +		$sql = 'SELECT post_id AS id, post_text AS text +			FROM ' . POSTS_TABLE . ' +			WHERE ' . $this->db->sql_in_set('post_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 test_reparse_empty() +	{ +		$this->get_reparser()->reparse_range(1, 1); + +		$this->assertEquals( +			array( +				array( +					'id'   => 1, +					'text' => '<t></t>' +				) +			), +			$this->get_rows(array(1)) +		); +	} +} diff --git a/tests/text_reparser/fixtures/base.xml b/tests/text_reparser/fixtures/base.xml new file mode 100644 index 0000000000..a4921a8823 --- /dev/null +++ b/tests/text_reparser/fixtures/base.xml @@ -0,0 +1,19 @@ +<?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></value> +			<value>abcd1234</value> +		</row> +	</table> +</dataset> diff --git a/tests/text_reparser/fixtures/config_text.xml b/tests/text_reparser/fixtures/config_text.xml new file mode 100644 index 0000000000..ba8e1fcfcc --- /dev/null +++ b/tests/text_reparser/fixtures/config_text.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<dataset> +	<table name="phpbb_config_text"> +		<column>config_name</column> +		<column>config_value</column> +	</table> +</dataset> diff --git a/tests/text_reparser/manager_test.php b/tests/text_reparser/manager_test.php new file mode 100644 index 0000000000..df6adacb66 --- /dev/null +++ b/tests/text_reparser/manager_test.php @@ -0,0 +1,117 @@ +<?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__ . '/../mock/container_builder.php'; +require_once __DIR__ . '/../test_framework/phpbb_database_test_case.php'; + +class phpbb_text_reparser_manager_test extends phpbb_database_test_case +{ +	/** @var \phpbb\config\config */ +	protected $config; + +	/** @var \phpbb\config\db_text */ +	protected $config_text; + +	/** @var \phpbb\textreparser\manager */ +	protected $reparser_manager; + +	public function getDataSet() +	{ +		return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config_text.xml'); +	} + +	public function setUp() +	{ +		parent::setUp(); + +		$this->config = new \phpbb\config\config(array( +			'test_reparser_cron_interval'	=> 0, +			'my_reparser_cron_interval'		=> 100, +		)); + +		$db = $this->new_dbal(); +		$this->config_text = new \phpbb\config\db_text($db, 'phpbb_config_text'); + +		$service_collection = new \phpbb\di\service_collection(new phpbb_mock_container_builder()); +		$service_collection->add('test_reparser'); +		$service_collection->add('another_reparser'); +		$service_collection->add('my_reparser'); + +		$this->reparser_manager = new \phpbb\textreparser\manager($this->config, $this->config_text, $service_collection); +	} + +	public function test_get_resume_data() +	{ +		$resume_data = array( +			'test_reparser'	=> array( +				'range-min'		=> 0, +				'range-max'		=> 100, +				'range-size'	=> 50, +			), +		); +		$this->config_text->set('reparser_resume', serialize($resume_data)); + +		$this->assert_array_content_equals($resume_data['test_reparser'], $this->reparser_manager->get_resume_data('test_reparser')); +		$this->assertEmpty($this->reparser_manager->get_resume_data('another_reparser')); +	} + +	public function test_update_resume_data() +	{ +		$resume_data = array( +			'test_reparser'	=> array( +				'range-min'		=> 0, +				'range-max'		=> 100, +				'range-size'	=> 50, +			), +		); +		$this->config_text->set('reparser_resume', serialize($resume_data)); + +		$this->reparser_manager->update_resume_data('another_reparser', 5, 20, 10, false); +		$this->assert_array_content_equals($resume_data, unserialize($this->config_text->get('reparser_resume'))); + +		$this->reparser_manager->update_resume_data('test_reparser', 0, 50, 50); +		$resume_data = array( +			'test_reparser'	=> array( +				'range-min'		=> 0, +				'range-max'		=> 50, +				'range-size'	=> 50, +			), +			'another_reparser'	=> array( +				'range-min'		=> 5, +				'range-max'		=> 20, +				'range-size'	=> 10, +			), +		); +		$this->assert_array_content_equals($resume_data, unserialize($this->config_text->get('reparser_resume'))); +	} + +	public function test_schedule() +	{ +		$this->reparser_manager->schedule('no_reparser', 21); +		$this->assertArrayNotHasKey('no_reparser_cron_interval', $this->config); + +		$this->reparser_manager->schedule('another_reparser', 42); +		$this->assertArrayNotHasKey('another_reparser_cron_interval', $this->config); + +		$this->reparser_manager->schedule('test_reparser', 20); +		$this->assertEquals(20, $this->config['test_reparser_cron_interval']); +	} + +	public function test_schedule_all() +	{ +		$this->reparser_manager->schedule_all(180); +		$this->assertEquals(180, $this->config['test_reparser_cron_interval']); +		$this->assertEquals(180, $this->config['my_reparser_cron_interval']); +		$this->assertArrayNotHasKey('another_reparser_cron_interval', $this->config); +	} +} 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..757b02be39 --- /dev/null +++ b/tests/text_reparser/plugins/contact_admin_info_test.php @@ -0,0 +1,95 @@ +<?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__ . '/../../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.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://example.org/flash.swf[/flash:abcd1234]]]></value> +			<value>abcd1234</value> +			<value>1</value> +			<value><![CDATA[[flash=123,345:abcd1234]http://example.org/flash.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://example.org/img.png[/img:abcd1234]]]></value> +			<value>abcd1234</value> +			<value>1</value> +			<value><![CDATA[[img:abcd1234]http://example.org/img.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://example.org/flash.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://example.org/img.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://example.org/flash.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://example.org/img.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://example.org/flash.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://example.org/img.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://example.org/flash.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://example.org/img.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://example.org/flash.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://example.org/img.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..177faac51d --- /dev/null +++ b/tests/text_reparser/plugins/poll_option_test.php @@ -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__ . '/../../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..3e9ff09448 --- /dev/null +++ b/tests/text_reparser/plugins/test_row_based_plugin.php @@ -0,0 +1,150 @@ +<?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__ . '/../../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); +	} +} | 
