From 2c878ead311b8b71cabb4070ce848d5b84470ce8 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 3 Feb 2014 15:06:43 -0600 Subject: [ticket/11880] Break up schema changes in the migrator PHPBB3-11880 --- tests/migrator/get_schema_steps_test.php | 163 +++++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 tests/migrator/get_schema_steps_test.php (limited to 'tests/migrator') diff --git a/tests/migrator/get_schema_steps_test.php b/tests/migrator/get_schema_steps_test.php new file mode 100644 index 0000000000..c37d55ea40 --- /dev/null +++ b/tests/migrator/get_schema_steps_test.php @@ -0,0 +1,163 @@ + array('table1', 'table2', 'table3'), + 'drop_tables' => array('table1', 'table2', 'table3'), + 'add_index' => array( + 'table1' => array( + 'index1' => 'column1', + 'index2' => 'column2', + ), + 'table2' => array( + 'index1' => 'column1', + 'index2' => 'column2', + ), + ), + 'add_columns' => array( + 'table1' => array( + 'column1' => array('foo'), + 'column2' => array('bar'), + ), + ), + 'change_columns' => array( + 'table1' => array( + 'column1' => array('foo'), + 'column2' => array('bar'), + ), + ), + 'drop_columns' => array( + 'table1' => array( + 'column1', + 'column2', + ), + ), + 'add_unique_index' => array( + 'table1' => array( + 'index1' => 'column1', + 'index2' => 'column2', + ), + ), + 'drop_keys' => array( + 'table1' => array( + 'column1', + 'column2', + ), + ), + 'add_primary_keys' => array( + 'table1' => array('foo'), + 'table2' => array('bar'), + 'table3' => array('foobar'), + ), + ), + array( + array('dbtools.perform_schema_changes', array(array('drop_tables' => array('table1')))), + array('dbtools.perform_schema_changes', array(array('drop_tables' => array('table2')))), + array('dbtools.perform_schema_changes', array(array('drop_tables' => array('table3')))), + array('dbtools.perform_schema_changes', array(array('add_tables' => array('table1')))), + array('dbtools.perform_schema_changes', array(array('add_tables' => array('table2')))), + array('dbtools.perform_schema_changes', array(array('add_tables' => array('table3')))), + array('dbtools.perform_schema_changes', array(array('change_columns' => array( + 'table1' => array( + 'column1' => array('foo'), + ), + )))), + array('dbtools.perform_schema_changes', array(array('change_columns' => array( + 'table1' => array( + 'column2' => array('bar'), + ), + )))), + array('dbtools.perform_schema_changes', array(array('add_columns' => array( + 'table1' => array( + 'column1' => array('foo'), + ), + )))), + array('dbtools.perform_schema_changes', array(array('add_columns' => array( + 'table1' => array( + 'column2' => array('bar'), + ), + )))), + array('dbtools.perform_schema_changes', array(array('drop_keys' => array( + 'table1' => array( + 0 => 'column1', + ), + )))), + array('dbtools.perform_schema_changes', array(array('drop_keys' => array( + 'table1' => array( + 1 => 'column2', + ), + )))), + array('dbtools.perform_schema_changes', array(array('drop_columns' => array( + 'table1' => array( + 0 => 'column1', + ), + )))), + array('dbtools.perform_schema_changes', array(array('drop_columns' => array( + 'table1' => array( + 1 => 'column2', + ), + )))), + array('dbtools.perform_schema_changes', array(array('add_primary_keys' => array( + 'table1' => array('foo'), + )))), + array('dbtools.perform_schema_changes', array(array('add_primary_keys' => array( + 'table2' => array('bar'), + )))), + array('dbtools.perform_schema_changes', array(array('add_primary_keys' => array( + 'table3' => array('foobar'), + )))), + array('dbtools.perform_schema_changes', array(array('add_unique_index' => array( + 'table1' => array( + 'index1' => 'column1', + ), + )))), + array('dbtools.perform_schema_changes', array(array('add_unique_index' => array( + 'table1' => array( + 'index2' => 'column2', + ), + )))), + array('dbtools.perform_schema_changes', array(array('add_index' => array( + 'table1' => array( + 'index1' => 'column1', + ), + )))), + array('dbtools.perform_schema_changes', array(array('add_index' => array( + 'table1' => array( + 'index2' => 'column2', + ), + )))), + array('dbtools.perform_schema_changes', array(array('add_index' => array( + 'table2' => array( + 'index1' => 'column1', + ), + )))), + array('dbtools.perform_schema_changes', array(array('add_index' => array( + 'table2' => array( + 'index2' => 'column2', + ), + )))), + ), + ), + ); + } + + /** + * @dataProvider schema_provider + */ + public function test_get_schema_steps($schema_changes, $expected) + { + $this->assertEquals($expected, \phpbb\db\migrator::get_schema_steps($schema_changes)); + } +} -- cgit v1.2.1