summaryrefslogtreecommitdiff
path: root/modules/simpletest
diff options
context:
space:
mode:
authorDavid Rothstein <drothstein@gmail.com>2015-10-10 11:40:33 -0400
committerDavid Rothstein <drothstein@gmail.com>2015-10-10 11:40:33 -0400
commite105186172a34f4c3ba05af594e34dfa63083b72 (patch)
treebd949b90bceb238b5133197942cee47b740d7620 /modules/simpletest
parent3c8b182b79850c497b24c79c1c3e56999b3da12a (diff)
downloadbrdo-e105186172a34f4c3ba05af594e34dfa63083b72.tar.gz
brdo-e105186172a34f4c3ba05af594e34dfa63083b72.tar.bz2
Issue #496170 by stefan.r, chx, Fabianx, jbrauer, David_Rothstein, roderik, rwohleb, pounard, kenorb, Jose Reyero, joelpittet, catch: module_implements() cache can be polluted by module_invoke_all() being called (in)directly prior to full bootstrap completion
Diffstat (limited to 'modules/simpletest')
-rw-r--r--modules/simpletest/simpletest.info1
-rw-r--r--modules/simpletest/tests/boot.test38
-rw-r--r--modules/simpletest/tests/boot_test_1.info6
-rw-r--r--modules/simpletest/tests/boot_test_1.module21
-rw-r--r--modules/simpletest/tests/boot_test_2.info6
-rw-r--r--modules/simpletest/tests/boot_test_2.module13
6 files changed, 85 insertions, 0 deletions
diff --git a/modules/simpletest/simpletest.info b/modules/simpletest/simpletest.info
index 7b139ba3d..1aec619f5 100644
--- a/modules/simpletest/simpletest.info
+++ b/modules/simpletest/simpletest.info
@@ -11,6 +11,7 @@ configure = admin/config/development/testing/settings
files[] = tests/actions.test
files[] = tests/ajax.test
files[] = tests/batch.test
+files[] = tests/boot.test
files[] = tests/bootstrap.test
files[] = tests/cache.test
files[] = tests/common.test
diff --git a/modules/simpletest/tests/boot.test b/modules/simpletest/tests/boot.test
new file mode 100644
index 000000000..562b082e8
--- /dev/null
+++ b/modules/simpletest/tests/boot.test
@@ -0,0 +1,38 @@
+<?php
+
+/**
+ * Perform early bootstrap tests.
+ */
+class EarlyBootstrapTestCase extends DrupalWebTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Early bootstrap test',
+ 'description' => 'Confirm that calling module_implements() during early bootstrap does not pollute the module_implements() cache.',
+ 'group' => 'System',
+ );
+ }
+
+ function setUp() {
+ parent::setUp('boot_test_1', 'boot_test_2');
+ }
+
+ /**
+ * Test hook_boot() on both regular and "early exit" pages.
+ */
+ public function testHookBoot() {
+ $paths = array('', 'early_exit');
+ foreach ($paths as $path) {
+ // Empty the module_implements() caches.
+ module_implements(NULL, FALSE, TRUE);
+ // Do a request to the front page, which will call module_implements()
+ // during hook_boot().
+ $this->drupalGet($path);
+ // Reset the static cache so we get implementation data from the persistent
+ // cache.
+ drupal_static_reset();
+ // Make sure we get a full list of all modules implementing hook_help().
+ $modules = module_implements('help');
+ $this->assertTrue(in_array('boot_test_2', $modules));
+ }
+ }
+}
diff --git a/modules/simpletest/tests/boot_test_1.info b/modules/simpletest/tests/boot_test_1.info
new file mode 100644
index 000000000..a6f2ffb60
--- /dev/null
+++ b/modules/simpletest/tests/boot_test_1.info
@@ -0,0 +1,6 @@
+name = Early bootstrap tests
+description = A support module for hook_boot testing.
+core = 7.x
+package = Testing
+version = VERSION
+hidden = TRUE
diff --git a/modules/simpletest/tests/boot_test_1.module b/modules/simpletest/tests/boot_test_1.module
new file mode 100644
index 000000000..a452e2897
--- /dev/null
+++ b/modules/simpletest/tests/boot_test_1.module
@@ -0,0 +1,21 @@
+<?php
+
+/**
+ * @file
+ * Tests calling module_implements() during hook_boot() invocation.
+ */
+
+/**
+ * Implements hook_boot().
+ */
+function boot_test_1_boot() {
+ // Calling module_implements during hook_boot() will return "vital" modules
+ // only, and this list of modules will be statically cached.
+ module_implements('help');
+ // Define a special path to test that the static cache isn't written away
+ // if we exit before having completed the bootstrap.
+ if ($_GET['q'] == 'early_exit') {
+ module_implements_write_cache();
+ exit();
+ }
+}
diff --git a/modules/simpletest/tests/boot_test_2.info b/modules/simpletest/tests/boot_test_2.info
new file mode 100644
index 000000000..f421997d4
--- /dev/null
+++ b/modules/simpletest/tests/boot_test_2.info
@@ -0,0 +1,6 @@
+name = Early bootstrap tests
+description = A support module for hook_boot hook testing.
+core = 7.x
+package = Testing
+version = VERSION
+hidden = TRUE
diff --git a/modules/simpletest/tests/boot_test_2.module b/modules/simpletest/tests/boot_test_2.module
new file mode 100644
index 000000000..c3ab8d61d
--- /dev/null
+++ b/modules/simpletest/tests/boot_test_2.module
@@ -0,0 +1,13 @@
+<?php
+
+/**
+ * @file
+ * Defines a hook_help() implementation in a non-"bootstrap" module.
+ */
+
+/**
+ * Implements hook_help().
+ */
+function boot_test_2_help($path, $arg) {
+ // Empty hook.
+}