aboutsummaryrefslogtreecommitdiffstats
path: root/tests/dbal
diff options
context:
space:
mode:
Diffstat (limited to 'tests/dbal')
-rw-r--r--tests/dbal/auto_increment_test.php13
-rw-r--r--tests/dbal/case_test.php73
-rw-r--r--tests/dbal/concatenate_test.php68
-rw-r--r--tests/dbal/connect_test.php14
-rw-r--r--tests/dbal/cross_join_test.php10
-rw-r--r--tests/dbal/db_tools_test.php110
-rw-r--r--tests/dbal/fixtures/massmail_crossjoin.xml8
-rw-r--r--tests/dbal/fixtures/migrator.xml29
-rw-r--r--tests/dbal/fixtures/migrator_config_text.xml7
-rw-r--r--tests/dbal/fixtures/migrator_module.xml133
-rw-r--r--tests/dbal/fixtures/migrator_permission.xml165
-rw-r--r--tests/dbal/fixtures/styles.xml34
-rw-r--r--tests/dbal/fixtures/three_users.xml8
-rw-r--r--tests/dbal/migration/dummy.php31
-rw-r--r--tests/dbal/migration/dummy_order.php30
-rw-r--r--tests/dbal/migration/dummy_order_0.php26
-rw-r--r--tests/dbal/migration/dummy_order_1.php26
-rw-r--r--tests/dbal/migration/dummy_order_2.php26
-rw-r--r--tests/dbal/migration/dummy_order_3.php26
-rw-r--r--tests/dbal/migration/dummy_order_4.php26
-rw-r--r--tests/dbal/migration/dummy_order_5.php27
-rw-r--r--tests/dbal/migration/fail.php45
-rw-r--r--tests/dbal/migration/if.php48
-rw-r--r--tests/dbal/migration/installed.php34
-rw-r--r--tests/dbal/migration/recall.php42
-rw-r--r--tests/dbal/migration/revert.php52
-rw-r--r--tests/dbal/migration/revert_with_dependency.php20
-rw-r--r--tests/dbal/migration/schema.php48
-rw-r--r--tests/dbal/migration/unfulfillable.php30
-rw-r--r--tests/dbal/migrator_test.php315
-rw-r--r--tests/dbal/migrator_tool_config_test.php90
-rw-r--r--tests/dbal/migrator_tool_config_text_test.php75
-rw-r--r--tests/dbal/migrator_tool_module_test.php305
-rw-r--r--tests/dbal/migrator_tool_permission_test.php223
-rw-r--r--tests/dbal/order_lower_test.php39
-rw-r--r--tests/dbal/schema_test.php42
-rw-r--r--tests/dbal/select_test.php86
-rw-r--r--tests/dbal/sql_affected_rows_test.php68
-rw-r--r--tests/dbal/sql_insert_buffer_test.php120
-rw-r--r--tests/dbal/write_sequence_test.php16
-rw-r--r--tests/dbal/write_test.php16
41 files changed, 2512 insertions, 92 deletions
diff --git a/tests/dbal/auto_increment_test.php b/tests/dbal/auto_increment_test.php
index e87fc1c6bd..1ed8ea29e3 100644
--- a/tests/dbal/auto_increment_test.php
+++ b/tests/dbal/auto_increment_test.php
@@ -1,14 +1,17 @@
<?php
/**
*
-* @package testing
-* @copyright (c) 2012 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
*
*/
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
-require_once dirname(__FILE__) . '/../../phpBB/includes/db/db_tools.php';
class phpbb_dbal_auto_increment_test extends phpbb_database_test_case
{
@@ -27,7 +30,7 @@ class phpbb_dbal_auto_increment_test extends phpbb_database_test_case
parent::setUp();
$this->db = $this->new_dbal();
- $this->tools = new phpbb_db_tools($this->db);
+ $this->tools = new \phpbb\db\tools($this->db);
$this->table_data = array(
'COLUMNS' => array(
diff --git a/tests/dbal/case_test.php b/tests/dbal/case_test.php
new file mode 100644
index 0000000000..5f1c7d61fa
--- /dev/null
+++ b/tests/dbal/case_test.php
@@ -0,0 +1,73 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+class phpbb_dbal_case_test extends phpbb_database_test_case
+{
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/config.xml');
+ }
+
+ public function test_case_int()
+ {
+ $db = $this->new_dbal();
+
+ $sql = 'SELECT ' . $db->sql_case('1 = 1', '1', '2') . ' AS test_num
+ FROM phpbb_config';
+ $result = $db->sql_query_limit($sql, 1);
+
+ $this->assertEquals(1, (int) $db->sql_fetchfield('test_num'));
+
+ $sql = 'SELECT ' . $db->sql_case('1 = 0', '1', '2') . ' AS test_num
+ FROM phpbb_config';
+ $result = $db->sql_query_limit($sql, 1);
+
+ $this->assertEquals(2, (int) $db->sql_fetchfield('test_num'));
+ }
+
+ public function test_case_string()
+ {
+ $db = $this->new_dbal();
+
+ $sql = 'SELECT ' . $db->sql_case('1 = 1', "'foo'", "'bar'") . ' AS test_string
+ FROM phpbb_config';
+ $result = $db->sql_query_limit($sql, 1);
+
+ $this->assertEquals('foo', $db->sql_fetchfield('test_string'));
+
+ $sql = 'SELECT ' . $db->sql_case('1 = 0', "'foo'", "'bar'") . ' AS test_string
+ FROM phpbb_config';
+ $result = $db->sql_query_limit($sql, 1);
+
+ $this->assertEquals('bar', $db->sql_fetchfield('test_string'));
+ }
+
+ public function test_case_column()
+ {
+ $db = $this->new_dbal();
+
+ $sql = 'SELECT ' . $db->sql_case("config_name = 'config1'", 'config_name', 'config_value') . " AS test_string
+ FROM phpbb_config
+ WHERE config_name = 'config1'";
+ $result = $db->sql_query_limit($sql, 1);
+
+ $this->assertEquals('config1', $db->sql_fetchfield('test_string'));
+
+ $sql = 'SELECT ' . $db->sql_case("config_name = 'config1'", 'config_name', 'config_value') . " AS test_string
+ FROM phpbb_config
+ WHERE config_value = 'bar'";
+ $result = $db->sql_query_limit($sql, 1);
+
+ $this->assertEquals('bar', $db->sql_fetchfield('test_string'));
+ }
+}
diff --git a/tests/dbal/concatenate_test.php b/tests/dbal/concatenate_test.php
new file mode 100644
index 0000000000..00e7e107aa
--- /dev/null
+++ b/tests/dbal/concatenate_test.php
@@ -0,0 +1,68 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+class phpbb_dbal_concatenate_test extends phpbb_database_test_case
+{
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/config.xml');
+ }
+
+ public function test_concatenate_string()
+ {
+ $db = $this->new_dbal();
+
+ $sql = 'SELECT config_name, ' . $db->sql_concatenate('config_name', "'" . $db->sql_escape('append') . "'") . ' AS string
+ FROM phpbb_config';
+ $result = $db->sql_query($sql);
+
+ $db->sql_return_on_error(false);
+
+ $this->assertEquals(array(
+ array(
+ 'config_name' => 'config1',
+ 'string' => 'config1append',
+ ),
+ array(
+ 'config_name' => 'config2',
+ 'string' => 'config2append',
+ ),
+ ),
+ $db->sql_fetchrowset($result)
+ );
+ }
+
+ public function test_concatenate_statement()
+ {
+ $db = $this->new_dbal();
+
+ $sql = 'SELECT config_name, ' . $db->sql_concatenate('config_name', 'config_value') . ' AS string
+ FROM phpbb_config';
+ $result = $db->sql_query($sql);
+
+ $db->sql_return_on_error(false);
+
+ $this->assertEquals(array(
+ array(
+ 'config_name' => 'config1',
+ 'string' => 'config1foo',
+ ),
+ array(
+ 'config_name' => 'config2',
+ 'string' => 'config2bar',
+ ),
+ ),
+ $db->sql_fetchrowset($result)
+ );
+ }
+}
diff --git a/tests/dbal/connect_test.php b/tests/dbal/connect_test.php
index 505ce28fa1..1ae34bd2b6 100644
--- a/tests/dbal/connect_test.php
+++ b/tests/dbal/connect_test.php
@@ -1,9 +1,13 @@
<?php
/**
*
-* @package testing
-* @copyright (c) 2012 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
*
*/
@@ -22,9 +26,7 @@ class phpbb_dbal_connect_test extends phpbb_database_test_case
$config = $this->get_database_config();
- require_once dirname(__FILE__) . '/../../phpBB/includes/db/' . $config['dbms'] . '.php';
- $dbal = 'dbal_' . $config['dbms'];
- $db = new $dbal();
+ $db = new $config['dbms']();
// Failure to connect results in a trigger_error call in dbal.
// phpunit converts triggered errors to exceptions.
diff --git a/tests/dbal/cross_join_test.php b/tests/dbal/cross_join_test.php
index 6c6b8a8449..7ba937ccc6 100644
--- a/tests/dbal/cross_join_test.php
+++ b/tests/dbal/cross_join_test.php
@@ -1,9 +1,13 @@
<?php
/**
*
-* @package testing
-* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
*
*/
diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php
index c20e46011f..5832b966d8 100644
--- a/tests/dbal/db_tools_test.php
+++ b/tests/dbal/db_tools_test.php
@@ -1,18 +1,23 @@
<?php
/**
*
-* @package testing
-* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
*
*/
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
-require_once dirname(__FILE__) . '/../../phpBB/includes/db/db_tools.php';
class phpbb_dbal_db_tools_test extends phpbb_database_test_case
{
+ /** @var \phpbb\db\driver\driver_interface */
protected $db;
+ /** @var \phpbb\db\tools */
protected $tools;
protected $table_exists;
protected $table_data;
@@ -27,7 +32,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
parent::setUp();
$this->db = $this->new_dbal();
- $this->tools = new phpbb_db_tools($this->db);
+ $this->tools = new \phpbb\db\tools($this->db);
$this->table_data = array(
'COLUMNS' => array(
@@ -41,6 +46,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
'c_bool' => array('BOOL', 1),
'c_vchar' => array('VCHAR', 'foo'),
'c_vchar_size' => array('VCHAR:4', 'foo'),
+ 'c_vchar_null' => array('VCHAR', null),
'c_char_size' => array('CHAR:4', 'foo'),
'c_xstext' => array('XSTEXT', 'foo'),
'c_stext' => array('STEXT', 'foo'),
@@ -106,6 +112,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
'c_bool' => 0,
'c_vchar' => '',
'c_vchar_size' => '',
+ 'c_vchar_null' => null,
'c_char_size' => 'abcd',
'c_xstext' => '',
'c_stext' => '',
@@ -139,6 +146,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
array('c_bool', 0),
array('c_vchar', str_repeat('a', 255)),
array('c_vchar_size', str_repeat('a', 4)),
+ array('c_vchar_null', str_repeat('a', 4)),
array('c_char_size', str_repeat('a', 4)),
array('c_xstext', str_repeat('a', 1000)),
array('c_stext', str_repeat('a', 3000)),
@@ -208,6 +216,50 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
$this->assertFalse($this->tools->sql_column_exists('prefix_table_name', 'column_does_not_exist'));
}
+ public function test_column_change_with_index()
+ {
+ // Create column
+ $this->assertFalse($this->tools->sql_column_exists('prefix_table_name', 'c_bug_12012'));
+ $this->assertTrue($this->tools->sql_column_add('prefix_table_name', 'c_bug_12012', array('DECIMAL', 0)));
+ $this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_bug_12012'));
+
+ // Create index over the column
+ $this->assertFalse($this->tools->sql_index_exists('prefix_table_name', 'i_bug_12012'));
+ $this->assertTrue($this->tools->sql_create_index('prefix_table_name', 'i_bug_12012', array('c_bug_12012', 'c_bool')));
+ $this->assertTrue($this->tools->sql_index_exists('prefix_table_name', 'i_bug_12012'));
+
+ // Change type from int to string
+ $this->assertTrue($this->tools->sql_column_change('prefix_table_name', 'c_bug_12012', array('VCHAR:100', '')));
+
+ // Remove the index
+ $this->assertTrue($this->tools->sql_index_exists('prefix_table_name', 'i_bug_12012'));
+ $this->assertTrue($this->tools->sql_index_drop('prefix_table_name', 'i_bug_12012'));
+ $this->assertFalse($this->tools->sql_index_exists('prefix_table_name', 'i_bug_12012'));
+
+ // Remove the column
+ $this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_bug_12012'));
+ $this->assertTrue($this->tools->sql_column_remove('prefix_table_name', 'c_bug_12012'));
+ $this->assertFalse($this->tools->sql_column_exists('prefix_table_name', 'c_bug_12012'));
+ }
+
+ public function test_column_change_with_composite_primary()
+ {
+ // Remove the old primary key
+ $this->assertTrue($this->tools->sql_column_remove('prefix_table_name', 'c_id'));
+ $this->assertTrue($this->tools->sql_column_add('prefix_table_name', 'c_id', array('UINT', 0)));
+
+ // Create a composite key
+ $this->assertTrue($this->tools->sql_create_primary_key('prefix_table_name', array('c_id', 'c_uint')));
+
+ // Create column
+ $this->assertFalse($this->tools->sql_column_exists('prefix_table_name', 'c_bug_12643'));
+ $this->assertTrue($this->tools->sql_column_add('prefix_table_name', 'c_bug_12643', array('DECIMAL', 0)));
+ $this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_bug_12643'));
+
+ // Change type from int to string
+ $this->assertTrue($this->tools->sql_column_change('prefix_table_name', 'c_bug_12643', array('VCHAR:100', '')));
+ }
+
public function test_column_remove()
{
$this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_int_size'));
@@ -217,6 +269,39 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
$this->assertFalse($this->tools->sql_column_exists('prefix_table_name', 'c_int_size'));
}
+ public function test_column_remove_similar_name()
+ {
+ $this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_vchar'));
+ $this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_vchar_size'));
+
+ $this->assertTrue($this->tools->sql_column_remove('prefix_table_name', 'c_vchar'));
+
+ $this->assertFalse($this->tools->sql_column_exists('prefix_table_name', 'c_vchar'));
+ $this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_vchar_size'));
+ }
+
+ public function test_column_remove_with_index()
+ {
+ // Create column
+ $this->assertFalse($this->tools->sql_column_exists('prefix_table_name', 'c_bug_12012_2'));
+ $this->assertTrue($this->tools->sql_column_add('prefix_table_name', 'c_bug_12012_2', array('UINT', 4)));
+ $this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_bug_12012_2'));
+
+ // Create index over the column
+ $this->assertFalse($this->tools->sql_index_exists('prefix_table_name', 'bug_12012_2'));
+ $this->assertTrue($this->tools->sql_create_index('prefix_table_name', 'bug_12012_2', array('c_bug_12012_2', 'c_bool')));
+ $this->assertTrue($this->tools->sql_index_exists('prefix_table_name', 'bug_12012_2'));
+
+ $this->assertFalse($this->tools->sql_index_exists('prefix_table_name', 'bug_12012_3'));
+ $this->assertTrue($this->tools->sql_create_index('prefix_table_name', 'bug_12012_3', array('c_bug_12012_2')));
+ $this->assertTrue($this->tools->sql_index_exists('prefix_table_name', 'bug_12012_3'));
+
+ // Remove the column
+ $this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_bug_12012_2'));
+ $this->assertTrue($this->tools->sql_column_remove('prefix_table_name', 'c_bug_12012_2'));
+ $this->assertFalse($this->tools->sql_column_exists('prefix_table_name', 'c_bug_12012_2'));
+ }
+
public function test_column_remove_primary()
{
$this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_id'));
@@ -253,9 +338,9 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
$this->assertFalse($this->tools->sql_table_exists('prefix_test_table'));
}
- public function test_peform_schema_changes_drop_tables()
+ public function test_perform_schema_changes_drop_tables()
{
- $db_tools = $this->getMock('phpbb_db_tools', array(
+ $db_tools = $this->getMock('\phpbb\db\tools', array(
'sql_table_exists',
'sql_table_drop',
), array(&$this->db));
@@ -279,9 +364,9 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
));
}
- public function test_peform_schema_changes_drop_columns()
+ public function test_perform_schema_changes_drop_columns()
{
- $db_tools = $this->getMock('phpbb_db_tools', array(
+ $db_tools = $this->getMock('\phpbb\db\tools', array(
'sql_column_exists',
'sql_column_remove',
), array(&$this->db));
@@ -330,4 +415,11 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
$this->tools->sql_create_unique_index('prefix_table_name', 'i_uniq_ts_id', array('c_timestamp', 'c_id'));
$this->assertTrue($this->tools->sql_unique_index_exists('prefix_table_name', 'i_uniq_ts_id'));
}
+
+ public function test_create_int_default_null()
+ {
+ $this->assertFalse($this->tools->sql_column_exists('prefix_table_name', 'c_bug_13282'));
+ $this->assertTrue($this->tools->sql_column_add('prefix_table_name', 'c_bug_13282', array('TINT:2')));
+ $this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_bug_13282'));
+ }
}
diff --git a/tests/dbal/fixtures/massmail_crossjoin.xml b/tests/dbal/fixtures/massmail_crossjoin.xml
index ef0a2b7149..1050ba067e 100644
--- a/tests/dbal/fixtures/massmail_crossjoin.xml
+++ b/tests/dbal/fixtures/massmail_crossjoin.xml
@@ -14,16 +14,12 @@
<column>username_clean</column>
<column>user_permissions</column>
<column>user_sig</column>
- <column>user_occ</column>
- <column>user_interests</column>
<row>
<value>1</value>
<value>mass email</value>
<value>mass email</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>2</value>
@@ -31,8 +27,6 @@
<value>banned</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>3</value>
@@ -40,8 +34,6 @@
<value>not in group</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
</table>
<table name="phpbb_user_group">
diff --git a/tests/dbal/fixtures/migrator.xml b/tests/dbal/fixtures/migrator.xml
new file mode 100644
index 0000000000..25be4d4129
--- /dev/null
+++ b/tests/dbal/fixtures/migrator.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<dataset>
+ <table name="phpbb_migrations">
+ <column>migration_name</column>
+ <column>migration_depends_on</column>
+ <column>migration_schema_done</column>
+ <column>migration_data_done</column>
+ <column>migration_data_state</column>
+ <column>migration_start_time</column>
+ <column>migration_end_time</column>
+ <row>
+ <value>installed_migration</value>
+ <value></value>
+ <value>1</value>
+ <value>1</value>
+ <value></value>
+ <value>1234</value>
+ <value>5678</value>
+ </row>
+ </table>
+ <table name="phpbb_config">
+ <column>config_name</column>
+ <column>config_value</column>
+ <row>
+ <value>foo</value>
+ <value>bar</value>
+ </row>
+ </table>
+</dataset>
diff --git a/tests/dbal/fixtures/migrator_config_text.xml b/tests/dbal/fixtures/migrator_config_text.xml
new file mode 100644
index 0000000000..ba8e1fcfcc
--- /dev/null
+++ b/tests/dbal/fixtures/migrator_config_text.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<dataset>
+ <table name="phpbb_config_text">
+ <column>config_name</column>
+ <column>config_value</column>
+ </table>
+</dataset>
diff --git a/tests/dbal/fixtures/migrator_module.xml b/tests/dbal/fixtures/migrator_module.xml
new file mode 100644
index 0000000000..e85c43ee25
--- /dev/null
+++ b/tests/dbal/fixtures/migrator_module.xml
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<dataset>
+ <table name="phpbb_modules">
+ <column>module_id</column>
+ <column>module_enabled</column>
+ <column>module_display</column>
+ <column>module_basename</column>
+ <column>module_class</column>
+ <column>parent_id</column>
+ <column>left_id</column>
+ <column>right_id</column>
+ <column>module_langname</column>
+ <column>module_mode</column>
+ <column>module_auth</column>
+ <row>
+ <value>1</value>
+ <value>1</value>
+ <value>1</value>
+ <value></value>
+ <value>acp</value>
+ <value>0</value>
+ <value>1</value>
+ <value>6</value>
+ <value>ACP_CAT</value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>1</value>
+ <value>1</value>
+ <value>acp_test</value>
+ <value>acp</value>
+ <value>1</value>
+ <value>2</value>
+ <value>3</value>
+ <value>ACP_MODULE</value>
+ <value>test</value>
+ <value></value>
+ </row>
+ <row>
+ <value>3</value>
+ <value>1</value>
+ <value>1</value>
+ <value></value>
+ <value>acp</value>
+ <value>1</value>
+ <value>4</value>
+ <value>5</value>
+ <value>ACP_FORUM_BASED_PERMISSIONS</value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>4</value>
+ <value>1</value>
+ <value>1</value>
+ <value></value>
+ <value>acp</value>
+ <value>0</value>
+ <value>7</value>
+ <value>12</value>
+ <value>ACP_CAT_FORUMS</value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>5</value>
+ <value>1</value>
+ <value>1</value>
+ <value></value>
+ <value>acp</value>
+ <value>4</value>
+ <value>8</value>
+ <value>11</value>
+ <value>ACP_FORUM_BASED_PERMISSIONS</value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>6</value>
+ <value>1</value>
+ <value>1</value>
+ <value></value>
+ <value>acp</value>
+ <value>5</value>
+ <value>9</value>
+ <value>10</value>
+ <value>ACP_FORUM_BASED_PERMISSIONS_CHILD_1</value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>7</value>
+ <value>1</value>
+ <value>1</value>
+ <value></value>
+ <value>ucp</value>
+ <value>0</value>
+ <value>13</value>
+ <value>18</value>
+ <value>UCP_MAIN_CAT</value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>8</value>
+ <value>1</value>
+ <value>1</value>
+ <value>ucp_subcat</value>
+ <value>ucp</value>
+ <value>7</value>
+ <value>14</value>
+ <value>17</value>
+ <value>UCP_SUBCATEGORY</value>
+ <value>ucp_test</value>
+ <value></value>
+ </row>
+ <row>
+ <value>9</value>
+ <value>1</value>
+ <value>1</value>
+ <value>ucp_module</value>
+ <value>ucp</value>
+ <value>8</value>
+ <value>15</value>
+ <value>16</value>
+ <value>UCP_MODULE</value>
+ <value>ucp_module_test</value>
+ <value></value>
+ </row>
+ </table>
+</dataset>
diff --git a/tests/dbal/fixtures/migrator_permission.xml b/tests/dbal/fixtures/migrator_permission.xml
new file mode 100644
index 0000000000..c07956fa85
--- /dev/null
+++ b/tests/dbal/fixtures/migrator_permission.xml
@@ -0,0 +1,165 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<dataset>
+ <table name="phpbb_acl_options">
+ <column>auth_option_id</column>
+ <column>auth_option</column>
+ <column>is_global</column>
+ <column>is_local</column>
+ <column>founder_only</column>
+ <row>
+ <value>1</value>
+ <value>global</value>
+ <value>1</value>
+ <value>0</value>
+ <value>0</value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>local</value>
+ <value>0</value>
+ <value>1</value>
+ <value>0</value>
+ </row>
+ <row>
+ <value>3</value>
+ <value>both</value>
+ <value>1</value>
+ <value>1</value>
+ <value>0</value>
+ </row>
+ <row>
+ <value>4</value>
+ <value>a_test</value>
+ <value>1</value>
+ <value>0</value>
+ <value>0</value>
+ </row>
+ <row>
+ <value>5</value>
+ <value>m_test</value>
+ <value>1</value>
+ <value>0</value>
+ <value>0</value>
+ </row>
+ <row>
+ <value>6</value>
+ <value>u_test</value>
+ <value>1</value>
+ <value>0</value>
+ <value>0</value>
+ </row>
+ </table>
+
+ <table name="phpbb_groups">
+ <column>group_id</column>
+ <column>group_name</column>
+ <column>group_desc</column>
+ <row>
+ <value>2</value>
+ <value>REGISTERED</value>
+ <value></value>
+ </row>
+ <row>
+ <value>4</value>
+ <value>GLOBAL_MODERATORS</value>
+ <value></value>
+ </row>
+ <row>
+ <value>5</value>
+ <value>ADMINISTRATORS</value>
+ <value></value>
+ </row>
+ </table>
+
+ <table name="phpbb_acl_groups">
+ <column>group_id</column>
+ <column>auth_role_id</column>
+ <column>forum_id</column>
+ <row>
+ <value>2</value>
+ <value>5</value>
+ <value>0</value>
+ </row>
+ <row>
+ <value>4</value>
+ <value>5</value>
+ <value>0</value>
+ </row>
+ <row>
+ <value>4</value>
+ <value>10</value>
+ <value>0</value>
+ </row>
+ <row>
+ <value>5</value>
+ <value>1</value>
+ <value>0</value>
+ </row>
+ <row>
+ <value>5</value>
+ <value>5</value>
+ <value>0</value>
+ </row>
+ </table>
+
+ <table name="phpbb_acl_roles">
+ <column>role_id</column>
+ <column>role_name</column>
+ <column>role_type</column>
+ <column>role_description</column>
+ <row>
+ <value>1</value>
+ <value>ROLE_ADMIN_STANDARD</value>
+ <value>a_</value>
+ <value></value>
+ </row>
+ <row>
+ <value>5</value>
+ <value>ROLE_USER_FULL</value>
+ <value>u_</value>
+ <value></value>
+ </row>
+ <row>
+ <value>10</value>
+ <value>ROLE_MOD_FULL</value>
+ <value>m_</value>
+ <value></value>
+ </row>
+ </table>
+
+ <table name="phpbb_acl_roles_data">
+ <column>role_id</column>
+ <column>auth_option_id</column>
+ <column>auth_setting</column>
+ <row>
+ <value>1</value>
+ <value>4</value>
+ <value>0</value>
+ </row>
+ <row>
+ <value>1</value>
+ <value>5</value>
+ <value>0</value>
+ </row>
+ <row>
+ <value>1</value>
+ <value>6</value>
+ <value>0</value>
+ </row>
+ <row>
+ <value>6</value>
+ <value>6</value>
+ <value>0</value>
+ </row>
+ <row>
+ <value>10</value>
+ <value>5</value>
+ <value>0</value>
+ </row>
+ <row>
+ <value>10</value>
+ <value>6</value>
+ <value>0</value>
+ </row>
+ </table>
+</dataset>
diff --git a/tests/dbal/fixtures/styles.xml b/tests/dbal/fixtures/styles.xml
index 47b384c47f..d51dcd0320 100644
--- a/tests/dbal/fixtures/styles.xml
+++ b/tests/dbal/fixtures/styles.xml
@@ -5,35 +5,39 @@
<column>style_name</column>
<column>style_copyright</column>
<column>style_active</column>
- <column>template_id</column>
- <column>theme_id</column>
- <column>imageset_id</column>
+ <column>style_path</column>
+ <column>bbcode_bitfield</column>
+ <column>style_parent_id</column>
+ <column>style_parent_tree</column>
<row>
<value>1</value>
<value>prosilver</value>
- <value>&amp;copy; phpBB Group</value>
- <value>1</value>
- <value>1</value>
- <value>1</value>
+ <value>&amp;copy; phpBB Limited</value>
<value>1</value>
+ <value>prosilver</value>
+ <value>kNg=</value>
+ <value>0</value>
+ <value></value>
</row>
<row>
<value>2</value>
<value>prosilver2</value>
- <value>&amp;copy; phpBB Group</value>
+ <value>&amp;copy; phpBB Limited</value>
<value>0</value>
- <value>2</value>
- <value>2</value>
- <value>2</value>
+ <value>prosilver2</value>
+ <value>kNg=</value>
+ <value>0</value>
+ <value></value>
</row>
<row>
<value>3</value>
<value>Prosilver1</value>
- <value>&amp;copy; phpBB Group</value>
+ <value>&amp;copy; phpBB Limited</value>
<value>0</value>
- <value>3</value>
- <value>3</value>
- <value>3</value>
+ <value>prosilver1</value>
+ <value>kNg=</value>
+ <value>1</value>
+ <value>prosilver</value>
</row>
</table>
</dataset>
diff --git a/tests/dbal/fixtures/three_users.xml b/tests/dbal/fixtures/three_users.xml
index a50e3e8634..a601e539e1 100644
--- a/tests/dbal/fixtures/three_users.xml
+++ b/tests/dbal/fixtures/three_users.xml
@@ -5,31 +5,23 @@
<column>username_clean</column>
<column>user_permissions</column>
<column>user_sig</column>
- <column>user_occ</column>
- <column>user_interests</column>
<row>
<value>1</value>
<value>barfoo</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>2</value>
<value>foobar</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>3</value>
<value>bertie</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
</table>
</dataset>
diff --git a/tests/dbal/migration/dummy.php b/tests/dbal/migration/dummy.php
new file mode 100644
index 0000000000..d564754892
--- /dev/null
+++ b/tests/dbal/migration/dummy.php
@@ -0,0 +1,31 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+class phpbb_dbal_migration_dummy extends \phpbb\db\migration\migration
+{
+ static public function depends_on()
+ {
+ return array('installed_migration');
+ }
+
+ function update_schema()
+ {
+ return array(
+ 'add_columns' => array(
+ 'phpbb_config' => array(
+ 'extra_column' => array('UINT', 1),
+ ),
+ ),
+ );
+ }
+}
diff --git a/tests/dbal/migration/dummy_order.php b/tests/dbal/migration/dummy_order.php
new file mode 100644
index 0000000000..5ab8f5d129
--- /dev/null
+++ b/tests/dbal/migration/dummy_order.php
@@ -0,0 +1,30 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+class phpbb_dbal_migration_dummy_order extends \phpbb\db\migration\migration
+{
+ function update_schema()
+ {
+ return array(
+ 'add_tables' => array(
+ $this->table_prefix . 'column_order_test1' => array(
+ 'COLUMNS' => array(
+ 'foobar1' => array('BOOL', 0),
+ 'foobar3' => array('BOOL', 0),
+ ),
+ 'PRIMARY_KEY' => array('foobar1'),
+ ),
+ ),
+ );
+ }
+}
diff --git a/tests/dbal/migration/dummy_order_0.php b/tests/dbal/migration/dummy_order_0.php
new file mode 100644
index 0000000000..4caea76704
--- /dev/null
+++ b/tests/dbal/migration/dummy_order_0.php
@@ -0,0 +1,26 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+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'),
+ ),
+ ),
+ );
+ }
+}
diff --git a/tests/dbal/migration/dummy_order_1.php b/tests/dbal/migration/dummy_order_1.php
new file mode 100644
index 0000000000..ea512765fa
--- /dev/null
+++ b/tests/dbal/migration/dummy_order_1.php
@@ -0,0 +1,26 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+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'),
+ ),
+ ),
+ );
+ }
+}
diff --git a/tests/dbal/migration/dummy_order_2.php b/tests/dbal/migration/dummy_order_2.php
new file mode 100644
index 0000000000..a7669b1ac8
--- /dev/null
+++ b/tests/dbal/migration/dummy_order_2.php
@@ -0,0 +1,26 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+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'),
+ ),
+ ),
+ );
+ }
+}
diff --git a/tests/dbal/migration/dummy_order_3.php b/tests/dbal/migration/dummy_order_3.php
new file mode 100644
index 0000000000..501db09b7e
--- /dev/null
+++ b/tests/dbal/migration/dummy_order_3.php
@@ -0,0 +1,26 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+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' => ''),
+ ),
+ ),
+ );
+ }
+}
diff --git a/tests/dbal/migration/dummy_order_4.php b/tests/dbal/migration/dummy_order_4.php
new file mode 100644
index 0000000000..77bb5a24b3
--- /dev/null
+++ b/tests/dbal/migration/dummy_order_4.php
@@ -0,0 +1,26 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+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),
+ ),
+ ),
+ );
+ }
+}
diff --git a/tests/dbal/migration/dummy_order_5.php b/tests/dbal/migration/dummy_order_5.php
new file mode 100644
index 0000000000..8f92392a8b
--- /dev/null
+++ b/tests/dbal/migration/dummy_order_5.php
@@ -0,0 +1,27 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+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'),
+ ),
+ ),
+ );
+ }
+}
diff --git a/tests/dbal/migration/fail.php b/tests/dbal/migration/fail.php
new file mode 100644
index 0000000000..a7a8a41694
--- /dev/null
+++ b/tests/dbal/migration/fail.php
@@ -0,0 +1,45 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+class phpbb_dbal_migration_fail extends \phpbb\db\migration\migration
+{
+ function update_schema()
+ {
+ return array(
+ 'add_columns' => array(
+ $this->table_prefix . 'config' => array(
+ 'test_column' => array('BOOL', 1),
+ ),
+ ),
+ );
+ }
+
+ function revert_schema()
+ {
+ return array(
+ 'drop_columns' => array(
+ $this->table_prefix . 'config' => array(
+ 'test_column',
+ ),
+ ),
+ );
+ }
+
+ function update_data()
+ {
+ return array(
+ array('config.add', array('foobar3', true)),
+ array('config.update', array('does_not_exist', true)),
+ );
+ }
+}
diff --git a/tests/dbal/migration/if.php b/tests/dbal/migration/if.php
new file mode 100644
index 0000000000..481250ea77
--- /dev/null
+++ b/tests/dbal/migration/if.php
@@ -0,0 +1,48 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+class phpbb_dbal_migration_if extends \phpbb\db\migration\migration
+{
+ function update_schema()
+ {
+ return array();
+ }
+
+ function update_data()
+ {
+ return array(
+ array('if', array(
+ true,
+ array('custom', array(array(&$this, 'test_true'))),
+ )),
+ array('if', array(
+ false,
+ array('custom', array(array(&$this, 'test_false'))),
+ )),
+ );
+ }
+
+ function test_true()
+ {
+ global $migrator_test_if_true_failed;
+
+ $migrator_test_if_true_failed = !$migrator_test_if_true_failed;
+ }
+
+ function test_false()
+ {
+ global $migrator_test_if_false_failed;
+
+ $migrator_test_if_false_failed = !$migrator_test_if_false_failed;
+ }
+}
diff --git a/tests/dbal/migration/installed.php b/tests/dbal/migration/installed.php
new file mode 100644
index 0000000000..83edaae23a
--- /dev/null
+++ b/tests/dbal/migration/installed.php
@@ -0,0 +1,34 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+class phpbb_dbal_migration_installed extends \phpbb\db\migration\migration
+{
+ function effectively_installed()
+ {
+ return true;
+ }
+
+ function update_data()
+ {
+ return array(
+ array('custom', array(array(&$this, 'test'))),
+ );
+ }
+
+ function test()
+ {
+ global $migrator_test_installed_failed;
+
+ $migrator_test_installed_failed = true;
+ }
+}
diff --git a/tests/dbal/migration/recall.php b/tests/dbal/migration/recall.php
new file mode 100644
index 0000000000..c0333b084d
--- /dev/null
+++ b/tests/dbal/migration/recall.php
@@ -0,0 +1,42 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+class phpbb_dbal_migration_recall extends \phpbb\db\migration\migration
+{
+ function update_schema()
+ {
+ return array();
+ }
+
+ function update_data()
+ {
+ return array(
+ array('custom', array(array(&$this, 'test_call'))),
+ );
+ }
+
+ // This function should be called 10 times
+ function test_call($input)
+ {
+ global $migrator_test_call_input;
+
+ $migrator_test_call_input = (int) $input;
+
+ if ($migrator_test_call_input < 10)
+ {
+ return ($migrator_test_call_input + 1);
+ }
+
+ return;
+ }
+}
diff --git a/tests/dbal/migration/revert.php b/tests/dbal/migration/revert.php
new file mode 100644
index 0000000000..7da65a83f1
--- /dev/null
+++ b/tests/dbal/migration/revert.php
@@ -0,0 +1,52 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+class phpbb_dbal_migration_revert extends \phpbb\db\migration\migration
+{
+ function update_schema()
+ {
+ return array(
+ 'add_columns' => array(
+ 'phpbb_config' => array(
+ 'bar_column' => array('UINT', 1),
+ ),
+ ),
+ );
+ }
+
+ function revert_schema()
+ {
+ return array(
+ 'drop_columns' => array(
+ 'phpbb_config' => array(
+ 'bar_column',
+ ),
+ ),
+ );
+ }
+
+ function update_data()
+ {
+ return array(
+ array('config.add', array('foobartest', 0)),
+ array('custom', array(array(&$this, 'my_custom_function'))),
+ );
+ }
+
+ function my_custom_function()
+ {
+ global $migrator_test_revert_counter;
+
+ $migrator_test_revert_counter += 1;
+ }
+}
diff --git a/tests/dbal/migration/revert_with_dependency.php b/tests/dbal/migration/revert_with_dependency.php
new file mode 100644
index 0000000000..43e9a4aa42
--- /dev/null
+++ b/tests/dbal/migration/revert_with_dependency.php
@@ -0,0 +1,20 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+class phpbb_dbal_migration_revert_with_dependency extends \phpbb\db\migration\migration
+{
+ static public function depends_on()
+ {
+ return array('phpbb_dbal_migration_revert');
+ }
+}
diff --git a/tests/dbal/migration/schema.php b/tests/dbal/migration/schema.php
new file mode 100644
index 0000000000..38663bcc16
--- /dev/null
+++ b/tests/dbal/migration/schema.php
@@ -0,0 +1,48 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+class phpbb_dbal_migration_schema extends \phpbb\db\migration\migration
+{
+ function update_schema()
+ {
+ return array(
+ 'add_columns' => array(
+ $this->table_prefix . 'config' => array(
+ 'test_column1' => array('BOOL', 1),
+ ),
+ ),
+ 'add_tables' => array(
+ $this->table_prefix . 'foobar' => array(
+ 'COLUMNS' => array(
+ 'module_id' => array('UINT:3', NULL, 'auto_increment'),
+ ),
+ 'PRIMARY_KEY' => 'module_id',
+ ),
+ ),
+ );
+ }
+
+ function revert_schema()
+ {
+ return array(
+ 'drop_columns' => array(
+ $this->table_prefix . 'config' => array(
+ 'test_column1',
+ ),
+ ),
+ 'drop_tables' => array(
+ $this->table_prefix . 'foobar',
+ ),
+ );
+ }
+}
diff --git a/tests/dbal/migration/unfulfillable.php b/tests/dbal/migration/unfulfillable.php
new file mode 100644
index 0000000000..11c87a6b85
--- /dev/null
+++ b/tests/dbal/migration/unfulfillable.php
@@ -0,0 +1,30 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+class phpbb_dbal_migration_unfulfillable extends \phpbb\db\migration\migration
+{
+ static public function depends_on()
+ {
+ return array('installed_migration', 'phpbb_dbal_migration_dummy', 'non_existant_migration');
+ }
+
+ function update_schema()
+ {
+ trigger_error('Schema update of migration with unfulfillable dependency was run!');
+ }
+
+ function update_data()
+ {
+ trigger_error('Data update of migration with unfulfillable dependency was run!');
+ }
+}
diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php
new file mode 100644
index 0000000000..798200eef1
--- /dev/null
+++ b/tests/dbal/migrator_test.php
@@ -0,0 +1,315 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/migration/dummy.php';
+require_once dirname(__FILE__) . '/migration/unfulfillable.php';
+require_once dirname(__FILE__) . '/migration/if.php';
+require_once dirname(__FILE__) . '/migration/recall.php';
+require_once dirname(__FILE__) . '/migration/revert.php';
+require_once dirname(__FILE__) . '/migration/revert_with_dependency.php';
+require_once dirname(__FILE__) . '/migration/fail.php';
+require_once dirname(__FILE__) . '/migration/installed.php';
+require_once dirname(__FILE__) . '/migration/schema.php';
+
+class phpbb_dbal_migrator_test extends phpbb_database_test_case
+{
+ protected $db;
+ protected $db_tools;
+ protected $migrator;
+
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/migrator.xml');
+ }
+
+ public function setUp()
+ {
+ parent::setUp();
+
+ $this->db = $this->new_dbal();
+ $this->db_tools = new \phpbb\db\tools($this->db);
+
+ $this->config = new \phpbb\config\db($this->db, new phpbb_mock_cache, 'phpbb_config');
+
+ $tools = array(
+ new \phpbb\db\migration\tool\config($this->config),
+ );
+
+ $container = new phpbb_mock_container_builder();
+
+ $this->migrator = new \phpbb\db\migrator(
+ $container,
+ $this->config,
+ $this->db,
+ $this->db_tools,
+ 'phpbb_migrations',
+ dirname(__FILE__) . '/../../phpBB/',
+ 'php',
+ 'phpbb_',
+ $tools,
+ new \phpbb\db\migration\helper()
+ );
+ $container->set('migrator', $this->migrator);
+ $container->set('dispatcher', new phpbb_mock_event_dispatcher());
+ $user = new \phpbb\user('\phpbb\datetime');
+
+ $this->extension_manager = new \phpbb\extension\manager(
+ $container,
+ $this->db,
+ $this->config,
+ new phpbb\filesystem(),
+ $user,
+ 'phpbb_ext',
+ dirname(__FILE__) . '/../../phpBB/',
+ 'php',
+ null
+ );
+ }
+
+ public function test_update()
+ {
+ $this->migrator->set_migrations(array('phpbb_dbal_migration_dummy'));
+
+ // schema
+ $this->migrator->update();
+ $this->assertFalse($this->migrator->finished());
+
+ $this->assertSqlResultEquals(
+ array(array('success' => '1')),
+ "SELECT 1 as success
+ FROM phpbb_migrations
+ WHERE migration_name = 'phpbb_dbal_migration_dummy'
+ AND migration_start_time >= " . (time() - 1) . "
+ AND migration_start_time <= " . (time() + 1),
+ 'Start time set correctly'
+ );
+
+ // data
+ $this->migrator->update();
+ $this->assertTrue($this->migrator->finished());
+
+ $this->assertSqlResultEquals(
+ array(array('extra_column' => '1')),
+ "SELECT extra_column FROM phpbb_config WHERE config_name = 'foo'",
+ 'Dummy migration created extra_column with value 1 in all rows.'
+ );
+
+ $this->assertSqlResultEquals(
+ array(array('success' => '1')),
+ "SELECT 1 as success
+ FROM phpbb_migrations
+ WHERE migration_name = 'phpbb_dbal_migration_dummy'
+ AND migration_start_time <= migration_end_time
+ AND migration_end_time >= " . (time() - 1) . "
+ AND migration_end_time <= " . (time() + 1),
+ 'End time set correctly'
+ );
+
+ // cleanup
+ $this->db_tools->sql_column_remove('phpbb_config', 'extra_column');
+ }
+
+ public function test_unfulfillable()
+ {
+ $this->migrator->set_migrations(array('phpbb_dbal_migration_unfulfillable', 'phpbb_dbal_migration_dummy'));
+
+ while (!$this->migrator->finished())
+ {
+ $this->migrator->update();
+ }
+
+ $this->assertTrue($this->migrator->finished());
+
+ $this->assertSqlResultEquals(
+ array(array('extra_column' => '1')),
+ "SELECT extra_column FROM phpbb_config WHERE config_name = 'foo'",
+ 'Dummy migration was run, even though an unfulfillable migration was found.'
+ );
+
+ $this->db_tools->sql_column_remove('phpbb_config', 'extra_column');
+ }
+
+ public function test_if()
+ {
+ $this->migrator->set_migrations(array('phpbb_dbal_migration_if'));
+
+ // Don't like this, but I'm not sure there is any other way to do this
+ global $migrator_test_if_true_failed, $migrator_test_if_false_failed;
+ $migrator_test_if_true_failed = true;
+ $migrator_test_if_false_failed = false;
+
+ while (!$this->migrator->finished())
+ {
+ $this->migrator->update();
+ }
+
+ $this->assertFalse($migrator_test_if_true_failed, 'True test failed');
+ $this->assertFalse($migrator_test_if_false_failed, 'False test failed');
+
+ while ($this->migrator->migration_state('phpbb_dbal_migration_if') !== false)
+ {
+ $this->migrator->revert('phpbb_dbal_migration_if');
+ }
+
+ $this->assertFalse($migrator_test_if_true_failed, 'True test after revert failed');
+ $this->assertFalse($migrator_test_if_false_failed, 'False test after revert failed');
+ }
+
+ public function test_recall()
+ {
+ $this->migrator->set_migrations(array('phpbb_dbal_migration_recall'));
+
+ global $migrator_test_call_input;
+
+ // Run the schema first
+ $this->migrator->update();
+
+ $i = 0;
+ while (!$this->migrator->finished())
+ {
+ $this->migrator->update();
+
+ $this->assertSame($i, $migrator_test_call_input);
+
+ $i++;
+ }
+
+ $this->assertSame(10, $migrator_test_call_input);
+ }
+
+ public function test_revert()
+ {
+ global $migrator_test_revert_counter;
+
+ // Make sure there are no other migrations in the db, this could cause issues
+ $this->db->sql_query("DELETE FROM phpbb_migrations");
+ $this->migrator->load_migration_state();
+
+ $migrator_test_revert_counter = 0;
+
+ $this->migrator->set_migrations(array('phpbb_dbal_migration_revert', 'phpbb_dbal_migration_revert_with_dependency'));
+
+ $this->assertFalse($this->migrator->migration_state('phpbb_dbal_migration_revert'));
+ $this->assertFalse($this->migrator->migration_state('phpbb_dbal_migration_revert_with_dependency'));
+
+ // Install the migration first
+ while (!$this->migrator->finished())
+ {
+ $this->migrator->update();
+ }
+
+ $this->assertTrue($this->migrator->migration_state('phpbb_dbal_migration_revert') !== false);
+ $this->assertTrue($this->migrator->migration_state('phpbb_dbal_migration_revert_with_dependency') !== false);
+
+ $this->assertSqlResultEquals(
+ array(array('bar_column' => '1')),
+ "SELECT bar_column FROM phpbb_config WHERE config_name = 'foo'",
+ 'Installing revert migration failed to create bar_column.'
+ );
+
+ $this->assertTrue(isset($this->config['foobartest']));
+
+ while ($this->migrator->migration_state('phpbb_dbal_migration_revert') !== false)
+ {
+ $this->migrator->revert('phpbb_dbal_migration_revert');
+ }
+
+ $this->assertFalse($this->migrator->migration_state('phpbb_dbal_migration_revert'));
+ $this->assertFalse($this->migrator->migration_state('phpbb_dbal_migration_revert_with_dependency'));
+
+ $this->assertFalse(isset($this->config['foobartest']));
+
+ $sql = 'SELECT * FROM phpbb_config';
+ $result = $this->db->sql_query_limit($sql, 1);
+ $row = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ if (isset($row['bar_column']))
+ {
+ $this->fail('Revert did not remove test_column.');
+ }
+
+ $this->assertEquals(1, $migrator_test_revert_counter, 'Revert did call custom function again');
+ }
+
+ public function test_fail()
+ {
+ $this->migrator->set_migrations(array('phpbb_dbal_migration_fail'));
+
+ $this->assertFalse(isset($this->config['foobar3']));
+
+ try
+ {
+ while (!$this->migrator->finished())
+ {
+ $this->migrator->update();
+ }
+ }
+ catch (\phpbb\db\migration\exception $e) {}
+
+ // Failure should have caused an automatic roll-back, so this should not exist.
+ $this->assertFalse(isset($this->config['foobar3']));
+
+ $sql = 'SELECT * FROM phpbb_config';
+ $result = $this->db->sql_query_limit($sql, 1);
+ $row = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ if (isset($row['test_column']))
+ {
+ $this->fail('Revert did not remove test_column.');
+ }
+ }
+
+ public function test_installed()
+ {
+ $this->migrator->set_migrations(array('phpbb_dbal_migration_installed'));
+
+ global $migrator_test_installed_failed;
+ $migrator_test_installed_failed = false;
+
+ while (!$this->migrator->finished())
+ {
+ $this->migrator->update();
+ }
+
+ $this->assertTrue($this->migrator->migration_state('phpbb_dbal_migration_installed') !== false);
+
+ if ($migrator_test_installed_failed)
+ {
+ $this->fail('Installed test failed');
+ }
+ }
+
+ public function test_schema()
+ {
+ $this->migrator->set_migrations(array('phpbb_dbal_migration_schema'));
+
+ while (!$this->migrator->finished())
+ {
+ $this->migrator->update();
+ }
+
+ $this->assertTrue($this->db_tools->sql_column_exists('phpbb_config', 'test_column1'));
+ $this->assertTrue($this->db_tools->sql_table_exists('phpbb_foobar'));
+
+ while ($this->migrator->migration_state('phpbb_dbal_migration_schema'))
+ {
+ $this->migrator->revert('phpbb_dbal_migration_schema');
+ }
+
+ $this->assertFalse($this->db_tools->sql_column_exists('phpbb_config', 'test_column1'));
+ $this->assertFalse($this->db_tools->sql_table_exists('phpbb_foobar'));
+ }
+}
diff --git a/tests/dbal/migrator_tool_config_test.php b/tests/dbal/migrator_tool_config_test.php
new file mode 100644
index 0000000000..13e0c13e3c
--- /dev/null
+++ b/tests/dbal/migrator_tool_config_test.php
@@ -0,0 +1,90 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+class phpbb_dbal_migrator_tool_config_test extends phpbb_test_case
+{
+ public function setup()
+ {
+ $this->config = new \phpbb\config\config(array());
+
+ $this->tool = new \phpbb\db\migration\tool\config($this->config);
+
+ parent::setup();
+ }
+
+ public function test_add()
+ {
+ $this->tool->add('foo', 'bar');
+ $this->assertEquals('bar', $this->config['foo']);
+ }
+
+ public function test_add_twice()
+ {
+ $this->tool->add('foo', 'bar');
+ $this->assertEquals('bar', $this->config['foo']);
+
+ $this->tool->add('foo', 'bar2');
+ $this->assertEquals('bar', $this->config['foo']);
+ }
+
+ public function test_update()
+ {
+ $this->config->set('foo', 'bar');
+
+ $this->tool->update('foo', 'bar2');
+ $this->assertEquals('bar2', $this->config['foo']);
+ }
+
+ public function test_update_if_equals()
+ {
+ $this->config->set('foo', 'bar');
+
+ $this->tool->update_if_equals('', 'foo', 'bar2');
+ $this->assertEquals('bar', $this->config['foo']);
+
+ $this->tool->update_if_equals('bar', 'foo', 'bar2');
+ $this->assertEquals('bar2', $this->config['foo']);
+ }
+
+ public function test_remove()
+ {
+ $this->config->set('foo', 'bar');
+
+ $this->tool->remove('foo');
+ $this->assertFalse(isset($this->config['foo']));
+ }
+
+ public function test_reverse_add()
+ {
+ $this->config->set('foo', 'bar');
+
+ $this->tool->reverse('add', 'foo');
+ $this->assertFalse(isset($this->config['foo']));
+ }
+
+ public function test_reverse_remove()
+ {
+ $this->config->delete('foo');
+
+ $this->tool->reverse('remove', 'foo');
+ $this->assertEquals('', $this->config['foo']);
+ }
+
+ public function test_reverse_update_if_equals()
+ {
+ $this->config->set('foo', 'bar');
+
+ $this->tool->reverse('update_if_equals', 'test', 'foo', 'bar');
+ $this->assertEquals('test', $this->config['foo']);
+ }
+}
diff --git a/tests/dbal/migrator_tool_config_text_test.php b/tests/dbal/migrator_tool_config_text_test.php
new file mode 100644
index 0000000000..b271c2d62e
--- /dev/null
+++ b/tests/dbal/migrator_tool_config_text_test.php
@@ -0,0 +1,75 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+class phpbb_dbal_migrator_tool_config_text_test extends phpbb_database_test_case
+{
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/migrator_config_text.xml');
+ }
+
+ public function setup()
+ {
+ parent::setup();
+
+ $this->db = $this->new_dbal();
+ $this->config_text = new \phpbb\config\db_text($this->db, 'phpbb_config_text');
+
+ $this->tool = new \phpbb\db\migration\tool\config_text($this->config_text);
+ }
+
+ public function test_add()
+ {
+ $this->tool->add('foo', 'bar');
+ $this->assertEquals('bar', $this->config_text->get('foo'));
+ }
+
+ public function test_add_twice()
+ {
+ $this->tool->add('foo', 'bar');
+ $this->assertEquals('bar', $this->config_text->get('foo'));
+
+ $this->tool->add('foo', 'bar2');
+ $this->assertEquals('bar', $this->config_text->get('foo'));
+ }
+
+ public function test_update()
+ {
+ $this->config_text->set('foo', 'bar');
+
+ $this->tool->update('foo', 'bar2');
+ $this->assertEquals('bar2', $this->config_text->get('foo'));
+ }
+
+ public function test_remove()
+ {
+ $this->config_text->set('foo', 'bar');
+
+ $this->tool->remove('foo');
+ $this->assertNull($this->config_text->get('foo'));
+ }
+
+ public function test_reverse_add()
+ {
+ $this->config_text->set('foo', 'bar');
+
+ $this->tool->reverse('add', 'foo');
+ $this->assertNull($this->config_text->get('foo'));
+ }
+
+ public function test_reverse_remove()
+ {
+ $this->tool->reverse('remove', 'foo');
+ $this->assertSame('', $this->config_text->get('foo'));
+ }
+}
diff --git a/tests/dbal/migrator_tool_module_test.php b/tests/dbal/migrator_tool_module_test.php
new file mode 100644
index 0000000000..bbe543f347
--- /dev/null
+++ b/tests/dbal/migrator_tool_module_test.php
@@ -0,0 +1,305 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+
+class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case
+{
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/migrator_module.xml');
+ }
+
+ public function setup()
+ {
+ // Need global $db, $user for delete_module function in acp_modules
+ global $phpbb_root_path, $phpEx, $skip_add_log, $db, $user, $phpbb_log;
+
+ parent::setup();
+
+ // Force add_log function to not be used
+ $skip_add_log = true;
+
+ $db = $this->db = $this->new_dbal();
+ $this->cache = new \phpbb\cache\service(new \phpbb\cache\driver\null(), new \phpbb\config\config(array()), $this->db, $phpbb_root_path, $phpEx);
+ $user = $this->user = new \phpbb\user('\phpbb\user');
+
+ $cache = new phpbb_mock_cache;
+ $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
+ $auth = $this->getMock('\phpbb\auth\auth');
+ $phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);
+
+ $this->tool = new \phpbb\db\migration\tool\module($this->db, $this->cache, $this->user, $phpbb_root_path, $phpEx, 'phpbb_modules');
+ }
+
+ public function exists_data_acp()
+ {
+ return array(
+ // Test the existing category
+ array(
+ '',
+ 'ACP_CAT',
+ true,
+ ),
+ array(
+ 0,
+ 'ACP_CAT',
+ true,
+ ),
+
+ // Test the existing module
+ array(
+ '',
+ 'ACP_MODULE',
+ false,
+ ),
+ array(
+ false,
+ 'ACP_MODULE',
+ true,
+ ),
+ array(
+ 'ACP_CAT',
+ 'ACP_MODULE',
+ true,
+ ),
+
+ // Test for non-existant modules
+ array(
+ '',
+ 'ACP_NON_EXISTANT_CAT',
+ false,
+ ),
+ array(
+ 'ACP_CAT',
+ 'ACP_NON_EXISTANT_MODULE',
+ false,
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider exists_data_acp
+ */
+ public function test_exists_acp($parent, $module, $expected)
+ {
+ $this->assertEquals($expected, $this->tool->exists('acp', $parent, $module));
+ }
+
+ public function exists_data_ucp()
+ {
+ return array(
+ // Test the existing category
+ array(
+ '',
+ 'UCP_MAIN_CAT',
+ true,
+ ),
+ array(
+ 0,
+ 'UCP_MAIN_CAT',
+ true,
+ ),
+
+ // Test the existing module
+ array(
+ '',
+ 'UCP_SUBCATEGORY',
+ false,
+ ),
+ array(
+ false,
+ 'UCP_SUBCATEGORY',
+ true,
+ ),
+ array(
+ 'UCP_MAIN_CAT',
+ 'UCP_SUBCATEGORY',
+ true,
+ ),
+ array(
+ 'UCP_SUBCATEGORY',
+ 'UCP_MODULE',
+ true,
+ ),
+
+ // Test for non-existant modules
+ array(
+ '',
+ 'UCP_NON_EXISTANT_CAT',
+ false,
+ ),
+ array(
+ 'UCP_MAIN_CAT',
+ 'UCP_NON_EXISTANT_MODULE',
+ false,
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider exists_data_ucp
+ */
+ public function test_exists_ucp($parent, $module, $expected)
+ {
+ $this->assertEquals($expected, $this->tool->exists('ucp', $parent, $module));
+ }
+
+ public function test_add()
+ {
+ try
+ {
+ $this->tool->add('acp', 0, 'ACP_NEW_CAT');
+ }
+ catch (Exception $e)
+ {
+ $this->fail($e);
+ }
+ $this->assertEquals(true, $this->tool->exists('acp', 0, 'ACP_NEW_CAT'));
+
+ // Should throw an exception when trying to add a module that already exists
+ try
+ {
+ $this->tool->add('acp', 0, 'ACP_NEW_CAT');
+ $this->fail('Exception not thrown');
+ }
+ catch (Exception $e) {}
+
+ try
+ {
+ $this->tool->add('acp', 'ACP_NEW_CAT', array(
+ 'module_basename' => 'acp_new_module',
+ 'module_langname' => 'ACP_NEW_MODULE',
+ 'module_mode' => 'test',
+ 'module_auth' => '',
+ ));
+ }
+ catch (Exception $e)
+ {
+ $this->fail($e);
+ }
+ $this->assertEquals(true, $this->tool->exists('acp', 'ACP_NEW_CAT', 'ACP_NEW_MODULE'));
+
+ // Test adding module when plural parent module_langname exists
+ // PHPBB3-14703
+ // Adding fail
+ try
+ {
+ $this->tool->add('acp', 'ACP_FORUM_BASED_PERMISSIONS', array(
+ 'module_basename' => 'acp_new_permissions_module',
+ 'module_langname' => 'ACP_NEW_PERMISSIONS_MODULE',
+ 'module_mode' => 'test',
+ 'module_auth' => '',
+ ));
+ $this->fail('Exception not thrown');
+ }
+ catch (Exception $e)
+ {
+ $this->assertEquals('phpbb\db\migration\exception', get_class($e));
+ $this->assertEquals('MODULE_EXIST_MULTIPLE', $e->getMessage());
+ }
+
+ // Test adding module when plural parent module_langname exists
+ // PHPBB3-14703
+ // Adding success
+ try
+ {
+ $this->tool->add('acp', 'ACP_FORUM_BASED_PERMISSIONS', array(
+ 'module_basename' => 'acp_new_permissions_module',
+ 'module_langname' => 'ACP_NEW_PERMISSIONS_MODULE',
+ 'module_mode' => 'test',
+ 'module_auth' => '',
+ 'after' => 'ACP_FORUM_BASED_PERMISSIONS_CHILD_1',
+ ));
+ }
+ catch (Exception $e)
+ {
+ $this->fail($e);
+ }
+ $this->assertEquals(true, $this->tool->exists('acp', 'ACP_FORUM_BASED_PERMISSIONS', 'ACP_NEW_PERMISSIONS_MODULE'));
+
+ // Test adding UCP modules
+ // Test adding new UCP category
+ try
+ {
+ $this->tool->add('ucp', 0, 'UCP_NEW_CAT');
+ }
+ catch (Exception $e)
+ {
+ $this->fail($e);
+ }
+ $this->assertEquals(true, $this->tool->exists('ucp', 0, 'UCP_NEW_CAT'));
+
+ // Test adding new UCP subcategory
+ try
+ {
+ $this->tool->add('ucp', 'UCP_NEW_CAT', 'UCP_NEW_SUBCAT');
+ }
+ catch (Exception $e)
+ {
+ $this->fail($e);
+ }
+ $this->assertEquals(true, $this->tool->exists('ucp', 'UCP_NEW_CAT', 'UCP_NEW_SUBCAT'));
+
+ // Test adding new UCP module
+ try
+ {
+ $this->tool->add('ucp', 'UCP_NEW_SUBCAT', array(
+ 'module_basename' => 'ucp_new_module',
+ 'module_langname' => 'UCP_NEW_MODULE',
+ 'module_mode' => 'ucp_test',
+ 'module_auth' => '',
+ ));
+ }
+ catch (Exception $e)
+ {
+ $this->fail($e);
+ }
+ $this->assertEquals(true, $this->tool->exists('ucp', 'UCP_NEW_SUBCAT', 'UCP_NEW_MODULE'));
+ }
+
+ public function test_remove()
+ {
+ try
+ {
+ $this->tool->remove('acp', 'ACP_CAT', 'ACP_MODULE');
+ }
+ catch (Exception $e)
+ {
+ $this->fail($e);
+ }
+ $this->assertEquals(false, $this->tool->exists('acp', 'ACP_CAT', 'ACP_MODULE'));
+ }
+
+ public function test_reverse()
+ {
+ try
+ {
+ $this->tool->add('acp', 0, 'ACP_NEW_CAT');
+ }
+ catch (Exception $e)
+ {
+ $this->fail($e);
+ }
+
+ try
+ {
+ $this->tool->reverse('add', 'acp', 0, 'ACP_NEW_CAT');
+ }
+ catch (Exception $e)
+ {
+ $this->fail($e);
+ }
+ $this->assertFalse($this->tool->exists('acp', 0, 'ACP_NEW_CAT'));
+ }
+}
diff --git a/tests/dbal/migrator_tool_permission_test.php b/tests/dbal/migrator_tool_permission_test.php
new file mode 100644
index 0000000000..2d673864f7
--- /dev/null
+++ b/tests/dbal/migrator_tool_permission_test.php
@@ -0,0 +1,223 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+
+class phpbb_dbal_migrator_tool_permission_test extends phpbb_database_test_case
+{
+ public $group_ids = array(
+ 'REGISTERED' => 2,
+ 'GLOBAL_MODERATORS' => 4,
+ 'ADMINISTRATORS' => 5,
+ );
+
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/migrator_permission.xml');
+ }
+
+ public function setup()
+ {
+ // Global $db and $cache are needed in acp/auth.php constructor
+ global $phpbb_root_path, $phpEx, $db, $cache;
+
+ parent::setup();
+
+ $db = $this->db = $this->new_dbal();
+ $cache = $this->cache = new \phpbb\cache\service(new \phpbb\cache\driver\null(), new \phpbb\config\config(array()), $this->db, $phpbb_root_path, $phpEx);
+ $this->auth = new \phpbb\auth\auth();
+
+ $this->tool = new \phpbb\db\migration\tool\permission($this->db, $this->cache, $this->auth, $phpbb_root_path, $phpEx);
+ }
+
+ public function exists_data()
+ {
+ return array(
+ array(
+ 'global',
+ true,
+ true,
+ ),
+ array(
+ 'local',
+ false,
+ true,
+ ),
+ array(
+ 'both',
+ true,
+ true,
+ ),
+ array(
+ 'both',
+ false,
+ true,
+ ),
+ array(
+ 'does_not_exist',
+ true,
+ false,
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider exists_data
+ */
+ public function test_exists($auth_option, $global, $expected)
+ {
+ $this->assertEquals($expected, $this->tool->exists($auth_option, $global));
+ }
+
+ public function test_add()
+ {
+ try
+ {
+ $this->tool->add('new', true);
+ }
+ catch (Exception $e)
+ {
+ $this->fail($e);
+ }
+ $this->assertEquals(true, $this->tool->exists('new', true));
+ $this->assertEquals(false, $this->tool->exists('new', false));
+
+ try
+ {
+ $this->tool->add('new', false);
+ }
+ catch (Exception $e)
+ {
+ $this->fail($e);
+ }
+ $this->assertEquals(true, $this->tool->exists('new', false));
+
+ // Should fail (duplicate)
+ try
+ {
+ $this->tool->add('new', true);
+ $this->fail('Did not throw exception on duplicate');
+ }
+ catch (Exception $e) {}
+ }
+
+ public function test_remove()
+ {
+ try
+ {
+ $this->tool->remove('global', true);
+ }
+ catch (Exception $e)
+ {
+ $this->fail($e);
+ }
+ $this->assertEquals(false, $this->tool->exists('global', true));
+
+ try
+ {
+ $this->tool->remove('both', false);
+ }
+ catch (Exception $e)
+ {
+ $this->fail($e);
+ }
+ $this->assertEquals(false, $this->tool->exists('both', false));
+
+ // Should fail (does not exist)
+ try
+ {
+ $this->tool->remove('new', true);
+ $this->fail('Did not throw exception on duplicate');
+ }
+ catch (Exception $e) {}
+ }
+
+ public function test_reverse()
+ {
+ try
+ {
+ $this->tool->reverse('remove', 'global_test', true);
+ }
+ catch (Exception $e)
+ {
+ $this->fail($e);
+ }
+ $this->assertTrue($this->tool->exists('global_test', true));
+
+ try
+ {
+ $this->tool->reverse('add', 'global_test', true);
+ }
+ catch (Exception $e)
+ {
+ $this->fail($e);
+ }
+ $this->assertFalse($this->tool->exists('global_test', true));
+ }
+
+ public function test_permission_set_data()
+ {
+ return array(
+ array(
+ 'ADMINISTRATORS',
+ 'a_test',
+ 'group',
+ true,
+ ),
+ array(
+ 'GLOBAL_MODERATORS',
+ 'm_test',
+ 'group',
+ true,
+ ),
+ array(
+ 'REGISTERED',
+ 'u_test',
+ 'group',
+ true,
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider test_permission_set_data
+ */
+ public function test_permission_set($group_name, $auth_option, $type, $has_permission)
+ {
+ $this->tool->permission_set($group_name, $auth_option, $type, $has_permission);
+ $administrators_perm = $this->auth->acl_group_raw_data($this->group_ids['ADMINISTRATORS'], $auth_option);
+ $global_moderators_perm = $this->auth->acl_group_raw_data($this->group_ids['GLOBAL_MODERATORS'], $auth_option);
+ $registered_users_perm = $this->auth->acl_group_raw_data($this->group_ids['REGISTERED'], $auth_option);
+
+ switch($group_name)
+ {
+ case 'GLOBAL_MODERATORS':
+ $this->assertEquals(false, empty($administrators_perm), 'm_test is not empty for Administrators');
+ $this->assertEquals(false, empty($global_moderators_perm), 'm_test is not empty for Global moderators');
+ $this->assertEquals(true, empty($registered_users_perm), 'm_test empty for Registered users');
+ break;
+
+ case 'ADMINISTRATORS':
+ $this->assertEquals(false, empty($administrators_perm), 'a_test is not empty for Administrators');
+ $this->assertEquals(true, empty($global_moderators_perm), 'a_test is empty for Global moderators');
+ $this->assertEquals(true, empty($registered_users_perm), 'a_test is empty for Registered users');
+ break;
+
+ case 'REGISTERED':
+ $this->assertEquals(false, empty($administrators_perm), 'u_test is not empty for Administrators');
+ $this->assertEquals(false, empty($global_moderators_perm), 'u_test is not empty for Global moderators');
+ $this->assertEquals(false, empty($registered_users_perm), 'u_test is not empty for Registered users');
+ break;
+ }
+ }
+}
diff --git a/tests/dbal/order_lower_test.php b/tests/dbal/order_lower_test.php
index e17295a4ea..b101d28c7d 100644
--- a/tests/dbal/order_lower_test.php
+++ b/tests/dbal/order_lower_test.php
@@ -1,9 +1,13 @@
<?php
/**
*
-* @package testing
-* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
*
*/
@@ -18,7 +22,7 @@ class phpbb_dbal_order_lower_test extends phpbb_database_test_case
{
$db = $this->new_dbal();
- if (strpos($db->sql_layer, 'mysql') === 0 && version_compare($db->sql_server_info(true, false), '5.6', '>='))
+ if (strpos($db->get_sql_layer(), 'mysql') === 0 && version_compare($db->sql_server_info(true, false), '5.6', '>='))
{
$this->markTestSkipped('MySQL 5.6 fails to order things correctly. See also: http://tracker.phpbb.com/browse/PHPBB3-11571 http://bugs.mysql.com/bug.php?id=69005');
}
@@ -36,29 +40,32 @@ class phpbb_dbal_order_lower_test extends phpbb_database_test_case
array(
'style_id' => 1,
'style_name' => 'prosilver',
- 'style_copyright' => '&copy; phpBB Group',
+ 'style_copyright' => '&copy; phpBB Limited',
'style_active' => 1,
- 'template_id' => 1,
- 'theme_id' => 1,
- 'imageset_id' => 1
+ 'style_path' => 'prosilver',
+ 'bbcode_bitfield' => 'kNg=',
+ 'style_parent_id' => 0,
+ 'style_parent_tree' => '',
),
array(
'style_id' => 3,
'style_name' => 'Prosilver1',
- 'style_copyright' => '&copy; phpBB Group',
+ 'style_copyright' => '&copy; phpBB Limited',
'style_active' => 0,
- 'template_id' => 3,
- 'theme_id' => 3,
- 'imageset_id' => 3
+ 'style_path' => 'prosilver1',
+ 'bbcode_bitfield' => 'kNg=',
+ 'style_parent_id' => 1,
+ 'style_parent_tree' => 'prosilver',
),
array(
'style_id' => 2,
'style_name' => 'prosilver2',
- 'style_copyright' => '&copy; phpBB Group',
+ 'style_copyright' => '&copy; phpBB Limited',
'style_active' => 0,
- 'template_id' => 2,
- 'theme_id' => 2,
- 'imageset_id' => 2
+ 'style_path' => 'prosilver2',
+ 'bbcode_bitfield' => 'kNg=',
+ 'style_parent_id' => 0,
+ 'style_parent_tree' => '',
)
),
$db->sql_fetchrowset($result)
diff --git a/tests/dbal/schema_test.php b/tests/dbal/schema_test.php
new file mode 100644
index 0000000000..f13c7ce032
--- /dev/null
+++ b/tests/dbal/schema_test.php
@@ -0,0 +1,42 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+
+class phpbb_dbal_schema_test extends phpbb_database_test_case
+{
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/config.xml');
+ }
+
+ public function test_config_value_multibyte()
+ {
+ $db = $this->new_dbal();
+
+ $value = str_repeat("\xC3\x84", 255);
+ $sql = "INSERT INTO phpbb_config
+ (config_name, config_value)
+ VALUES ('name', '$value')";
+ $result = $db->sql_query($sql);
+
+ $sql = "SELECT config_value
+ FROM phpbb_config
+ WHERE config_name = 'name'";
+ $result = $db->sql_query_limit($sql, 1);
+ $row = $db->sql_fetchrow($result);
+ $db->sql_freeresult($result);
+
+ $this->assertEquals($value, $row['config_value']);
+ }
+}
diff --git a/tests/dbal/select_test.php b/tests/dbal/select_test.php
index 6dbab05a41..b7074552ba 100644
--- a/tests/dbal/select_test.php
+++ b/tests/dbal/select_test.php
@@ -1,9 +1,13 @@
<?php
/**
*
-* @package testing
-* @copyright (c) 2008 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
*
*/
@@ -17,7 +21,7 @@ class phpbb_dbal_select_test extends phpbb_database_test_case
return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/three_users.xml');
}
- static public function return_on_error_select_data()
+ public function return_on_error_select_data()
{
return array(
array('phpbb_users', "username_clean = 'bertie'", array(array('username_clean' => 'bertie'))),
@@ -44,7 +48,7 @@ class phpbb_dbal_select_test extends phpbb_database_test_case
$this->assertEquals($expected, $db->sql_fetchrowset($result));
}
- static public function fetchrow_data()
+ public function fetchrow_data()
{
return array(
array('', array(array('username_clean' => 'barfoo'),
@@ -95,7 +99,7 @@ class phpbb_dbal_select_test extends phpbb_database_test_case
$db->sql_freeresult($result);
}
- static public function fetchfield_data()
+ public function fetchfield_data()
{
return array(
array('', array('barfoo', 'foobar', 'bertie')),
@@ -192,7 +196,7 @@ class phpbb_dbal_select_test extends phpbb_database_test_case
$this->assertEquals($expected, $ary);
}
- static public function like_expression_data()
+ public function like_expression_data()
{
// * = any_char; # = one_char
return array(
@@ -215,8 +219,8 @@ class phpbb_dbal_select_test extends phpbb_database_test_case
{
$db = $this->new_dbal();
- $like_expression = str_replace('*', $db->any_char, $like_expression);
- $like_expression = str_replace('#', $db->one_char, $like_expression);
+ $like_expression = str_replace('*', $db->get_any_char(), $like_expression);
+ $like_expression = str_replace('#', $db->get_one_char(), $like_expression);
$where = ($like_expression) ? 'username_clean ' . $db->sql_like_expression($like_expression) : '';
$result = $db->sql_query('SELECT username_clean
@@ -229,7 +233,67 @@ class phpbb_dbal_select_test extends phpbb_database_test_case
$db->sql_freeresult($result);
}
- static public function in_set_data()
+ public function not_like_expression_data()
+ {
+ // * = any_char; # = one_char
+ return array(
+ array('barfoo', array(
+ array('username_clean' => 'foobar'),
+ array('username_clean' => 'bertie')
+ )),
+ array('bar', array(
+ array('username_clean' => 'barfoo'),
+ array('username_clean' => 'foobar'),
+ array('username_clean' => 'bertie'),
+ )),
+ array('bar*', array(
+ array('username_clean' => 'foobar'),
+ array('username_clean' => 'bertie'))
+ ),
+ array('*bar*', array(array('username_clean' => 'bertie'))),
+ array('b*r', array(
+ array('username_clean' => 'barfoo'),
+ array('username_clean' => 'foobar'),
+ array('username_clean' => 'bertie')
+ )),
+ array('b*e', array(
+ array('username_clean' => 'barfoo'),
+ array('username_clean' => 'foobar')
+ )),
+ array('#b*e', array(
+ array('username_clean' => 'barfoo'),
+ array('username_clean' => 'foobar'),
+ array('username_clean' => 'bertie')
+ )),
+ array('b####e', array(
+ array('username_clean' => 'barfoo'),
+ array('username_clean' => 'foobar')
+ )),
+ );
+ }
+
+ /**
+ * @dataProvider not_like_expression_data
+ */
+ public function test_not_like_expression($like_expression, $expected)
+ {
+ $db = $this->new_dbal();
+
+ $like_expression = str_replace('*', $db->get_any_char(), $like_expression);
+ $like_expression = str_replace('#', $db->get_one_char(), $like_expression);
+ $where = ($like_expression) ? 'username_clean ' . $db->sql_not_like_expression($like_expression) : '';
+
+ $result = $db->sql_query('SELECT username_clean
+ FROM phpbb_users
+ ' . (($where) ? ' WHERE ' . $where : '') . '
+ ORDER BY user_id ASC');
+
+ $this->assertEquals($expected, $db->sql_fetchrowset($result));
+
+ $db->sql_freeresult($result);
+ }
+
+ public function in_set_data()
{
return array(
array('user_id', 3, false, false, array(array('username_clean' => 'bertie'))),
@@ -303,7 +367,7 @@ class phpbb_dbal_select_test extends phpbb_database_test_case
$db->sql_freeresult($result);
}
- static public function build_array_data()
+ public function build_array_data()
{
return array(
array(array('username_clean' => 'barfoo'), array(array('username_clean' => 'barfoo'))),
diff --git a/tests/dbal/sql_affected_rows_test.php b/tests/dbal/sql_affected_rows_test.php
new file mode 100644
index 0000000000..07d7318358
--- /dev/null
+++ b/tests/dbal/sql_affected_rows_test.php
@@ -0,0 +1,68 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+class phpbb_dbal_sql_affected_rows_test extends phpbb_database_test_case
+{
+ /** @var \phpbb\db\driver\driver_interface */
+ protected $db;
+
+ public function setUp()
+ {
+ parent::setUp();
+ $this->db = $this->new_dbal();
+ }
+
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml');
+ }
+
+ public function test_update()
+ {
+ $sql = 'UPDATE ' . CONFIG_TABLE . "
+ SET config_value = 'bertie'";
+ $this->db->sql_query($sql);
+
+ $this->assertEquals(2, $this->db->sql_affectedrows());
+ }
+
+ public function test_update_all_matched_unequal_updated()
+ {
+ $sql = 'UPDATE ' . CONFIG_TABLE . "
+ SET config_value = 'foo'";
+ $this->db->sql_query($sql);
+
+ $this->assertEquals(2, $this->db->sql_affectedrows());
+ }
+
+ public function test_update_same_value_matched_unequal_updated()
+ {
+ $sql = 'UPDATE ' . CONFIG_TABLE . "
+ SET config_value = 'foo'
+ WHERE config_value = 'foo'";
+ $this->db->sql_query($sql);
+
+ $this->assertEquals(1, $this->db->sql_affectedrows());
+ }
+
+ public function test_insert()
+ {
+ $sql = 'INSERT INTO ' . CONFIG_TABLE . ' ' . $this->db->sql_build_array('INSERT', array(
+ 'config_name' => 'bertie',
+ 'config_value' => 'rules',
+ ));
+ $this->db->sql_query($sql);
+
+ $this->assertEquals(1, $this->db->sql_affectedrows());
+ }
+}
diff --git a/tests/dbal/sql_insert_buffer_test.php b/tests/dbal/sql_insert_buffer_test.php
new file mode 100644
index 0000000000..eae0abceba
--- /dev/null
+++ b/tests/dbal/sql_insert_buffer_test.php
@@ -0,0 +1,120 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+class phpbb_dbal_sql_insert_buffer_test extends phpbb_database_test_case
+{
+ protected $db;
+ protected $buffer;
+
+ public function setUp()
+ {
+ parent::setUp();
+
+ $this->db = $this->new_dbal();
+ $this->buffer = new \phpbb\db\sql_insert_buffer($this->db, 'phpbb_config', 2);
+ $this->assert_config_count(2);
+ }
+
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml');
+ }
+
+ public function test_multi_insert_disabled_insert_and_flush()
+ {
+ $this->db->set_multi_insert(false);
+ $this->assertTrue($this->buffer->insert($this->get_row(1)));
+ $this->assert_config_count(3);
+ $this->assertFalse($this->buffer->flush());
+ $this->assert_config_count(3);
+ }
+
+ public function test_multi_insert_enabled_insert_and_flush()
+ {
+ $this->check_multi_insert_support();
+ $this->assertFalse($this->buffer->insert($this->get_row(1)));
+ $this->assert_config_count(2);
+ $this->assertTrue($this->buffer->flush());
+ $this->assert_config_count(3);
+ }
+
+ public function test_multi_insert_disabled_insert_with_flush()
+ {
+ $this->db->set_multi_insert(false);
+ $this->assertTrue($this->buffer->insert($this->get_row(1)));
+ $this->assert_config_count(3);
+ $this->assertTrue($this->buffer->insert($this->get_row(2)));
+ $this->assert_config_count(4);
+ }
+
+ public function test_multi_insert_enabled_insert_with_flush()
+ {
+ $this->check_multi_insert_support();
+ $this->assertFalse($this->buffer->insert($this->get_row(1)));
+ $this->assert_config_count(2);
+ $this->assertTrue($this->buffer->insert($this->get_row(2)));
+ $this->assert_config_count(4);
+ }
+
+ public function test_multi_insert_disabled_insert_all_and_flush()
+ {
+ $this->db->set_multi_insert(false);
+ $this->assertTrue($this->buffer->insert_all($this->get_rows(3)));
+ $this->assert_config_count(5);
+ }
+
+ public function test_multi_insert_enabled_insert_all_and_flush()
+ {
+ $this->check_multi_insert_support();
+ $this->assertTrue($this->buffer->insert_all($this->get_rows(3)));
+ $this->assert_config_count(4);
+ $this->assertTrue($this->buffer->flush());
+ $this->assert_config_count(5);
+ }
+
+ protected function assert_config_count($num_configs)
+ {
+ $sql = 'SELECT COUNT(*) AS num_configs
+ FROM phpbb_config';
+ $result = $this->db->sql_query($sql);
+ $this->assertEquals($num_configs, $this->db->sql_fetchfield('num_configs'));
+ $this->db->sql_freeresult($result);
+ }
+
+ protected function check_multi_insert_support()
+ {
+ if (!$this->db->get_multi_insert())
+ {
+ $this->markTestSkipped('Database does not support multi_insert');
+ }
+ }
+
+ protected function get_row($rownum)
+ {
+ return array(
+ 'config_name' => "name$rownum",
+ 'config_value' => "value$rownum",
+ 'is_dynamic' => '0',
+ );
+ }
+
+ protected function get_rows($n)
+ {
+ $result = array();
+ for ($i = 0; $i < $n; ++$i)
+ {
+ $result[] = $this->get_row($i);
+ }
+ return $result;
+ }
+}
diff --git a/tests/dbal/write_sequence_test.php b/tests/dbal/write_sequence_test.php
index 8975cfbfb1..a1b589c578 100644
--- a/tests/dbal/write_sequence_test.php
+++ b/tests/dbal/write_sequence_test.php
@@ -1,9 +1,13 @@
<?php
/**
*
-* @package testing
-* @copyright (c) 2012 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
*
*/
@@ -33,13 +37,15 @@ class phpbb_dbal_write_sequence_test extends phpbb_database_test_case
{
$db = $this->new_dbal();
+ // dbal uses cache
+ global $cache;
+ $cache = new phpbb_mock_cache();
+
$sql = 'INSERT INTO phpbb_users ' . $db->sql_build_array('INSERT', array(
'username' => $username,
'username_clean' => $username,
'user_permissions' => '',
'user_sig' => '',
- 'user_occ' => '',
- 'user_interests' => '',
));
$db->sql_query($sql);
diff --git a/tests/dbal/write_test.php b/tests/dbal/write_test.php
index ecfd774896..2426f2b0be 100644
--- a/tests/dbal/write_test.php
+++ b/tests/dbal/write_test.php
@@ -1,9 +1,13 @@
<?php
/**
*
-* @package testing
-* @copyright (c) 2008 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
*
*/
@@ -16,7 +20,7 @@ class phpbb_dbal_write_test extends phpbb_database_test_case
return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/config.xml');
}
- static public function build_array_insert_data()
+ public function build_array_insert_data()
{
return array(
array(array(
@@ -64,7 +68,7 @@ class phpbb_dbal_write_test extends phpbb_database_test_case
FROM phpbb_config';
$result = $db->sql_query($sql);
$rows = $db->sql_fetchrowset($result);
-
+
$this->assertEquals(1, sizeof($rows));
$this->assertEquals('config2', $rows[0]['config_name']);
@@ -104,7 +108,7 @@ class phpbb_dbal_write_test extends phpbb_database_test_case
$db->sql_freeresult($result);
}
- static public function update_data()
+ public function update_data()
{
return array(
array(