[ticket/12432] Adding unit test

PHPBB3-12432
This commit is contained in:
Nicofuma 2014-04-26 12:12:51 +02:00
parent 595f831589
commit 28176b0746
2 changed files with 17 additions and 0 deletions

View file

@ -35,6 +35,14 @@ class phpbb_dbal_migration_revert extends \phpbb\db\migration\migration
{ {
return array( return array(
array('config.add', array('foobartest', 0)), 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;
}
} }

View file

@ -174,10 +174,14 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
public function test_revert() public function test_revert()
{ {
global $migrator_test_revert_counter;
// Make sure there are no other migrations in the db, this could cause issues // Make sure there are no other migrations in the db, this could cause issues
$this->db->sql_query("DELETE FROM phpbb_migrations"); $this->db->sql_query("DELETE FROM phpbb_migrations");
$this->migrator->load_migration_state(); $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->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'));
@ -219,6 +223,11 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
{ {
$this->fail('Revert did not remove test_column.'); $this->fail('Revert did not remove test_column.');
} }
if ($migrator_test_revert_counter != 1)
{
$this->fail('Revert did not recall the customs functions.');
}
} }
public function test_fail() public function test_fail()