Skip to content
Snippets Groups Projects
Commit 41a0e3f0 authored by Angie Byron's avatar Angie Byron
Browse files

#721210 by andypost: Preserve shutdown handlers in SimpleTest (Allow...

#721210 by andypost: Preserve shutdown handlers in SimpleTest (Allow SimpleTest module to run without Search module)
parent b04816e0
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -672,6 +672,13 @@ class DrupalWebTestCase extends DrupalTestCase {
*/
protected $originalUser = NULL;
/**
* The original shutdown handlers array, before it was cleaned for testing purposes.
*
* @var array
*/
protected $originalShutdownCallbacks = array();
/**
* HTTP authentication method
*/
......@@ -1103,6 +1110,14 @@ protected function setUp() {
$this->originalProfile = drupal_get_profile();
$clean_url_original = variable_get('clean_url', 0);
// Save and clean shutdown callbacks array because it static cached and
// will be changed by the test run. If we don't, then it will contain
// callbacks from both environments. So testing environment will try
// to call handlers from original environment.
$callbacks = &drupal_register_shutdown_function();
$this->originalShutdownCallbacks = $callbacks;
$callbacks = array();
// Generate temporary prefixed database to ensure that tests have a clean starting point.
$db_prefix_new = Database::getConnection()->prefixTables('{simpletest' . mt_rand(1000, 1000000) . '}');
db_update('simpletest_test_id')
......@@ -1256,6 +1271,11 @@ protected function tearDown() {
// Return the database prefix to the original.
$db_prefix = $this->originalPrefix;
// Restore original shutdown callbacks array to prevent original
// environment of calling handlers from test run.
$callbacks = &drupal_register_shutdown_function();
$callbacks = $this->originalShutdownCallbacks;
// Return the user to the original one.
$user = $this->originalUser;
drupal_save_session(TRUE);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment