summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2009-11-15 21:41:06 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2009-11-15 21:41:06 +0000
commite1d4dc7d6e37749e4642cbcaf236f26d01c9a0bc (patch)
tree5a360d1af2ca88547d13ea68c9fb1cd7822a0cf6 /modules
parent7fb94bda0d2c8e05edbfb02f335a5f27e0af780f (diff)
downloadbrdo-e1d4dc7d6e37749e4642cbcaf236f26d01c9a0bc.tar.gz
brdo-e1d4dc7d6e37749e4642cbcaf236f26d01c9a0bc.tar.bz2
#620688 follow-up by chx and effulgentsia: Fixed drupal_static_reset() is broken, with expanded test coverage.
Diffstat (limited to 'modules')
-rw-r--r--modules/simpletest/tests/bootstrap.test44
1 files changed, 44 insertions, 0 deletions
diff --git a/modules/simpletest/tests/bootstrap.test b/modules/simpletest/tests/bootstrap.test
index 18d671b39..e4ef2d717 100644
--- a/modules/simpletest/tests/bootstrap.test
+++ b/modules/simpletest/tests/bootstrap.test
@@ -374,3 +374,47 @@ class BootstrapTimerTestCase extends DrupalUnitTestCase {
$this->assertEqual($timer['count'], 2, t('Timer counted 2 instances of being started.'));
}
}
+
+/**
+ * Test that resetting static variables works.
+ */
+class BootstrapResettableStaticTestCase extends DrupalUnitTestCase {
+
+ public static function getInfo() {
+ return array(
+ 'name' => 'Resettable static variables test',
+ 'description' => 'Test that drupal_static() and drupal_static_reset() work.',
+ 'group' => 'Bootstrap',
+ );
+ }
+
+ /**
+ * Test that a variable reference returned by drupal_static() gets reset when
+ * drupal_static_reset() is called.
+ */
+ function testDrupalStatic() {
+ $name = __CLASS__ . '_' . __METHOD__;
+ $var = &drupal_static($name, 'foo');
+ $this->assertEqual($var, 'foo', t('Variable returned by drupal_static() was set to its default.'));
+
+ // Call the specific reset and the global reset each twice to ensure that
+ // multiple resets can be issued without odd side effects.
+ $var = 'bar';
+ drupal_static_reset($name);
+ $this->assertEqual($var, 'foo', t('Variable was reset after first invocation of name-specific reset.'));
+ $var = 'bar';
+ drupal_static_reset($name);
+ $this->assertEqual($var, 'foo', t('Variable was reset after second invocation of name-specific reset.'));
+
+ // Ensure that batch processing doesn't get reset.
+ $batch = &batch_get();
+ $batch_saved = $batch;
+ $var = 'bar';
+ drupal_static_reset();
+ $this->assertEqual($var, 'foo', t('Variable was reset after first invocation of global reset.'));
+ $var = 'bar';
+ drupal_static_reset();
+ $this->assertEqual($var, 'foo', t('Variable was reset after second invocation of global reset.'));
+ $batch = $batch_saved;
+ }
+}