aboutsummaryrefslogtreecommitdiffstats
path: root/tests/migrator/schema_generator_test.php
diff options
context:
space:
mode:
authorPayBas <contact@paybas.com>2014-05-26 20:47:19 +0200
committerPayBas <contact@paybas.com>2014-05-26 20:47:19 +0200
commit3cabe5fd792fced4120de02cfef66900b49516c4 (patch)
tree7d15e28481a9c15568a802cfd0d6e39088f35a48 /tests/migrator/schema_generator_test.php
parentc51b926631eb8e339c7a29cf3ff145e9e158b04f (diff)
downloadforums-3cabe5fd792fced4120de02cfef66900b49516c4.tar
forums-3cabe5fd792fced4120de02cfef66900b49516c4.tar.gz
forums-3cabe5fd792fced4120de02cfef66900b49516c4.tar.bz2
forums-3cabe5fd792fced4120de02cfef66900b49516c4.tar.xz
forums-3cabe5fd792fced4120de02cfef66900b49516c4.zip
[ticket/12561] Added tests for "after last", "after missing" and "empty"
Also removed tabs PHPBB3-12561
Diffstat (limited to 'tests/migrator/schema_generator_test.php')
-rw-r--r--tests/migrator/schema_generator_test.php67
1 files changed, 62 insertions, 5 deletions
diff --git a/tests/migrator/schema_generator_test.php b/tests/migrator/schema_generator_test.php
index 4de6064895..c87c4cb904 100644
--- a/tests/migrator/schema_generator_test.php
+++ b/tests/migrator/schema_generator_test.php
@@ -49,18 +49,75 @@ class schmema_generator_test extends phpbb_test_case
$this->assertArrayHasKey('phpbb_users', $this->generator->get_schema());
}
- public function test_check_column_position_success()
+ protected $expected_results_between = array(
+ 'foobar1' => array('BOOL', 0),
+ 'foobar2' => array('BOOL', 0),
+ 'foobar3' => array('BOOL', 0),
+ );
+
+ public function test_check_column_position_between_success()
+ {
+ $this->get_schema_generator(array(
+ 'phpbb_dbal_migration_dummy_order',
+ ));
+
+ $tables = $this->generator->get_schema();
+ $columns = $tables[$this->table_prefix . 'column_order_test1']['COLUMNS'];
+
+ $this->assertEquals($columns, $expected_results_between, 'The schema generator could not position the column correctly between column 1 and 3, using the "after" option in the migration script.');
+ }
+
+ protected $expected_results_after_last = array(
+ 'foobar1' => array('BOOL', 0),
+ 'foobar3' => array('BOOL', 0),
+ 'foobar4' => array('BOOL', 0),
+ );
+
+ public function test_check_column_position_after_last_success()
+ {
+ $this->get_schema_generator(array(
+ 'phpbb_dbal_migration_dummy_order',
+ ));
+
+ $tables = $this->generator->get_schema();
+ $columns = $tables[$this->table_prefix . 'column_order_test2']['COLUMNS'];
+
+ $this->assertEquals($columns, $expected_results_after_last, 'The schema generator could not position the column correctly after the last column, using the "after" option in the migration script.');
+ }
+
+ protected $expected_results_after_missing = array(
+ 'foobar1' => array('BOOL', 0),
+ 'foobar3' => array('BOOL', 0),
+ 'foobar5' => array('BOOL', 0),
+ );
+
+ public function test_check_column_position_after_missing_success()
{
$this->get_schema_generator(array(
'phpbb_dbal_migration_dummy_order',
));
$tables = $this->generator->get_schema();
- $columns = $tables[$this->table_prefix . 'column_order_test']['COLUMNS'];
+ $columns = $tables[$this->table_prefix . 'column_order_test3']['COLUMNS'];
+
+ $this->assertEquals($columns, $expected_results_after_missing, 'The schema generator could not position the column after a "missing" column value, using the "after" option in the migration script.');
+ }
- $offset1 = array_search('foobar1', array_keys($columns));
- $offset2 = array_search('foobar2', array_keys($columns));
+ protected $expected_results_after_empty = array(
+ 'foobar1' => array('BOOL', 0),
+ 'foobar3' => array('BOOL', 0),
+ 'foobar5' => array('BOOL', 0),
+ );
+
+ public function test_check_column_position_after_empty_success()
+ {
+ $this->get_schema_generator(array(
+ 'phpbb_dbal_migration_dummy_order',
+ ));
+
+ $tables = $this->generator->get_schema();
+ $columns = $tables[$this->table_prefix . 'column_order_test4']['COLUMNS'];
- $this->assertEquals($offset1 + 1, $offset2, 'The schema generator could not position the column correctly, using the "after" option in the migration script.');
+ $this->assertEquals($columns, $expected_results_after_empty, 'The schema generator could not position the column after an "empty" column value, using the "after" option in the migration script.');
}
}