class BootstrapResettableStaticTestCase

Test that resetting static variables works.

Hierarchy

Expanded class hierarchy of BootstrapResettableStaticTestCase

File

drupal/modules/simpletest/tests/bootstrap.test, line 668

View source
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', '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', 'Variable was reset after first invocation of name-specific reset.');
    $var = 'bar';
    drupal_static_reset($name);
    $this
      ->assertEqual($var, 'foo', 'Variable was reset after second invocation of name-specific reset.');
    $var = 'bar';
    drupal_static_reset();
    $this
      ->assertEqual($var, 'foo', 'Variable was reset after first invocation of global reset.');
    $var = 'bar';
    drupal_static_reset();
    $this
      ->assertEqual($var, 'foo', 'Variable was reset after second invocation of global reset.');
  }

}

Members

Namesort ascending Modifiers Type Description Overrides
DrupalUnitTestCase::__construct function Constructor for DrupalUnitTestCase. Overrides DrupalTestCase::__construct
DrupalUnitTestCase::tearDown protected function 1
DrupalUnitTestCase::setUp protected function Sets up unit test environment. 8
DrupalTestCase::verbose protected function Logs a verbose message in a text file.
DrupalTestCase::run public function Run all tests in this class.
DrupalTestCase::randomString public static function Generates a random string of ASCII characters of codes 32 to 126.
DrupalTestCase::randomName public static function Generates a random string containing letters and numbers.
DrupalTestCase::pass protected function Fire an assertion that is always positive.
DrupalTestCase::insertAssert public static function Store an assertion from outside the testing context.
DrupalTestCase::getDatabaseConnection public static function Returns the database connection to the site running Simpletest.
DrupalTestCase::getAssertionCall protected function Cycles through backtrace until the first non-assertion method is found.
DrupalTestCase::generatePermutations public static function Converts a list of possible parameters into a stack of permutations.
DrupalTestCase::fail protected function Fire an assertion that is always negative.
DrupalTestCase::exceptionHandler protected function Handle exceptions.
DrupalTestCase::errorHandler public function Handle errors during test runs. 1
DrupalTestCase::error protected function Fire an error assertion. 1
DrupalTestCase::deleteAssert public static function Delete an assertion record by message ID.
DrupalTestCase::assertTrue protected function Check to see if a value is not false (not an empty string, 0, NULL, or FALSE).
DrupalTestCase::assertNull protected function Check to see if a value is NULL.
DrupalTestCase::assertNotNull protected function Check to see if a value is not NULL.
DrupalTestCase::assertNotIdentical protected function Check to see if two values are not identical.
DrupalTestCase::assertNotEqual protected function Check to see if two values are not equal.
DrupalTestCase::assertIdentical protected function Check to see if two values are identical.
DrupalTestCase::assertFalse protected function Check to see if a value is false (an empty string, 0, NULL, or FALSE).
DrupalTestCase::assertEqual protected function Check to see if two values are equal.
DrupalTestCase::assert protected function Internal helper: stores the assert.
DrupalTestCase::$verboseDirectoryUrl protected property URL to the verbose output file directory.
DrupalTestCase::$timeLimit protected property Time limit for the test.
DrupalTestCase::$testId protected property The test run ID.
DrupalTestCase::$skipClasses protected property This class is skipped when looking for the source of an assertion.
DrupalTestCase::$setupEnvironment protected property
DrupalTestCase::$setupDatabasePrefix protected property
DrupalTestCase::$setup protected property Flag to indicate whether the test has been set up.
DrupalTestCase::$results public property Current results of this test case.
DrupalTestCase::$originalFileDirectory protected property The original file directory, before it was changed for testing purposes.
DrupalTestCase::$databasePrefix protected property The database prefix of this test run.
DrupalTestCase::$assertions protected property Assertions thrown in that test case.
BootstrapResettableStaticTestCase::testDrupalStatic function Test that a variable reference returned by drupal_static() gets reset when drupal_static_reset() is called.
BootstrapResettableStaticTestCase::getInfo public static function