1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
<?php
/**
*
* @package testing
* @copyright (c) 2014 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
require_once __DIR__ . '/../dbal/migration/dummy_order.php';
class schmema_generator_test extends phpbb_test_case
{
public function setUp()
{
parent::setUp();
$this->config = new \phpbb\config\config(array());
$this->db = new \phpbb\db\driver\sqlite();
$this->db_tools = new \phpbb\db\tools($this->db);
$this->table_prefix = 'phpbb_';
}
protected function get_schema_generator(array $class_names)
{
$this->generator = new \phpbb\db\migration\schema_generator($class_names, $this->config, $this->db, $this->db_tools, $this->phpbb_root_path, $this->php_ext, $this->table_prefix);
return $this->generator;
}
/**
* @expectedException \UnexpectedValueException
*/
public function test_check_dependencies_fail()
{
$this->get_schema_generator(array('\phpbb\db\migration\data\v310\forgot_password'));
$this->generator->get_schema();
}
public function test_get_schema_success()
{
$this->get_schema_generator(array(
'\phpbb\db\migration\data\v30x\release_3_0_1_rc1',
'\phpbb\db\migration\data\v30x\release_3_0_0',
'\phpbb\db\migration\data\v310\boardindex'
));
$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.');
}
}
|