aboutsummaryrefslogtreecommitdiffstats
path: root/tests/dbal
diff options
context:
space:
mode:
Diffstat (limited to 'tests/dbal')
-rw-r--r--tests/dbal/migration/recall.php43
-rw-r--r--tests/dbal/migrator_test.php23
2 files changed, 66 insertions, 0 deletions
diff --git a/tests/dbal/migration/recall.php b/tests/dbal/migration/recall.php
new file mode 100644
index 0000000000..18d8b4a6d2
--- /dev/null
+++ b/tests/dbal/migration/recall.php
@@ -0,0 +1,43 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+class phpbb_dbal_migration_recall extends phpbb_db_migration
+{
+ function depends_on()
+ {
+ return array();
+ }
+
+ 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/migrator_test.php b/tests/dbal/migrator_test.php
index dd592d7b05..9c40eec15a 100644
--- a/tests/dbal/migrator_test.php
+++ b/tests/dbal/migrator_test.php
@@ -15,6 +15,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';
+require_once dirname(__FILE__) . '/migration/recall.php';
class phpbb_dbal_migrator_test extends phpbb_database_test_case
{
@@ -127,4 +128,26 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
$this->fail('False test 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);
+ }
}