aboutsummaryrefslogtreecommitdiffstats
path: root/tests/dbal
diff options
context:
space:
mode:
Diffstat (limited to 'tests/dbal')
-rw-r--r--tests/dbal/fixtures/massmail_crossjoin.xml8
-rw-r--r--tests/dbal/fixtures/three_users.xml8
-rw-r--r--tests/dbal/migration/schema.php44
-rw-r--r--tests/dbal/migrator_test.php25
-rw-r--r--tests/dbal/write_sequence_test.php2
5 files changed, 68 insertions, 19 deletions
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/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/schema.php b/tests/dbal/migration/schema.php
new file mode 100644
index 0000000000..98407eb1bd
--- /dev/null
+++ b/tests/dbal/migration/schema.php
@@ -0,0 +1,44 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2014 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+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/migrator_test.php b/tests/dbal/migrator_test.php
index c6b4c289d3..f22f5f5b30 100644
--- a/tests/dbal/migrator_test.php
+++ b/tests/dbal/migrator_test.php
@@ -16,6 +16,7 @@ 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
{
@@ -49,7 +50,8 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
dirname(__FILE__) . '/../../phpBB/',
'php',
'phpbb_',
- $tools
+ $tools,
+ new \phpbb\db\migration\helper()
);
$container = new phpbb_mock_container_builder();
@@ -267,4 +269,25 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
$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/write_sequence_test.php b/tests/dbal/write_sequence_test.php
index f382a971a5..5fe0fe8de9 100644
--- a/tests/dbal/write_sequence_test.php
+++ b/tests/dbal/write_sequence_test.php
@@ -42,8 +42,6 @@ class phpbb_dbal_write_sequence_test extends phpbb_database_test_case
'username_clean' => $username,
'user_permissions' => '',
'user_sig' => '',
- 'user_occ' => '',
- 'user_interests' => '',
));
$db->sql_query($sql);