From 132282634ff746c6c4627b87e307df3748f7bbd9 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Fri, 29 May 2015 17:36:06 +0200 Subject: [ticket/13803] Moved tests to a subdir PHPBB3-13803 --- .../plugins/contact_admin_info_test.php | 81 ++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 tests/text_reparser/plugins/contact_admin_info_test.php (limited to 'tests/text_reparser/plugins/contact_admin_info_test.php') 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..e577d2fd3d --- /dev/null +++ b/tests/text_reparser/plugins/contact_admin_info_test.php @@ -0,0 +1,81 @@ + +* @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' => '[email]admin@example.org[/email]', + ), + 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); + } +} -- cgit v1.2.1 From 7ccb6389124c5e990abaa917a6684fc3f4d072db Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Mon, 6 Jul 2015 01:43:43 +0200 Subject: [ticket/13987] Add --dry-run option to reparser CLI PHPBB3-13987 --- .../plugins/contact_admin_info_test.php | 33 +++++++++++++++------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'tests/text_reparser/plugins/contact_admin_info_test.php') diff --git a/tests/text_reparser/plugins/contact_admin_info_test.php b/tests/text_reparser/plugins/contact_admin_info_test.php index e577d2fd3d..e3df1ee2b8 100644 --- a/tests/text_reparser/plugins/contact_admin_info_test.php +++ b/tests/text_reparser/plugins/contact_admin_info_test.php @@ -28,6 +28,18 @@ class phpbb_textreparser_contact_admin_info_test extends phpbb_database_test_cas 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; @@ -46,18 +58,19 @@ class phpbb_textreparser_contact_admin_info_test extends phpbb_database_test_cas $this->assertEquals(1, $reparser->get_max_id()); } - public function testReparse() + public function test_dry_run() { + $old_rows = $this->get_rows(); $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); + $reparser->reparse_range(1, 1, true); + $new_rows = $this->get_rows(); + $this->assertEquals($old_rows, $new_rows); + } + public function test_reparse() + { + $reparser = $this->get_reparser(); + $reparser->reparse_range(1, 1); $expected = array( array( 'config_name' => 'contact_admin_info', @@ -76,6 +89,6 @@ class phpbb_textreparser_contact_admin_info_test extends phpbb_database_test_cas 'config_value' => '1a2hbwf5', ), ); - $this->assertEquals($expected, $rows); + $this->assertEquals($expected, $this->get_rows()); } } -- cgit v1.2.1 From cf4cdcda586a2371aa92ae452951f9660737ae09 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Mon, 6 Jul 2015 01:57:54 +0200 Subject: [ticket/13987] Replaced optional parameter with explicit API Added disable_save() and enable_save() to toggle a dry run PHPBB3-13987 --- tests/text_reparser/plugins/contact_admin_info_test.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests/text_reparser/plugins/contact_admin_info_test.php') diff --git a/tests/text_reparser/plugins/contact_admin_info_test.php b/tests/text_reparser/plugins/contact_admin_info_test.php index e3df1ee2b8..1dc03834b6 100644 --- a/tests/text_reparser/plugins/contact_admin_info_test.php +++ b/tests/text_reparser/plugins/contact_admin_info_test.php @@ -62,7 +62,8 @@ class phpbb_textreparser_contact_admin_info_test extends phpbb_database_test_cas { $old_rows = $this->get_rows(); $reparser = $this->get_reparser(); - $reparser->reparse_range(1, 1, true); + $reparser->disable_save(); + $reparser->reparse_range(1, 1); $new_rows = $this->get_rows(); $this->assertEquals($old_rows, $new_rows); } @@ -70,6 +71,7 @@ class phpbb_textreparser_contact_admin_info_test extends phpbb_database_test_cas public function test_reparse() { $reparser = $this->get_reparser(); + $reparser->enable_save(); $reparser->reparse_range(1, 1); $expected = array( array( -- cgit v1.2.1 From 14e8113fcf01be7dbdb080458fcbf4e75668cc1a Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Thu, 31 Mar 2016 11:06:47 -0700 Subject: [ticket/14576] Move common required files to bootstrap PHPBB3-14576 --- tests/text_reparser/plugins/contact_admin_info_test.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'tests/text_reparser/plugins/contact_admin_info_test.php') diff --git a/tests/text_reparser/plugins/contact_admin_info_test.php b/tests/text_reparser/plugins/contact_admin_info_test.php index 1dc03834b6..757b02be39 100644 --- a/tests/text_reparser/plugins/contact_admin_info_test.php +++ b/tests/text_reparser/plugins/contact_admin_info_test.php @@ -10,8 +10,7 @@ * 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 -- cgit v1.2.1