mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-25 11:01:48 +02:00
[ticket/12012] Add a unit test for changing the column type
PHPBB3-12012
This commit is contained in:
@@ -11,7 +11,9 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
|||||||
|
|
||||||
class phpbb_dbal_db_tools_test extends phpbb_database_test_case
|
class phpbb_dbal_db_tools_test extends phpbb_database_test_case
|
||||||
{
|
{
|
||||||
|
/** @var \phpbb\db\driver\driver_interface */
|
||||||
protected $db;
|
protected $db;
|
||||||
|
/** @var \phpbb\db\tools */
|
||||||
protected $tools;
|
protected $tools;
|
||||||
protected $table_exists;
|
protected $table_exists;
|
||||||
protected $table_data;
|
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'));
|
$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()
|
public function test_column_remove()
|
||||||
{
|
{
|
||||||
$this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_int_size'));
|
$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'));
|
$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(
|
$db_tools = $this->getMock('\phpbb\db\tools', array(
|
||||||
'sql_table_exists',
|
'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(
|
$db_tools = $this->getMock('\phpbb\db\tools', array(
|
||||||
'sql_column_exists',
|
'sql_column_exists',
|
||||||
|
Reference in New Issue
Block a user