diff --git a/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module index 4f5e692..13f9dd6 100644 --- a/core/modules/simpletest/simpletest.module +++ b/core/modules/simpletest/simpletest.module @@ -304,9 +304,17 @@ function simpletest_phpunit_configuration_filepath() { * The results as returned by exec(). */ function simpletest_phpunit_run_command(array $unescaped_test_classnames, $phpunit_file, &$status = NULL) { + global $base_url; // Setup an environment variable containing the database connection so that // functional tests can connect to the database. putenv('SIMPLETEST_DB=' . Database::getConnectionInfoAsUrl()); + + // Setup an environment variable containing the base URL so that functional + // tests can browser the site under test. + $existing_simpletest_base_url = getenv('SIMPLETEST_BASE_URL'); + if ($base_url) { + putenv('SIMPLETEST_BASE_URL=' . $base_url); + } $phpunit_bin = simpletest_phpunit_command(); $command = array( @@ -344,6 +352,9 @@ function simpletest_phpunit_run_command(array $unescaped_test_classnames, $phpun chdir($old_cwd); putenv('SIMPLETEST_DB='); + if ($base_url) { + putenv('SIMPLETEST_BASE_URL=' . $existing_simpletest_base_url); + } return $ret; } diff --git a/core/modules/simpletest/src/Form/SimpletestTestForm.php b/core/modules/simpletest/src/Form/SimpletestTestForm.php index e645705..8ad5fe2 100644 --- a/core/modules/simpletest/src/Form/SimpletestTestForm.php +++ b/core/modules/simpletest/src/Form/SimpletestTestForm.php @@ -199,7 +199,6 @@ public function buildForm(array $form, FormStateInterface $form_state) { * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { - global $base_url; // Test discovery does not run upon form submission. simpletest_classloader_register(); @@ -219,7 +218,6 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $tests_list = array_filter($form_state->getValue('tests')); if (!empty($tests_list)) { - putenv('SIMPLETEST_BASE_URL=' . $base_url); $test_id = simpletest_run_tests($tests_list, 'drupal'); $form_state->setRedirect( 'simpletest.result_form',