aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2014-04-14 16:29:21 +0200
committerJoas Schilling <nickvergessen@gmx.de>2014-04-17 11:29:45 +0200
commita48f1abf6693eaee3343abd4f4a7e6412ecc10d9 (patch)
treef0d8195250fb22854c117e7ffc24c6a18e878fdd /tests
parent190b4282df5c5c81123b1ed371eeada385831e99 (diff)
downloadforums-a48f1abf6693eaee3343abd4f4a7e6412ecc10d9.tar
forums-a48f1abf6693eaee3343abd4f4a7e6412ecc10d9.tar.gz
forums-a48f1abf6693eaee3343abd4f4a7e6412ecc10d9.tar.bz2
forums-a48f1abf6693eaee3343abd4f4a7e6412ecc10d9.tar.xz
forums-a48f1abf6693eaee3343abd4f4a7e6412ecc10d9.zip
[ticket/12012] Add a unit test for changing the column type
PHPBB3-12012
Diffstat (limited to 'tests')
-rw-r--r--tests/dbal/db_tools_test.php32
1 files changed, 30 insertions, 2 deletions
diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php
index e25335165a..0715b09ea3 100644
--- a/tests/dbal/db_tools_test.php
+++ b/tests/dbal/db_tools_test.php
@@ -11,7 +11,9 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
class phpbb_dbal_db_tools_test extends phpbb_database_test_case
{
+ /** @var \phpbb\db\driver\driver_interface */
protected $db;
+ /** @var \phpbb\db\tools */
protected $tools;
protected $table_exists;
protected $table_data;
@@ -207,6 +209,32 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
$this->assertFalse($this->tools->sql_column_exists('prefix_table_name', 'column_does_not_exist'));
}
+ public function test_column_change_with_index()
+ {
+ // Create column
+ $this->assertFalse($this->tools->sql_column_exists('prefix_table_name', 'c_bug_12012'));
+ $this->assertTrue($this->tools->sql_column_add('prefix_table_name', 'c_bug_12012', array('DECIMAL', 0)));
+ $this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_bug_12012'));
+
+ // Create index over the column
+ $this->assertFalse($this->tools->sql_index_exists('prefix_table_name', 'i_bug_12012'));
+ $this->assertTrue($this->tools->sql_create_index('prefix_table_name', 'i_bug_12012', array('c_bug_12012', 'c_bool')));
+ $this->assertTrue($this->tools->sql_index_exists('prefix_table_name', 'i_bug_12012'));
+
+ // Change type from int to string
+ $this->assertTrue($this->tools->sql_column_change('prefix_table_name', 'c_bug_12012', array('VCHAR:100', '')));
+
+ // Remove the index
+ $this->assertTrue($this->tools->sql_index_exists('prefix_table_name', 'i_bug_12012'));
+ $this->assertTrue($this->tools->sql_index_drop('prefix_table_name', 'i_bug_12012'));
+ $this->assertFalse($this->tools->sql_index_exists('prefix_table_name', 'i_bug_12012'));
+
+ // Remove the column
+ $this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_bug_12012'));
+ $this->assertTrue($this->tools->sql_column_remove('prefix_table_name', 'c_bug_12012'));
+ $this->assertFalse($this->tools->sql_column_exists('prefix_table_name', 'c_bug_12012'));
+ }
+
public function test_column_remove()
{
$this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_int_size'));
@@ -252,7 +280,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
$this->assertFalse($this->tools->sql_table_exists('prefix_test_table'));
}
- public function test_peform_schema_changes_drop_tables()
+ public function test_perform_schema_changes_drop_tables()
{
$db_tools = $this->getMock('\phpbb\db\tools', array(
'sql_table_exists',
@@ -278,7 +306,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
));
}
- public function test_peform_schema_changes_drop_columns()
+ public function test_perform_schema_changes_drop_columns()
{
$db_tools = $this->getMock('\phpbb\db\tools', array(
'sql_column_exists',