mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-13 04:04:12 +02:00
[feature/migrations] Fix if method (and create a test for it)
PHPBB3-9737
This commit is contained in:
@@ -14,6 +14,7 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/db/db_tools.php';
|
||||
|
||||
require_once dirname(__FILE__) . '/migration/dummy.php';
|
||||
require_once dirname(__FILE__) . '/migration/unfulfillable.php';
|
||||
require_once dirname(__FILE__) . '/migration/if.php';
|
||||
|
||||
class phpbb_dbal_migrator_test extends phpbb_database_test_case
|
||||
{
|
||||
@@ -41,12 +42,6 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
|
||||
$this->migrator = new phpbb_db_migrator($this->config, $this->db, $this->db_tools, 'phpbb_migrations', dirname(__FILE__) . '/../../phpBB/', 'php', 'phpbb_', $tools);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
// cleanup
|
||||
$this->db_tools->sql_column_remove('phpbb_config', 'extra_column');
|
||||
}
|
||||
|
||||
public function test_update()
|
||||
{
|
||||
$this->migrator->set_migrations(array('phpbb_dbal_migration_dummy'));
|
||||
@@ -85,6 +80,9 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
|
||||
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()
|
||||
@@ -104,4 +102,29 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
|
||||
'Dummy migration was run, even though an unfulfillable migration was found.'
|
||||
);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
if ($migrator_test_if_true_failed)
|
||||
{
|
||||
$this->fail('True test failed');
|
||||
}
|
||||
|
||||
if ($migrator_test_if_false_failed)
|
||||
{
|
||||
$this->fail('False test failed');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user