summaryrefslogtreecommitdiff
path: root/modules/simpletest
diff options
context:
space:
mode:
Diffstat (limited to 'modules/simpletest')
-rw-r--r--modules/simpletest/tests/update.test28
-rw-r--r--modules/simpletest/tests/update_test_1.install29
-rw-r--r--modules/simpletest/tests/update_test_2.install19
-rw-r--r--modules/simpletest/tests/update_test_3.install2
4 files changed, 78 insertions, 0 deletions
diff --git a/modules/simpletest/tests/update.test b/modules/simpletest/tests/update.test
index 0809690e6..c4d382847 100644
--- a/modules/simpletest/tests/update.test
+++ b/modules/simpletest/tests/update.test
@@ -86,3 +86,31 @@ class UpdateDependencyMissingTestCase extends DrupalWebTestCase {
}
}
+/**
+ * Tests for the invocation of hook_update_dependencies().
+ */
+class UpdateDependencyHookInvocationTestCase extends DrupalWebTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Update dependency hook invocation',
+ 'description' => 'Test that the hook invocation for determining update dependencies works correctly.',
+ 'group' => 'Update API',
+ );
+ }
+
+ function setUp() {
+ parent::setUp('update_test_1', 'update_test_2');
+ require_once DRUPAL_ROOT . '/includes/update.inc';
+ }
+
+ /**
+ * Test the structure of the array returned by hook_update_dependencies().
+ */
+ function testHookUpdateDependencies() {
+ $update_dependencies = update_retrieve_dependencies();
+ $this->assertTrue($update_dependencies['system'][7000]['update_test_1'] == 7000, t('An update function that has a dependency on two separate modules has the first dependency recorded correctly.'));
+ $this->assertTrue($update_dependencies['system'][7000]['update_test_2'] == 7001, t('An update function that has a dependency on two separate modules has the second dependency recorded correctly.'));
+ $this->assertTrue($update_dependencies['system'][7001]['update_test_1'] == 7002, t('An update function that depends on more than one update from the same module only has the dependency on the higher-numbered update function recorded.'));
+ }
+}
+
diff --git a/modules/simpletest/tests/update_test_1.install b/modules/simpletest/tests/update_test_1.install
index 96e8787b3..ac69a358e 100644
--- a/modules/simpletest/tests/update_test_1.install
+++ b/modules/simpletest/tests/update_test_1.install
@@ -7,6 +7,35 @@
*/
/**
+ * Implements hook_update_dependencies().
+ *
+ * @see update_test_2_update_dependencies()
+ */
+function update_test_1_update_dependencies() {
+ // These dependencies are used in combination with those declared in
+ // update_test_2_update_dependencies() for the sole purpose of testing that
+ // the results of hook_update_dependencies() are collected correctly and have
+ // the correct array structure. Therefore, we use updates from System module
+ // (which have already run), so that they will not get in the way of other
+ // tests.
+ $dependencies['system'][7000] = array(
+ // Compare to update_test_2_update_dependencies(), where the same System
+ // module update function is forced to depend on an update function from a
+ // different module. This allows us to test that both dependencies are
+ // correctly recorded.
+ 'update_test_1' => 7000,
+ );
+ $dependencies['system'][7001] = array(
+ // Compare to update_test_2_update_dependencies(), where the same System
+ // module update function is forced to depend on a different update
+ // function within the same module. This allows us to test that only the
+ // dependency on the higher-numbered update function is recorded.
+ 'update_test_1' => 7002,
+ );
+ return $dependencies;
+}
+
+/**
* Dummy update_test_1 update 7000.
*/
function update_test_1_update_7000() {
diff --git a/modules/simpletest/tests/update_test_2.install b/modules/simpletest/tests/update_test_2.install
index e2b4fb25f..e12b77b93 100644
--- a/modules/simpletest/tests/update_test_2.install
+++ b/modules/simpletest/tests/update_test_2.install
@@ -8,11 +8,30 @@
/**
* Implements hook_update_dependencies().
+ *
+ * @see update_test_1_update_dependencies()
+ * @see update_test_3_update_dependencies()
*/
function update_test_2_update_dependencies() {
+ // Combined with update_test_3_update_dependencies(), we are declaring here
+ // that these two modules run updates in the following order:
+ // 1. update_test_2_update_7000()
+ // 2. update_test_3_update_7000()
+ // 3. update_test_2_update_7001()
+ // 4. update_test_2_update_7002()
$dependencies['update_test_2'][7001] = array(
'update_test_3' => 7000,
);
+
+ // These are coordinated with the corresponding dependencies declared in
+ // update_test_1_update_dependencies().
+ $dependencies['system'][7000] = array(
+ 'update_test_2' => 7001,
+ );
+ $dependencies['system'][7001] = array(
+ 'update_test_1' => 7001,
+ );
+
return $dependencies;
}
diff --git a/modules/simpletest/tests/update_test_3.install b/modules/simpletest/tests/update_test_3.install
index 952ebf0b6..195412327 100644
--- a/modules/simpletest/tests/update_test_3.install
+++ b/modules/simpletest/tests/update_test_3.install
@@ -8,6 +8,8 @@
/**
* Implements hook_update_dependencies().
+ *
+ * @see update_test_2_update_dependencies()
*/
function update_test_3_update_dependencies() {
$dependencies['update_test_3'][7000] = array(