diff options
| author | Tristan Darricau <tristan.darricau@sensiolabs.com> | 2015-07-07 17:25:28 +0200 |
|---|---|---|
| committer | Tristan Darricau <tristan.darricau@sensiolabs.com> | 2015-07-07 17:25:28 +0200 |
| commit | 2fbfb0e00436acc090a55e1739cf8bdd3b5c4497 (patch) | |
| tree | 03bda2fcceca020ddc486ded2aafe32ae0c33d4b /tests/text_reparser/plugins/test_row_based_plugin.php | |
| parent | 39d3a026fe30c9ca3b276039e673cec0548e1eff (diff) | |
| parent | cf4cdcda586a2371aa92ae452951f9660737ae09 (diff) | |
| download | forums-2fbfb0e00436acc090a55e1739cf8bdd3b5c4497.tar forums-2fbfb0e00436acc090a55e1739cf8bdd3b5c4497.tar.gz forums-2fbfb0e00436acc090a55e1739cf8bdd3b5c4497.tar.bz2 forums-2fbfb0e00436acc090a55e1739cf8bdd3b5c4497.tar.xz forums-2fbfb0e00436acc090a55e1739cf8bdd3b5c4497.zip | |
Merge pull request #3744 from s9e/ticket/13987
[ticket/13987] Add --dry-run option to reparser CLI
Diffstat (limited to 'tests/text_reparser/plugins/test_row_based_plugin.php')
| -rw-r--r-- | tests/text_reparser/plugins/test_row_based_plugin.php | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/tests/text_reparser/plugins/test_row_based_plugin.php b/tests/text_reparser/plugins/test_row_based_plugin.php index befcb48bda..bbae44c8e0 100644 --- a/tests/text_reparser/plugins/test_row_based_plugin.php +++ b/tests/text_reparser/plugins/test_row_based_plugin.php @@ -20,6 +20,21 @@ abstract class phpbb_textreparser_test_row_based_plugin extends phpbb_database_t abstract protected function get_reparser(); + protected function get_rows(array $ids) + { + $reparser = $this->get_reparser(); + $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); + + return $rows; + } + public function setUp() { global $config; @@ -38,10 +53,20 @@ abstract class phpbb_textreparser_test_row_based_plugin extends phpbb_database_t $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 getReparseTests + * @dataProvider get_reparse_tests */ - public function testReparse($min_id, $max_id, $expected) + public function test_reparse($min_id, $max_id, $expected) { $reparser = $this->get_reparser(); $reparser->reparse_range($min_id, $max_id); @@ -52,18 +77,10 @@ abstract class phpbb_textreparser_test_row_based_plugin extends phpbb_database_t $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); + $this->assertEquals($expected, $this->get_rows($ids)); } - public function getReparseTests() + public function get_reparse_tests() { return array( array( |
