aboutsummaryrefslogtreecommitdiffstats
path: root/tests/dbal/db_tools_test.php
diff options
context:
space:
mode:
authorNils Adermann <naderman@naderman.de>2011-08-29 14:24:50 -0400
committerNils Adermann <naderman@naderman.de>2011-08-29 14:24:50 -0400
commit0f2e45800e9e88c86bdf335cac6a9974ec8f0385 (patch)
treefbf7126e6e934c454a9d1dddcd4505b520340733 /tests/dbal/db_tools_test.php
parent0d41385344e5ccf782197798c663e2d9fc26f8d7 (diff)
downloadforums-0f2e45800e9e88c86bdf335cac6a9974ec8f0385.tar
forums-0f2e45800e9e88c86bdf335cac6a9974ec8f0385.tar.gz
forums-0f2e45800e9e88c86bdf335cac6a9974ec8f0385.tar.bz2
forums-0f2e45800e9e88c86bdf335cac6a9974ec8f0385.tar.xz
forums-0f2e45800e9e88c86bdf335cac6a9974ec8f0385.zip
[ticket/10346] Add drop_tables to perform_schema_changes and add tests
PHPBB3-10346
Diffstat (limited to 'tests/dbal/db_tools_test.php')
-rw-r--r--tests/dbal/db_tools_test.php60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php
index ddea500f83..753cc08fc5 100644
--- a/tests/dbal/db_tools_test.php
+++ b/tests/dbal/db_tools_test.php
@@ -271,6 +271,66 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
'foo' => array('UINT', 42)))
);
+ $this->assertTrue($this->tools->sql_table_exists('prefix_test_table'));
+
$this->tools->sql_table_drop('prefix_test_table');
+
+ $this->assertFalse($this->tools->sql_table_exists('prefix_test_table'));
+ }
+
+ public function test_peform_schema_changes_drop_tables()
+ {
+ $db_tools = $this->getMock('phpbb_db_tools', array(
+ 'sql_table_exists',
+ 'sql_table_drop',
+ ), array(&$this->db));
+
+ // pretend all tables exist
+ $db_tools->expects($this->any())->method('sql_table_exists')
+ ->will($this->returnValue(true));
+
+ // drop tables
+ $db_tools->expects($this->exactly(2))->method('sql_table_drop');
+ $db_tools->expects($this->at(1))->method('sql_table_drop')
+ ->with($this->equalTo('dropped_table_1'));
+ $db_tools->expects($this->at(3))->method('sql_table_drop')
+ ->with($this->equalTo('dropped_table_2'));
+
+ $db_tools->perform_schema_changes(array(
+ 'drop_tables' => array(
+ 'dropped_table_1',
+ 'dropped_table_2',
+ ),
+ ));
+ }
+
+ public function test_peform_schema_changes_drop_columns()
+ {
+ $db_tools = $this->getMock('phpbb_db_tools', array(
+ 'sql_column_exists',
+ 'sql_column_remove',
+ ), array(&$this->db));
+
+ // pretend all columns exist
+ $db_tools->expects($this->any())->method('sql_column_exists')
+ ->will($this->returnValue(true));
+ $db_tools->expects($this->any())->method('sql_column_exists')
+ ->will($this->returnValue(true));
+
+ // drop columns
+ $db_tools->expects($this->exactly(2))->method('sql_column_remove');
+ $db_tools->expects($this->at(1))->method('sql_column_remove')
+ ->with($this->equalTo('existing_table'), $this->equalTo('dropped_column_1'));
+ $db_tools->expects($this->at(3))->method('sql_column_remove')
+ ->with($this->equalTo('existing_table'), $this->equalTo('dropped_column_2'));
+
+ $db_tools->perform_schema_changes(array(
+ 'drop_columns' => array(
+ 'existing_table' => array(
+ 'dropped_column_1',
+ 'dropped_column_2',
+ ),
+ ),
+ ));
}
}