diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigLocaleOverride.php b/core/modules/config/lib/Drupal/config/Tests/ConfigLocaleOverride.php index 24edb76..f2673c8 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigLocaleOverride.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigLocaleOverride.php @@ -223,13 +223,12 @@ function testConfigLocaleLanguageOverride() { * Tests locale override in combination with global overrides. */ function testConfigLocaleUserAndGlobalOverride() { - global $conf; - // Globally override value for the keys in config_test.system. Although we // override the foo key, there are also language overrides, which trump // global overrides so the 'foo' key override will never surface. - $conf['config_test.system']['foo'] = 'global bar'; - $conf['config_test.system']['404'] = 'global herp'; + $config['config_test.system']['foo'] = 'global bar'; + $config['config_test.system']['404'] = 'global herp'; + $this->globalConfig->setConfig($config); $this->installSchema('system', 'variable'); $this->installConfig(array('language')); @@ -251,7 +250,7 @@ function testConfigLocaleUserAndGlobalOverride() { $user_config_context->setAccount($account); $config = \Drupal::config('config_test.system'); $this->assertIdentical($config->get('foo'), 'fr bar'); - // Ensure the value overriden from global $conf works. + // Ensure the value overriden from global $config works. $this->assertIdentical($config->get('404'), 'global herp'); // Ensure that we get the expected value when we leave the user context. The diff --git a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php index efdb851..9ac43d5 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php @@ -1183,9 +1183,13 @@ protected function tearDown() { // Restore original statics and globals. \Drupal::setContainer($this->originalContainer); $GLOBALS['config_directories'] = $this->originalConfigDirectories; + if (isset($this->originalPrefix)) { drupal_valid_test_ua($this->originalPrefix); } + else { + drupal_valid_test_ua(FALSE); + } // Restore original shutdown callbacks. $callbacks = &drupal_register_shutdown_function(); diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Tests/MissingCheckedRequirementsTest.php b/core/modules/simpletest/lib/Drupal/simpletest/Tests/MissingCheckedRequirementsTest.php index 61d6401..8725e88 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/Tests/MissingCheckedRequirementsTest.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/Tests/MissingCheckedRequirementsTest.php @@ -39,7 +39,7 @@ function setUp() { * Overrides checkRequirements(). */ protected function checkRequirements() { - if (drupal_valid_test_ua()) { + if (!empty($GLOBALS['drupal_test_info']['in_child_site'])) { return array( 'Test is not allowed to run.' ); @@ -53,7 +53,7 @@ protected function checkRequirements() { protected function testCheckRequirements() { // If this is the main request, run the web test script and then assert // that the child tests did not run. - if (!drupal_valid_test_ua()) { + if (empty($GLOBALS['drupal_test_info']['in_child_site'])) { // Run this test from web interface. $edit['Drupal\simpletest\Tests\MissingCheckedRequirementsTest'] = TRUE; $this->drupalPostForm('admin/config/development/testing', $edit, t('Run tests')); diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Tests/SimpleTestTest.php b/core/modules/simpletest/lib/Drupal/simpletest/Tests/SimpleTestTest.php index 2a19a5c1..ccc82bf 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/Tests/SimpleTestTest.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/Tests/SimpleTestTest.php @@ -339,6 +339,6 @@ function asText(\SimpleXMLElement $element) { * Check if the test is being run from inside a CURL request. */ function inCURL() { - return (bool) drupal_valid_test_ua(); + return (bool) !empty($GLOBALS['drupal_test_info']['in_child_site']; } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Installer/InstallerTranslationTest.php b/core/modules/system/lib/Drupal/system/Tests/Installer/InstallerTranslationTest.php index 69b3352..7591381 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Installer/InstallerTranslationTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Installer/InstallerTranslationTest.php @@ -24,8 +24,6 @@ public static function getInfo() { } protected function setUp() { - global $conf; - // When running tests through the SimpleTest UI (vs. on the command line), // SimpleTest's batch conflicts with the installer's batch. Batch API does // not support the concept of nested batches (in which the nested is not @@ -33,46 +31,35 @@ protected function setUp() { // Back up the currently running SimpleTest batch. $this->originalBatch = batch_get(); - // Add the translations directory so we can retrieve German translations. - $conf['locale.settings']['translation.path'] = drupal_get_path('module', 'simpletest') . '/files/translations'; - $conf['language_default']['name'] = 'German'; - $conf['language_default']['id'] = 'de'; - // Create the database prefix for this test. $this->prepareDatabasePrefix(); // Prepare the environment for running tests. $this->prepareEnvironment(); if (!$this->setupEnvironment) { - return FALSE; + throw new \RuntimeException('Failed to set up test environment.'); } - // Reset all statics and variables to perform tests in a clean environment. - $conf = array(); - drupal_static_reset(); - // Change the database prefix. // All static variables need to be reset before the database prefix is // changed, since \Drupal\Core\Utility\CacheArray implementations attempt to // write back to persistent caches when they are destructed. $this->changeDatabasePrefix(); if (!$this->setupDatabasePrefix) { - return FALSE; - } - $variable_groups = array( - 'system.file' => array( - 'path.private' => $this->private_files_directory, - 'path.temporary' => $this->temp_files_directory, - ), - 'locale.settings' => array( - 'translation.path' => $this->translation_files_directory, - ), - ); - foreach ($variable_groups as $config_base => $variables) { - foreach ($variables as $name => $value) { - NestedArray::setValue($GLOBALS['conf'], array_merge(array($config_base), explode('.', $name)), $value); - } + throw new \RuntimeException('Failed to set up database prefix.'); } + + // After preparing the environment and changing the database prefix, we are + // in a valid test environment. + drupal_valid_test_ua($this->databasePrefix); + + // Remove all configuration overrides. + $this->globalConfig->setConfig(array()); + + $this->globalConfig->set('system.file', 'path.private', $this->private_files_directory); + $this->globalConfig->set('system.file', 'path.temporary', $this->temp_files_directory); + $this->globalConfig->set('locale.settings', 'translation.path', $this->translation_files_directory); + $settings['conf_path'] = (object) array( 'value' => $this->public_files_directory, 'required' => TRUE, @@ -81,10 +68,31 @@ protected function setUp() { 'value' => array(), 'required' => TRUE, ); + $settings['config']['system.file'] = (object) array( + 'value' => array( + 'path' => array( + 'private' => $this->private_files_directory, + 'temporary' => $this->temp_files_directory, + ), + ), + 'required' => TRUE, + ); + // Add the translations directory so we can retrieve German translations. + $settings['config']['locale.settings'] = (object) array( + 'value' => array( + 'translation' => array( + 'path' => drupal_get_path('module', 'simpletest') . '/files/translations', + ), + ), + 'required' => TRUE, + ); $this->writeSettings($settings); // Submit the installer with German language. - $this->drupalPostForm($GLOBALS['base_url'] . '/core/install.php', array('langcode' => 'de'), 'Save and continue'); + $edit = array( + 'langcode' => 'de', + ); + $this->drupalPostForm($GLOBALS['base_url'] . '/core/install.php', $edit, 'Save and continue'); // On the following page where installation profile is being selected the // interface should be already translated, so there is no "Set up database" @@ -99,9 +107,13 @@ protected function setUp() { // Get the "Save and continue" submit button translated value from the // translated interface. $submit_value = (string) current($this->xpath('//input[@type="submit"]/@value')); + $this->assertNotEqual($submit_value, 'Save and continue'); - // Submit the standard profile installation. - $this->drupalPostForm(NULL, array('profile' => 'standard'), $submit_value); + // Submit the Minimal profile installation. + $edit = array( + 'profile' => 'minimal', + ); + $this->drupalPostForm(NULL, $edit, $submit_value); // Submit the next step. $this->drupalPostForm(NULL, array(), $submit_value); @@ -113,13 +125,13 @@ protected function setUp() { } $this->rebuildContainer(); - foreach ($variable_groups as $config_base => $variables) { - $config = \Drupal::config($config_base); - foreach ($variables as $name => $value) { - $config->set($name, $value); - } - $config->save(); - } + \Drupal::config('system.file') + ->set('path.private', $this->private_files_directory) + ->set('path.temporary', $this->temp_files_directory) + ->save(); + \Drupal::config('locale.settings') + ->set('translation.path', $this->translation_files_directory) + ->save(); // Submit site configuration form. $this->drupalPostForm(NULL, array(