From 05839f85994c1281936d2dd64215c068e55b6d54 Mon Sep 17 00:00:00 2001 From: PayBas Date: Fri, 23 May 2014 22:24:57 +0200 Subject: [ticket/12561] Added test for "after" PHPBB3-12561 --- tests/dbal/migration/dummy_order.php | 31 +++++++++++++++++++++++++++++++ tests/migrator/schema_generator_test.php | 17 +++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 tests/dbal/migration/dummy_order.php (limited to 'tests') diff --git a/tests/dbal/migration/dummy_order.php b/tests/dbal/migration/dummy_order.php new file mode 100644 index 0000000000..011ac7c1e9 --- /dev/null +++ b/tests/dbal/migration/dummy_order.php @@ -0,0 +1,31 @@ + array( + $this->table_prefix . 'column_order_test' => array( + 'COLUMNS' => array( + 'foobar1' => array('BOOL', 0), + 'foobar3' => array('BOOL', 0), + ), + 'PRIMARY_KEY' => array('foobar1'), + ), + ), + 'add_columns' => array( + $this->table_prefix . 'column_order_test' => array( + 'foobar2' => array('BOOL', 0, 'after' => 'foobar1'), + ), + ), + ); + } +} diff --git a/tests/migrator/schema_generator_test.php b/tests/migrator/schema_generator_test.php index 4bac447229..4de6064895 100644 --- a/tests/migrator/schema_generator_test.php +++ b/tests/migrator/schema_generator_test.php @@ -7,6 +7,8 @@ * */ +require_once __DIR__ . '/../dbal/migration/dummy_order.php'; + class schmema_generator_test extends phpbb_test_case { public function setUp() @@ -46,4 +48,19 @@ class schmema_generator_test extends phpbb_test_case $this->assertArrayHasKey('phpbb_users', $this->generator->get_schema()); } + + public function test_check_column_position_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']; + + $offset1 = array_search('foobar1', array_keys($columns)); + $offset2 = array_search('foobar2', array_keys($columns)); + + $this->assertEquals($offset1 + 1, $offset2, 'The schema generator could not position the column correctly, using the "after" option in the migration script.'); + } } -- cgit v1.2.1