protected function DrupalWebTestCase::tearDown in SimpleTest 6.2
Same name and namespace in other branches
- 7.2 drupal_web_test_case.php \DrupalWebTestCase::tearDown()
- 7 drupal_web_test_case.php \DrupalWebTestCase::tearDown()
Delete created files and temporary files directory, delete the tables created by setUp(), and reset the database prefix.
File
- ./
drupal_web_test_case.php, line 1358
Class
- DrupalWebTestCase
- Test case for typical Drupal tests.
Code
protected function tearDown() {
global $user, $language;
// In case a fatal error occured that was not in the test process read the
// log to pick up any fatal errors.
simpletest_log_read($this->testId, $this->databasePrefix, get_class($this), TRUE);
$emailCount = count(variable_get('drupal_test_email_collector', array()));
if ($emailCount) {
$message = format_plural($emailCount, '1 e-mail was sent during this test.', '@count e-mails were sent during this test.');
$this
->pass($message, t('E-mail'));
}
// Delete temporary files directory.
simpletest_file_unmanaged_delete_recursive($this->originalFileDirectory . '/simpletest/' . substr($this->databasePrefix, 10));
// Remove all prefixed tables (all the tables in the schema).
$schema = drupal_get_schema(NULL, TRUE);
$ret = array();
foreach ($schema as $name => $table) {
db_drop_table($ret, $name);
}
// Get back to the original connection.
$GLOBALS['db_prefix'] = $this->originalPrefix;
// Return the user to the original one.
$user = $this->originalUser;
session_save_session(TRUE);
// Bring back default language. (Drupal 6)
if (module_exists('locale')) {
drupal_init_language();
locale(NULL, NULL, TRUE);
}
// Ensure that internal logged in variable and cURL options are reset.
$this->loggedInUser = FALSE;
$this->additionalCurlOptions = array();
// Reload module list and implementations to ensure that test module hooks
// aren't called after tests.
module_list(TRUE, FALSE);
module_implements('', FALSE, TRUE);
// Rebuild caches.
$this
->refreshVariables();
// Reset language.
$language = $this->originalLanguage;
if ($this->originalLanguageDefault) {
$GLOBALS['conf']['language_default'] = $this->originalLanguageDefault;
}
// Close the CURL handler.
$this
->curlClose();
}