1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

Merge pull request #2474 from PayBas/ticket/12561

[ticket/12561] Add "after" check to schema_generator for columns_add

* PayBas/ticket/12561:
  [ticket/12561] Reworked tests by nickvergessen
  [ticket/12561] Added tests for "after last", "after missing" and "empty"
  [ticket/12561] Add check to see if "after" column actually exists
  [ticket/12561] Added test for "after"
  [ticket/12561] Add "after" check to schema_generator for columns_add
This commit is contained in:
Joas Schilling
2014-05-28 23:33:25 +02:00
9 changed files with 264 additions and 2 deletions

View File

@@ -11,8 +11,19 @@
*
*/
class schmema_generator_test extends phpbb_test_case
require_once __DIR__ . '/../dbal/migration/dummy_order.php';
require_once __DIR__ . '/../dbal/migration/dummy_order_0.php';
require_once __DIR__ . '/../dbal/migration/dummy_order_1.php';
require_once __DIR__ . '/../dbal/migration/dummy_order_2.php';
require_once __DIR__ . '/../dbal/migration/dummy_order_3.php';
require_once __DIR__ . '/../dbal/migration/dummy_order_4.php';
require_once __DIR__ . '/../dbal/migration/dummy_order_5.php';
class schema_generator_test extends phpbb_test_case
{
/** @var \phpbb\db\migration\schema_generator */
protected $generator;
public function setUp()
{
parent::setUp();
@@ -50,4 +61,78 @@ class schmema_generator_test extends phpbb_test_case
$this->assertArrayHasKey('phpbb_users', $this->generator->get_schema());
}
public function column_add_after_data()
{
return array(
array(
'phpbb_dbal_migration_dummy_order_0',
array(
'foobar1',
'foobar2',
'foobar3',
),
),
array(
'phpbb_dbal_migration_dummy_order_1',
array(
'foobar1',
'foobar3',
'foobar4',
),
),
array(
'phpbb_dbal_migration_dummy_order_2',
array(
'foobar1',
'foobar3',
'foobar5',
),
),
array(
'phpbb_dbal_migration_dummy_order_3',
array(
'foobar1',
'foobar3',
'foobar6',
),
),
array(
'phpbb_dbal_migration_dummy_order_4',
array(
'foobar1',
'foobar3',
'foobar7',
),
),
array(
'phpbb_dbal_migration_dummy_order_5',
array(
'foobar1',
'foobar3',
'foobar9',
'foobar8',
),
),
);
}
/**
* @dataProvider column_add_after_data
*/
public function test_column_add_after($migration, $expected)
{
$this->get_schema_generator(array(
'phpbb_dbal_migration_dummy_order',
$migration,
));
$tables = $this->generator->get_schema();
$this->assertEquals(
$expected,
array_keys($tables[$this->table_prefix . 'column_order_test1']['COLUMNS']),
'The schema generator could not position the column correctly, using the "after" option in the migration script.'
);
}
}