Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
45 / 45 |
|
100.00% |
7 / 7 |
CRAP | |
100.00% |
1 / 1 |
| phpbb_textreparser_contact_admin_info_test | |
100.00% |
45 / 45 |
|
100.00% |
7 / 7 |
8 | |
100.00% |
1 / 1 |
| getDataSet | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| get_reparser | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| get_rows | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
1 | |||
| setUp | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
2 | |||
| test_get_max_id | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| test_dry_run | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
| test_reparse | |
100.00% |
22 / 22 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * |
| 4 | * This file is part of the phpBB Forum Software package. |
| 5 | * |
| 6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
| 7 | * @license GNU General Public License, version 2 (GPL-2.0) |
| 8 | * |
| 9 | * For full copyright and license information, please see |
| 10 | * the docs/CREDITS.txt file. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | require_once __DIR__ . '/../../test_framework/phpbb_database_test_case.php'; |
| 15 | |
| 16 | class phpbb_textreparser_contact_admin_info_test extends phpbb_database_test_case |
| 17 | { |
| 18 | protected $db; |
| 19 | |
| 20 | public function getDataSet() |
| 21 | { |
| 22 | return $this->createXMLDataSet(__DIR__ . '/fixtures/contact_admin_info.xml'); |
| 23 | } |
| 24 | |
| 25 | protected function get_reparser() |
| 26 | { |
| 27 | return new \phpbb\textreparser\plugins\contact_admin_info(new \phpbb\config\db_text($this->db, CONFIG_TEXT_TABLE)); |
| 28 | } |
| 29 | |
| 30 | protected function get_rows() |
| 31 | { |
| 32 | $sql = 'SELECT config_name, config_value |
| 33 | FROM ' . CONFIG_TEXT_TABLE . ' |
| 34 | ORDER BY config_name'; |
| 35 | $result = $this->db->sql_query($sql); |
| 36 | $rows = $this->db->sql_fetchrowset($result); |
| 37 | $this->db->sql_freeresult($result); |
| 38 | |
| 39 | return $rows; |
| 40 | } |
| 41 | |
| 42 | protected function setUp(): void |
| 43 | { |
| 44 | global $config; |
| 45 | if (!isset($config)) |
| 46 | { |
| 47 | $config = new \phpbb\config\config(array()); |
| 48 | } |
| 49 | $this->get_test_case_helpers()->set_s9e_services(); |
| 50 | $this->db = $this->new_dbal(); |
| 51 | parent::setUp(); |
| 52 | } |
| 53 | |
| 54 | public function test_get_max_id() |
| 55 | { |
| 56 | $reparser = $this->get_reparser(); |
| 57 | $this->assertEquals(1, $reparser->get_max_id()); |
| 58 | } |
| 59 | |
| 60 | public function test_dry_run() |
| 61 | { |
| 62 | $old_rows = $this->get_rows(); |
| 63 | $reparser = $this->get_reparser(); |
| 64 | $reparser->disable_save(); |
| 65 | $reparser->reparse_range(1, 1); |
| 66 | $new_rows = $this->get_rows(); |
| 67 | $this->assertEquals($old_rows, $new_rows); |
| 68 | } |
| 69 | |
| 70 | public function test_reparse() |
| 71 | { |
| 72 | $reparser = $this->get_reparser(); |
| 73 | $reparser->enable_save(); |
| 74 | $reparser->reparse_range(1, 1); |
| 75 | $expected = array( |
| 76 | array( |
| 77 | 'config_name' => 'contact_admin_info', |
| 78 | 'config_value' => '<r><EMAIL email="admin@example.org"><s>[email]</s>admin@example.org<e>[/email]</e></EMAIL></r>', |
| 79 | ), |
| 80 | array( |
| 81 | 'config_name' => 'contact_admin_info_bitfield', |
| 82 | 'config_value' => 'ACA=', |
| 83 | ), |
| 84 | array( |
| 85 | 'config_name' => 'contact_admin_info_flags', |
| 86 | 'config_value' => '7', |
| 87 | ), |
| 88 | array( |
| 89 | 'config_name' => 'contact_admin_info_uid', |
| 90 | 'config_value' => '1a2hbwf5', |
| 91 | ), |
| 92 | ); |
| 93 | $this->assertEquals($expected, $this->get_rows()); |
| 94 | } |
| 95 | } |