mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 12:28:52 +00:00
[ticket/12561] Reworked tests by nickvergessen
PHPBB3-12561
This commit is contained in:
parent
3cabe5fd79
commit
9f37d414be
8 changed files with 205 additions and 111 deletions
|
@ -21,56 +21,6 @@ class phpbb_dbal_migration_dummy_order extends \phpbb\db\migration\migration
|
||||||
'PRIMARY_KEY' => array('foobar1'),
|
'PRIMARY_KEY' => array('foobar1'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'add_columns' => array(
|
|
||||||
$this->table_prefix . 'column_order_test1' => array(
|
|
||||||
'foobar2' => array('BOOL', 0, 'after' => 'foobar1'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
'add_tables' => array(
|
|
||||||
$this->table_prefix . 'column_order_test2' => array(
|
|
||||||
'COLUMNS' => array(
|
|
||||||
'foobar1' => array('BOOL', 0),
|
|
||||||
'foobar3' => array('BOOL', 0),
|
|
||||||
),
|
|
||||||
'PRIMARY_KEY' => array('foobar1'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
'add_columns' => array(
|
|
||||||
$this->table_prefix . 'column_order_test2' => array(
|
|
||||||
'foobar4' => array('BOOL', 0, 'after' => 'foobar3'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
'add_tables' => array(
|
|
||||||
$this->table_prefix . 'column_order_test3' => array(
|
|
||||||
'COLUMNS' => array(
|
|
||||||
'foobar1' => array('BOOL', 0),
|
|
||||||
'foobar3' => array('BOOL', 0),
|
|
||||||
),
|
|
||||||
'PRIMARY_KEY' => array('foobar1'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
'add_columns' => array(
|
|
||||||
$this->table_prefix . 'column_order_test3' => array(
|
|
||||||
'foobar5' => array('BOOL', 0, 'after' => 'non-existing'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
'add_tables' => array(
|
|
||||||
$this->table_prefix . 'column_order_test4' => array(
|
|
||||||
'COLUMNS' => array(
|
|
||||||
'foobar1' => array('BOOL', 0),
|
|
||||||
'foobar3' => array('BOOL', 0),
|
|
||||||
),
|
|
||||||
'PRIMARY_KEY' => array('foobar1'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
'add_columns' => array(
|
|
||||||
$this->table_prefix . 'column_order_test4' => array(
|
|
||||||
'foobar5' => array('BOOL', 0, 'after' => ''),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
22
tests/dbal/migration/dummy_order_0.php
Normal file
22
tests/dbal/migration/dummy_order_0.php
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?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_0 extends \phpbb\db\migration\migration
|
||||||
|
{
|
||||||
|
function update_schema()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'add_columns' => array(
|
||||||
|
$this->table_prefix . 'column_order_test1' => array(
|
||||||
|
'foobar2' => array('BOOL', 0, 'after' => 'foobar1'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
22
tests/dbal/migration/dummy_order_1.php
Normal file
22
tests/dbal/migration/dummy_order_1.php
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?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_1 extends \phpbb\db\migration\migration
|
||||||
|
{
|
||||||
|
function update_schema()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'add_columns' => array(
|
||||||
|
$this->table_prefix . 'column_order_test1' => array(
|
||||||
|
'foobar4' => array('BOOL', 0, 'after' => 'foobar3'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
22
tests/dbal/migration/dummy_order_2.php
Normal file
22
tests/dbal/migration/dummy_order_2.php
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?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_2 extends \phpbb\db\migration\migration
|
||||||
|
{
|
||||||
|
function update_schema()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'add_columns' => array(
|
||||||
|
$this->table_prefix . 'column_order_test1' => array(
|
||||||
|
'foobar5' => array('BOOL', 0, 'after' => 'non-existing'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
22
tests/dbal/migration/dummy_order_3.php
Normal file
22
tests/dbal/migration/dummy_order_3.php
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?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_3 extends \phpbb\db\migration\migration
|
||||||
|
{
|
||||||
|
function update_schema()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'add_columns' => array(
|
||||||
|
$this->table_prefix . 'column_order_test1' => array(
|
||||||
|
'foobar6' => array('BOOL', 0, 'after' => ''),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
22
tests/dbal/migration/dummy_order_4.php
Normal file
22
tests/dbal/migration/dummy_order_4.php
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?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_4 extends \phpbb\db\migration\migration
|
||||||
|
{
|
||||||
|
function update_schema()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'add_columns' => array(
|
||||||
|
$this->table_prefix . 'column_order_test1' => array(
|
||||||
|
'foobar7' => array('BOOL', 0),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
23
tests/dbal/migration/dummy_order_5.php
Normal file
23
tests/dbal/migration/dummy_order_5.php
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<?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_5 extends \phpbb\db\migration\migration
|
||||||
|
{
|
||||||
|
function update_schema()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'add_columns' => array(
|
||||||
|
$this->table_prefix . 'column_order_test1' => array(
|
||||||
|
'foobar8' => array('BOOL', 0, 'after' => 'foobar3'),
|
||||||
|
'foobar9' => array('BOOL', 0, 'after' => 'foobar3'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,9 +8,18 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once __DIR__ . '/../dbal/migration/dummy_order.php';
|
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 schmema_generator_test extends phpbb_test_case
|
class schema_generator_test extends phpbb_test_case
|
||||||
{
|
{
|
||||||
|
/** @var \phpbb\db\migration\schema_generator */
|
||||||
|
protected $generator;
|
||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
@ -49,75 +58,77 @@ class schmema_generator_test extends phpbb_test_case
|
||||||
$this->assertArrayHasKey('phpbb_users', $this->generator->get_schema());
|
$this->assertArrayHasKey('phpbb_users', $this->generator->get_schema());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected $expected_results_between = array(
|
public function column_add_after_data()
|
||||||
'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(
|
return array(
|
||||||
'phpbb_dbal_migration_dummy_order',
|
array(
|
||||||
));
|
'phpbb_dbal_migration_dummy_order_0',
|
||||||
|
array(
|
||||||
$tables = $this->generator->get_schema();
|
'foobar1',
|
||||||
$columns = $tables[$this->table_prefix . 'column_order_test1']['COLUMNS'];
|
'foobar2',
|
||||||
|
'foobar3',
|
||||||
$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.');
|
),
|
||||||
|
),
|
||||||
|
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',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected $expected_results_after_last = array(
|
/**
|
||||||
'foobar1' => array('BOOL', 0),
|
* @dataProvider column_add_after_data
|
||||||
'foobar3' => array('BOOL', 0),
|
*/
|
||||||
'foobar4' => array('BOOL', 0),
|
public function test_column_add_after($migration, $expected)
|
||||||
);
|
|
||||||
|
|
||||||
public function test_check_column_position_after_last_success()
|
|
||||||
{
|
{
|
||||||
$this->get_schema_generator(array(
|
$this->get_schema_generator(array(
|
||||||
'phpbb_dbal_migration_dummy_order',
|
'phpbb_dbal_migration_dummy_order',
|
||||||
|
$migration,
|
||||||
));
|
));
|
||||||
|
|
||||||
$tables = $this->generator->get_schema();
|
$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.');
|
$this->assertEquals(
|
||||||
}
|
$expected,
|
||||||
|
array_keys($tables[$this->table_prefix . 'column_order_test1']['COLUMNS']),
|
||||||
protected $expected_results_after_missing = array(
|
'The schema generator could not position the column correctly, using the "after" option in the migration script.'
|
||||||
'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_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.');
|
|
||||||
}
|
|
||||||
|
|
||||||
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($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.');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue