mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/12561] Added test for "after"
PHPBB3-12561
This commit is contained in:
parent
9ddf02243e
commit
05839f8599
2 changed files with 48 additions and 0 deletions
31
tests/dbal/migration/dummy_order.php
Normal file
31
tests/dbal/migration/dummy_order.php
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package testing
|
||||||
|
* @copyright (c) 2014 phpBB Group
|
||||||
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
class phpbb_dbal_migration_dummy_order extends \phpbb\db\migration\migration
|
||||||
|
{
|
||||||
|
function update_schema()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'add_tables' => 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'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,6 +7,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../dbal/migration/dummy_order.php';
|
||||||
|
|
||||||
class schmema_generator_test extends phpbb_test_case
|
class schmema_generator_test extends phpbb_test_case
|
||||||
{
|
{
|
||||||
public function setUp()
|
public function setUp()
|
||||||
|
@ -46,4 +48,19 @@ class schmema_generator_test extends phpbb_test_case
|
||||||
|
|
||||||
$this->assertArrayHasKey('phpbb_users', $this->generator->get_schema());
|
$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.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue