diff options
-rw-r--r-- | build/build.xml | 52 | ||||
-rw-r--r-- | phpBB/docs/events.md | 8 | ||||
-rw-r--r-- | phpBB/install/database_update.php | 7 | ||||
-rw-r--r-- | phpBB/language/en/migrator.php | 1 | ||||
-rw-r--r-- | phpBB/phpbb/db/migration/helper.php | 32 | ||||
-rw-r--r-- | phpBB/phpbb/db/migration/tool/config.php | 5 | ||||
-rw-r--r-- | phpBB/phpbb/db/migration/tool/config_text.php | 5 | ||||
-rw-r--r-- | phpBB/phpbb/db/migration/tool/module.php | 5 | ||||
-rw-r--r-- | phpBB/phpbb/db/migration/tool/permission.php | 5 | ||||
-rw-r--r-- | phpBB/phpbb/db/migrator.php | 169 | ||||
-rw-r--r-- | phpBB/phpbb/db/migrator_output_handler_interface.php | 10 | ||||
-rw-r--r-- | phpBB/phpbb/notification/method/messenger_base.php | 2 | ||||
-rw-r--r-- | phpBB/styles/prosilver/template/memberlist_email.html | 2 | ||||
-rw-r--r-- | phpBB/styles/subsilver2/template/memberlist_email.html | 2 | ||||
-rw-r--r-- | tests/dbal/migration/if.php | 4 | ||||
-rw-r--r-- | tests/dbal/migrator_test.php | 8 | ||||
-rw-r--r-- | tests/migrator/reverse_update_data_test.php | 56 |
17 files changed, 275 insertions, 98 deletions
diff --git a/build/build.xml b/build/build.xml index c412a747ac..2bece48edc 100644 --- a/build/build.xml +++ b/build/build.xml @@ -49,7 +49,7 @@ --> <target name="composer"> <exec dir="phpBB" - command="php ../composer.phar install --dev" + command="php ../composer.phar install" checkreturn="true" passthru="true" /> </target> @@ -143,6 +143,7 @@ <phingcall target="export"> <property name="revision" value="release-${version}" /> <property name="dir" value="build/old_versions/release-${version}" /> + <property name="skip-composer" value="true" /> </phingcall> <phingcall target="clean-diff-dir"> @@ -251,26 +252,35 @@ <equals arg1="${composer-has-dependencies}" arg2="1" trim="true" /> <then> <!-- We have non-dev composer dependencies --> - <exec dir="." - command="git ls-tree ${revision} composer.phar" - checkreturn="true" - outputProperty='composer-ls-tree-output' /> <if> - <equals arg1="${composer-ls-tree-output}" arg2="" trim="true" /> + <not><isset property="skip-composer" /></not> <then> - <fail message="There are composer dependencies, but composer.phar is missing." /> - </then> - <else> - <!-- Export the phar, install dependencies, delete phar. --> <exec dir="." - command="git archive ${revision} composer.phar | tar -xf - -C ${dir}" - checkreturn="true" /> - <exec dir="${dir}" - command="php composer.phar install --no-dev --optimize-autoloader" + command="git ls-tree ${revision} composer.phar" checkreturn="true" - passthru="true" /> - <delete file="${dir}/composer.phar" /> - </else> + outputProperty='composer-ls-tree-output' /> + <if> + <equals arg1="${composer-ls-tree-output}" arg2="" trim="true" /> + <then> + <fail message="There are composer dependencies, but composer.phar is missing." /> + </then> + <else> + <!-- Export the phar, install dependencies, delete phar. --> + <exec dir="." + command="git archive ${revision} composer.phar | tar -xf - -C ${dir}" + checkreturn="true" /> + <exec dir="${dir}" + command="php composer.phar install --no-dev --optimize-autoloader" + checkreturn="true" + passthru="true" /> + <delete file="${dir}/composer.phar" /> + + <phingcall target="clean-vendor-dir"> + <property name="dir" value="${dir}" /> + </phingcall> + </else> + </if> + </then> </if> </then> <else> @@ -287,10 +297,6 @@ <delete dir="${dir}/develop" /> <delete dir="${dir}/install/data" /> - <phingcall target="clean-vendor-dir"> - <property name="dir" value="${dir}" /> - </phingcall> - <echo msg="Setting permissions for checkout of ${revision} in ${dir}" /> <!-- set permissions of all files to 644, directories to 755 --> <exec dir="${dir}" command="find . -type f|xargs chmod 644" escape="false" /> @@ -307,6 +313,7 @@ <delete dir="${dir}/vendor/lusitanian/oauth/examples" /> <delete dir="${dir}/vendor/lusitanian/oauth/tests" /> <delete file="${dir}/vendor/lusitanian/oauth/.gitignore" /> + <delete file="${dir}/vendor/lusitanian/oauth/.scrutinizer.yml" /> <delete file="${dir}/vendor/lusitanian/oauth/.travis.yml" /> <delete file="${dir}/vendor/lusitanian/oauth/phpunit.xml.dist" /> <delete file="${dir}/vendor/lusitanian/oauth/README.md" /> @@ -381,10 +388,9 @@ <delete file="${dir}/vendor/twig/twig/.editorconfig" /> <delete file="${dir}/vendor/twig/twig/.gitignore" /> <delete file="${dir}/vendor/twig/twig/.travis.yml" /> - <delete file="${dir}/vendor/twig/twig/AUTHORS" /> <delete file="${dir}/vendor/twig/twig/CHANGELOG" /> <delete file="${dir}/vendor/twig/twig/phpunit.xml.dist" /> - <delete file="${dir}/vendor/twig/twig/README.markdown" /> + <delete file="${dir}/vendor/twig/twig/README.rst" /> </target> <target name="clean-diff-dir"> diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index 1fe8b915f1..0e71bf5c11 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -959,6 +959,14 @@ memberlist_body_username_prepend * Purpose: Add information before every username in the memberlist. Works in all display modes (leader, group and normal memberlist). +memberlist_email_before +=== +* Locations: + + styles/prosilver/template/memberlist_email.html + + styles/subsilver2/template/memberlist_email.html +* Since: 3.1.10-RC1 +* Purpose: Allow adding customizations before the memberlist_email form. + memberlist_search_fields_after === * Locations: diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 0ea6eeffd7..f367ae1fc0 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -211,13 +211,6 @@ while (!$migrator->finished()) phpbb_end_update($cache, $config); } - $state = array_merge(array( - 'migration_schema_done' => false, - 'migration_data_done' => false, - ), - $migrator->last_run_migration['state'] - ); - // Are we approaching the time limit? If so we want to pause the update and continue after refreshing if ((time() - $update_start_time) >= $safe_time_limit) { diff --git a/phpBB/language/en/migrator.php b/phpBB/language/en/migrator.php index 244a5faadf..7623636941 100644 --- a/phpBB/language/en/migrator.php +++ b/phpBB/language/en/migrator.php @@ -50,6 +50,7 @@ $lang = array_merge($lang, array( 'MIGRATION_NOT_FULFILLABLE' => 'The migration "%1$s" is not fulfillable, missing migration "%2$s".', 'MIGRATION_NOT_VALID' => '%s is not a valid migration.', 'MIGRATION_SCHEMA_DONE' => 'Installed Schema: %1$s; Time: %2$.2f seconds', + 'MIGRATION_SCHEMA_IN_PROGRESS' => 'Installing Schema: %1$s; Time: %2$.2f seconds', 'MIGRATION_SCHEMA_RUNNING' => 'Installing Schema: %s.', 'MIGRATION_INVALID_DATA_MISSING_CONDITION' => 'A migration is invalid. An if statement helper is missing a condition.', diff --git a/phpBB/phpbb/db/migration/helper.php b/phpBB/phpbb/db/migration/helper.php index e40deeb37b..bce2efff51 100644 --- a/phpBB/phpbb/db/migration/helper.php +++ b/phpBB/phpbb/db/migration/helper.php @@ -81,4 +81,36 @@ class helper return $steps; } + + /** + * Reverse the update steps from an array of data changes + * + * 'If' statements and custom methods will be skipped, for all + * other calls the reverse method of the tool class will be called + * + * @param array $steps Update changes from migration + * + * @return array + */ + public function reverse_update_data($steps) + { + $reversed_array = array(); + + foreach ($steps as $step) + { + $parts = explode('.', $step[0]); + $parameters = $step[1]; + + $class = $parts[0]; + $method = isset($parts[1]) ? $parts[1] : false; + + if ($class !== 'if' && $class !== 'custom') + { + array_unshift($parameters, $method); + $reversed_array[] = array($class . '.reverse', $parameters); + } + } + + return array_reverse($reversed_array); + } } diff --git a/phpBB/phpbb/db/migration/tool/config.php b/phpBB/phpbb/db/migration/tool/config.php index f93e7118c4..33aa8ff026 100644 --- a/phpBB/phpbb/db/migration/tool/config.php +++ b/phpBB/phpbb/db/migration/tool/config.php @@ -150,6 +150,11 @@ class config implements \phpbb\db\migration\tool\tool_interface $arguments[0], ); break; + + case 'reverse': + // Reversing a reverse is just the call itself + $call = array_shift($arguments); + break; } if ($call) diff --git a/phpBB/phpbb/db/migration/tool/config_text.php b/phpBB/phpbb/db/migration/tool/config_text.php index bf8ac55023..54b45f6f6d 100644 --- a/phpBB/phpbb/db/migration/tool/config_text.php +++ b/phpBB/phpbb/db/migration/tool/config_text.php @@ -115,6 +115,11 @@ class config_text implements \phpbb\db\migration\tool\tool_interface $arguments[] = ''; } break; + + case 'reverse': + // Reversing a reverse is just the call itself + $call = array_shift($arguments); + break; } if ($call) diff --git a/phpBB/phpbb/db/migration/tool/module.php b/phpBB/phpbb/db/migration/tool/module.php index 035625b095..59719db9a4 100644 --- a/phpBB/phpbb/db/migration/tool/module.php +++ b/phpBB/phpbb/db/migration/tool/module.php @@ -454,6 +454,11 @@ class module implements \phpbb\db\migration\tool\tool_interface case 'remove': $call = 'add'; break; + + case 'reverse': + // Reversing a reverse is just the call itself + $call = array_shift($arguments); + break; } if ($call) diff --git a/phpBB/phpbb/db/migration/tool/permission.php b/phpBB/phpbb/db/migration/tool/permission.php index ceff6d7d5a..9688420025 100644 --- a/phpBB/phpbb/db/migration/tool/permission.php +++ b/phpBB/phpbb/db/migration/tool/permission.php @@ -637,6 +637,11 @@ class permission implements \phpbb\db\migration\tool\tool_interface $arguments[0], ); break; + + case 'reverse': + // Reversing a reverse is just the call itself + $call = array_shift($arguments); + break; } if ($call) diff --git a/phpBB/phpbb/db/migrator.php b/phpBB/phpbb/db/migrator.php index 7fc3e787e2..4c4c0a8672 100644 --- a/phpBB/phpbb/db/migrator.php +++ b/phpBB/phpbb/db/migrator.php @@ -80,14 +80,14 @@ class migrator * * @var array */ - public $last_run_migration = false; + protected $last_run_migration = false; /** * The output handler. A null handler is configured by default. * * @var migrator_output_handler_interface */ - public $output_handler; + protected $output_handler; /** * Constructor of the database migrator @@ -152,6 +152,7 @@ class migrator $this->migration_state[$migration['migration_name']] = $migration; $this->migration_state[$migration['migration_name']]['migration_depends_on'] = unserialize($migration['migration_depends_on']); + $this->migration_state[$migration['migration_name']]['migration_data_state'] = !empty($migration['migration_data_state']) ? unserialize($migration['migration_data_state']) : ''; } } @@ -161,6 +162,19 @@ class migrator } /** + * Get an array with information about the last migration run. + * + * The array contains 'name', 'class' and 'state'. 'effectively_installed' is set + * and set to true if the last migration was effectively_installed. + * + * @return array + */ + public function get_last_run_migration() + { + return $this->last_run_migration; + } + + /** * Sets the list of available migration class names to the given array. * * @param array $class_names An array of migration class names @@ -297,38 +311,70 @@ class migrator if (!$state['migration_schema_done']) { - $this->output_handler->write(array('MIGRATION_SCHEMA_RUNNING', $name), migrator_output_handler_interface::VERBOSITY_VERBOSE); + $verbosity = empty($state['migration_data_state']) ? + migrator_output_handler_interface::VERBOSITY_VERBOSE : migrator_output_handler_interface::VERBOSITY_DEBUG; + $this->output_handler->write(array('MIGRATION_SCHEMA_RUNNING', $name), $verbosity); $this->last_run_migration['task'] = 'process_schema_step'; + + $total_time = (is_array($state['migration_data_state']) && isset($state['migration_data_state']['_total_time'])) ? + $state['migration_data_state']['_total_time'] : 0.0; $elapsed_time = microtime(true); + $steps = $this->helper->get_schema_steps($migration->update_schema()); $result = $this->process_data_step($steps, $state['migration_data_state']); + $elapsed_time = microtime(true) - $elapsed_time; + $total_time += $elapsed_time; + + if (is_array($result)) + { + $result['_total_time'] = $total_time; + } $state['migration_data_state'] = ($result === true) ? '' : $result; $state['migration_schema_done'] = ($result === true); - $this->output_handler->write(array('MIGRATION_SCHEMA_DONE', $name, $elapsed_time), migrator_output_handler_interface::VERBOSITY_NORMAL); + if ($state['migration_schema_done']) + { + $this->output_handler->write(array('MIGRATION_SCHEMA_DONE', $name, $total_time), migrator_output_handler_interface::VERBOSITY_NORMAL); + } + else + { + $this->output_handler->write(array('MIGRATION_SCHEMA_IN_PROGRESS', $name, $elapsed_time), migrator_output_handler_interface::VERBOSITY_VERY_VERBOSE); + } } else if (!$state['migration_data_done']) { try { - $this->output_handler->write(array('MIGRATION_DATA_RUNNING', $name), migrator_output_handler_interface::VERBOSITY_VERBOSE); + $verbosity = empty($state['migration_data_state']) ? + migrator_output_handler_interface::VERBOSITY_VERBOSE : migrator_output_handler_interface::VERBOSITY_DEBUG; + $this->output_handler->write(array('MIGRATION_DATA_RUNNING', $name), $verbosity); $this->last_run_migration['task'] = 'process_data_step'; + $total_time = (is_array($state['migration_data_state']) && isset($state['migration_data_state']['_total_time'])) ? + $state['migration_data_state']['_total_time'] : 0.0; $elapsed_time = microtime(true); + $result = $this->process_data_step($migration->update_data(), $state['migration_data_state']); + $elapsed_time = microtime(true) - $elapsed_time; + $total_time += $elapsed_time; + + if (is_array($result)) + { + $result['_total_time'] = $total_time; + } $state['migration_data_state'] = ($result === true) ? '' : $result; $state['migration_data_done'] = ($result === true); $state['migration_end_time'] = ($result === true) ? time() : 0; - if ($state['migration_schema_done']) + if ($state['migration_data_done']) { - $this->output_handler->write(array('MIGRATION_DATA_DONE', $name, $elapsed_time), migrator_output_handler_interface::VERBOSITY_NORMAL); + $this->output_handler->write(array('MIGRATION_DATA_DONE', $name, $total_time), migrator_output_handler_interface::VERBOSITY_NORMAL); } else { @@ -337,10 +383,12 @@ class migrator } catch (\phpbb\db\migration\exception $e) { - // Revert the schema changes + // Reset data state and revert the schema changes + $state['migration_data_state'] = ''; + $this->set_migration_state($name, $state); + $this->revert_do($name); - // Rethrow exception throw $e; } } @@ -416,19 +464,11 @@ class migrator if ($state['migration_data_done']) { - if ($state['migration_data_state'] !== 'revert_data') - { - $result = $this->process_data_step($migration->update_data(), $state['migration_data_state'], true); - - $state['migration_data_state'] = ($result === true) ? 'revert_data' : $result; - } - else - { - $result = $this->process_data_step($migration->revert_data(), '', false); + $steps = array_merge($this->helper->reverse_update_data($migration->update_data()), $migration->revert_data()); + $result = $this->process_data_step($steps, $state['migration_data_state']); - $state['migration_data_state'] = ($result === true) ? '' : $result; - $state['migration_data_done'] = ($result === true) ? false : true; - } + $state['migration_data_state'] = ($result === true) ? '' : $result; + $state['migration_data_done'] = ($result === true) ? false : true; $this->set_migration_state($name, $state); } @@ -446,8 +486,13 @@ class migrator WHERE migration_name = '" . $this->db->sql_escape($name) . "'"; $this->db->sql_query($sql); + $this->last_run_migration = false; unset($this->migration_state[$name]); } + else + { + $this->set_migration_state($name, $state); + } } return true; @@ -464,7 +509,12 @@ class migrator */ protected function process_data_step($steps, $state, $revert = false) { - $state = ($state) ? unserialize($state) : false; + if (sizeof($steps) === 0) + { + return true; + } + + $state = is_array($state) ? $state : false; // reverse order of steps if reverting if ($revert === true) @@ -472,54 +522,45 @@ class migrator $steps = array_reverse($steps); } - foreach ($steps as $step_identifier => $step) + $step = $last_result = 0; + if ($state) { - $last_result = 0; - if ($state) - { - // Continue until we reach the step that matches the last step called - if ($state['step'] != $step_identifier) - { - continue; - } - - // We send the result from last time to the callable function - $last_result = $state['result']; + $step = $state['step']; - // Set state to false since we reached the point we were at - $state = false; - } + // We send the result from last time to the callable function + $last_result = $state['result']; + } - try + try + { + // Result will be null or true if everything completed correctly + // Stop after each update step, to let the updater control the script runtime + $result = $this->run_step($steps[$step], $last_result, $revert); + if (($result !== null && $result !== true) || $step + 1 < sizeof($steps)) { - // Result will be null or true if everything completed correctly - $result = $this->run_step($step, $last_result, $revert); - if ($result !== null && $result !== true) - { - return serialize(array( - 'result' => $result, - 'step' => $step_identifier, - )); - } + return array( + 'result' => $result, + // Move on if the last call finished + 'step' => ($result !== null && $result !== true) ? $step : $step + 1, + ); } - catch (\phpbb\db\migration\exception $e) + } + catch (\phpbb\db\migration\exception $e) + { + // We should try rolling back here + foreach ($steps as $reverse_step_identifier => $reverse_step) { - // We should try rolling back here - foreach ($steps as $reverse_step_identifier => $reverse_step) + // If we've reached the current step we can break because we reversed everything that was run + if ($reverse_step_identifier == $step) { - // If we've reached the current step we can break because we reversed everything that was run - if ($reverse_step_identifier == $step_identifier) - { - break; - } - - // Reverse the step that was run - $result = $this->run_step($reverse_step, false, !$revert); + break; } - // rethrow the exception - throw $e; + // Reverse the step that was run + $result = $this->run_step($reverse_step, false, !$revert); } + + throw $e; } return true; @@ -587,6 +628,13 @@ class migrator throw new \phpbb\db\migration\exception('MIGRATION_INVALID_DATA_MISSING_STEP', $step); } + if ($reverse) + { + // We might get unexpected results when trying + // to revert this, so just avoid it + return false; + } + $condition = $parameters[0]; if (!$condition) @@ -664,6 +712,7 @@ class migrator { $migration_row = $state; $migration_row['migration_depends_on'] = serialize($state['migration_depends_on']); + $migration_row['migration_data_state'] = !empty($state['migration_data_state']) ? serialize($state['migration_data_state']) : ''; if (isset($this->migration_state[$name])) { diff --git a/phpBB/phpbb/db/migrator_output_handler_interface.php b/phpBB/phpbb/db/migrator_output_handler_interface.php index a923af99f6..9947b51dcc 100644 --- a/phpBB/phpbb/db/migrator_output_handler_interface.php +++ b/phpBB/phpbb/db/migrator_output_handler_interface.php @@ -15,11 +15,11 @@ namespace phpbb\db; interface migrator_output_handler_interface { - const VERBOSITY_QUIET = 0; - const VERBOSITY_NORMAL = 1; - const VERBOSITY_VERBOSE = 2; - const VERBOSITY_VERY_VERBOSE = 3; - const VERBOSITY_DEBUG = 4; + const VERBOSITY_QUIET = 16; + const VERBOSITY_NORMAL = 32; + const VERBOSITY_VERBOSE = 64; + const VERBOSITY_VERY_VERBOSE = 128; + const VERBOSITY_DEBUG = 256; /** * Write output using the configured closure. diff --git a/phpBB/phpbb/notification/method/messenger_base.php b/phpBB/phpbb/notification/method/messenger_base.php index 3c6d617c66..0bfbfd6b02 100644 --- a/phpBB/phpbb/notification/method/messenger_base.php +++ b/phpBB/phpbb/notification/method/messenger_base.php @@ -81,7 +81,7 @@ abstract class messenger_base extends \phpbb\notification\method\base $messenger->assign_vars(array_merge(array( 'USERNAME' => $user['username'], - 'U_NOTIFICATION_SETTINGS' => generate_board_url() . '/ucp.' . $this->php_ext . '?i=ucp_notifications&mode=notification_options', + 'U_NOTIFICATION_SETTINGS' => generate_board_url() . '/ucp.' . $this->php_ext . '?i=ucp_notifications&mode=notification_options', ), $notification->get_email_template_variables())); $messenger->send($notify_method); diff --git a/phpBB/styles/prosilver/template/memberlist_email.html b/phpBB/styles/prosilver/template/memberlist_email.html index 4a9f764d07..eea699da08 100644 --- a/phpBB/styles/prosilver/template/memberlist_email.html +++ b/phpBB/styles/prosilver/template/memberlist_email.html @@ -1,5 +1,7 @@ <!-- INCLUDE overall_header.html --> +<!-- EVENT memberlist_email_before --> + <!-- IF S_CONTACT_ADMIN--> <h2 class="titlespace">{L_CONTACT_ADMIN}</h2> <!-- ELSEIF S_SEND_USER --> diff --git a/phpBB/styles/subsilver2/template/memberlist_email.html b/phpBB/styles/subsilver2/template/memberlist_email.html index 78ab3e4b8d..04f36b2244 100644 --- a/phpBB/styles/subsilver2/template/memberlist_email.html +++ b/phpBB/styles/subsilver2/template/memberlist_email.html @@ -1,5 +1,7 @@ <!-- INCLUDE overall_header.html --> +<!-- EVENT memberlist_email_before --> + <div id="pagecontent"> <form action="{S_POST_ACTION}" method="post" name="postform"> diff --git a/tests/dbal/migration/if.php b/tests/dbal/migration/if.php index 98a66526ed..481250ea77 100644 --- a/tests/dbal/migration/if.php +++ b/tests/dbal/migration/if.php @@ -36,13 +36,13 @@ class phpbb_dbal_migration_if extends \phpbb\db\migration\migration { global $migrator_test_if_true_failed; - $migrator_test_if_true_failed = false; + $migrator_test_if_true_failed = !$migrator_test_if_true_failed; } function test_false() { global $migrator_test_if_false_failed; - $migrator_test_if_false_failed = true; + $migrator_test_if_false_failed = !$migrator_test_if_false_failed; } } diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php index 4c4306888c..798200eef1 100644 --- a/tests/dbal/migrator_test.php +++ b/tests/dbal/migrator_test.php @@ -156,6 +156,14 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case $this->assertFalse($migrator_test_if_true_failed, 'True test failed'); $this->assertFalse($migrator_test_if_false_failed, 'False test failed'); + + while ($this->migrator->migration_state('phpbb_dbal_migration_if') !== false) + { + $this->migrator->revert('phpbb_dbal_migration_if'); + } + + $this->assertFalse($migrator_test_if_true_failed, 'True test after revert failed'); + $this->assertFalse($migrator_test_if_false_failed, 'False test after revert failed'); } public function test_recall() diff --git a/tests/migrator/reverse_update_data_test.php b/tests/migrator/reverse_update_data_test.php new file mode 100644 index 0000000000..b85e48c64c --- /dev/null +++ b/tests/migrator/reverse_update_data_test.php @@ -0,0 +1,56 @@ +<?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. + * + */ + +class reverse_update_data_test extends phpbb_test_case +{ + /** @var \phpbb\db\migration\helper */ + protected $helper; + + public function setUp() + { + parent::setUp(); + + $this->helper = new \phpbb\db\migration\helper(); + } + + public function update_data_provider() + { + return array( + array( + array( + array('config.add', array('foobar', 1)), + array('if', array( + (false === true), + array('permission.add', array('some_data')), + )), + array('config.remove', array('foobar')), + array('custom', array(array($this, 'foo_bar'))), + array('tool.method', array('test_data')), + ), + array( + array('tool.reverse', array('method', 'test_data')), + array('config.reverse', array('remove', 'foobar')), + array('config.reverse', array('add', 'foobar', 1)), + ), + ), + ); + } + + /** + * @dataProvider update_data_provider + */ + public function test_get_schema_steps($data_changes, $expected) + { + $this->assertEquals($expected, $this->helper->reverse_update_data($data_changes)); + } +} |