aboutsummaryrefslogtreecommitdiffstats
path: root/tests/dbal
diff options
context:
space:
mode:
authorNathan Guse <nathaniel.guse@gmail.com>2013-01-09 18:24:32 -0600
committerNathan Guse <nathaniel.guse@gmail.com>2013-01-09 18:24:32 -0600
commit3d4c00619f1c96df7a4c6f8bc1c03eb21abf49d7 (patch)
treefcefc44c35f182224fefd4a43fc671514ea37daf /tests/dbal
parent28cd253d19f49a6450bce90a5b81df939d0be2c9 (diff)
downloadforums-3d4c00619f1c96df7a4c6f8bc1c03eb21abf49d7.tar
forums-3d4c00619f1c96df7a4c6f8bc1c03eb21abf49d7.tar.gz
forums-3d4c00619f1c96df7a4c6f8bc1c03eb21abf49d7.tar.bz2
forums-3d4c00619f1c96df7a4c6f8bc1c03eb21abf49d7.tar.xz
forums-3d4c00619f1c96df7a4c6f8bc1c03eb21abf49d7.zip
[feature/migrations] Reverse data functionality
If data step fails, attempt to roll back any previous calls from the migration that failed. Fix some failing tests PHPBB3-9737
Diffstat (limited to 'tests/dbal')
-rw-r--r--tests/dbal/migrator_tool_config_test.php27
-rw-r--r--tests/dbal/migrator_tool_module.php28
-rw-r--r--tests/dbal/migrator_tool_permission.php25
3 files changed, 76 insertions, 4 deletions
diff --git a/tests/dbal/migrator_tool_config_test.php b/tests/dbal/migrator_tool_config_test.php
index 27511519ca..7d582f230b 100644
--- a/tests/dbal/migrator_tool_config_test.php
+++ b/tests/dbal/migrator_tool_config_test.php
@@ -94,4 +94,31 @@ class phpbb_dbal_migrator_tool_config_test extends phpbb_test_case
}
$this->assertFalse(isset($this->config['foo']));
}
+
+ public function test_reverse()
+ {
+ $this->config->set('foo', 'bar');
+
+ try
+ {
+ $this->tool->reverse('add', 'foo');
+ }
+ catch (Exception $e)
+ {
+ $this->fail($e);
+ }
+ $this->assertFalse(isset($this->config['foo']));
+
+ $this->config->set('foo', 'bar');
+
+ try
+ {
+ $this->tool->reverse('update_if_equals', 'test', 'foo', 'bar');
+ }
+ catch (Exception $e)
+ {
+ $this->fail($e);
+ }
+ $this->assertEquals('test', $this->config['foo']);
+ }
}
diff --git a/tests/dbal/migrator_tool_module.php b/tests/dbal/migrator_tool_module.php
index 0b57cbfbcb..6937b6f8c5 100644
--- a/tests/dbal/migrator_tool_module.php
+++ b/tests/dbal/migrator_tool_module.php
@@ -29,10 +29,10 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case
$skip_add_log = true;
$db = $this->db = $this->new_dbal();
- $this->cache = new phpbb_cache_service(new phpbb_cache_driver_null());
+ $this->cache = new phpbb_cache_service(new phpbb_cache_driver_null(), new phpbb_config(array()), $this->db, $phpbb_root_path, $phpEx);
$user = $this->user = new phpbb_user();
- $this->tool = new phpbb_db_migration_tool_module($this->db, $this->cache, $this->user, $phpbb_root_path, $phpEx);
+ $this->tool = new phpbb_db_migration_tool_module($this->db, $this->cache, $this->user, $phpbb_root_path, $phpEx, 'phpbb_modules');
}
public function exists_data()
@@ -99,7 +99,7 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case
try
{
- $this->tool->add('acp', ACP_NEW_CAT, array(
+ $this->tool->add('acp', 'ACP_NEW_CAT', array(
'module_basename' => 'acp_new_module',
'module_langname' => 'ACP_NEW_MODULE',
'module_mode' => 'test',
@@ -125,4 +125,26 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case
}
$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.php b/tests/dbal/migrator_tool_permission.php
index 2229576cd9..438ab2b28e 100644
--- a/tests/dbal/migrator_tool_permission.php
+++ b/tests/dbal/migrator_tool_permission.php
@@ -26,7 +26,7 @@ class phpbb_dbal_migrator_tool_permission_test extends phpbb_database_test_case
parent::setup();
$db = $this->db = $this->new_dbal();
- $cache = $this->cache = new phpbb_cache_service(new phpbb_cache_driver_null());
+ $cache = $this->cache = new phpbb_cache_service(new phpbb_cache_driver_null(), new phpbb_config(array()), $this->db, $phpbb_root_path, $phpEx);
$this->auth = new phpbb_auth();
$this->tool = new phpbb_db_migration_tool_permission($this->db, $this->cache, $this->auth, $phpbb_root_path, $phpEx);
@@ -133,4 +133,27 @@ class phpbb_dbal_migrator_tool_permission_test extends phpbb_database_test_case
}
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));
+ }
}