diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index e7d9938..bd5934d 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -1156,13 +1156,7 @@ function install_settings_form($form, &$form_state, &$install_state) { */ function install_settings_form_validate($form, &$form_state) { $driver = $form_state['values']['driver']; - - // @todo Remove when PIFR submits 'prefix' instead of 'db_prefix'. - if (!empty($form_state['input'][$driver]['db_prefix'])) { - $form_state['values'][$driver]['prefix'] = $form_state['input'][$driver]['db_prefix']; - } $database = $form_state['values'][$driver]; - $drivers = drupal_get_database_types(); $reflection = new \ReflectionClass($drivers[$driver]); $install_namespace = $reflection->getNamespaceName(); @@ -1227,6 +1221,7 @@ function install_settings_form_submit($form, &$form_state) { global $install_state, $conf; // Update global settings array and save. + $settings = array(); $database = $form_state['storage']['database']; $settings['databases']['default']['default'] = (object) array( 'value' => $database, diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php index 2d10435..70d297c 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php @@ -67,11 +67,9 @@ protected function stateSet(array $values) { $this->container->get('state')->setMultiple($values); // Refresh in-memory static state/config caches and static variables. $this->refreshVariables(); - // Clear language negotiation plugin definitions, in order to pick up - // conditional manipulations in alter hooks controlled by state flags. - $this->container->get('plugin.manager.language_negotiation_method')->clearCachedDefinitions(); - // Reset state of LanguageManager (and implicitly LanguageNegotiator). - $this->languageManager()->reset(); + // Refresh/rewrite language negotiation configuration, in order to pick up + // the manipulations performed by language_test module's info alter hooks. + $this->container->get('language_negotiator')->purgeConfiguration(); } /** @@ -116,19 +114,13 @@ function testInfoAlterations() { $this->stateSet(array( 'language_test.language_negotiation_info_alter' => TRUE, )); - $this->drupalGet('admin/config/regional/language/detection'); - $this->assertNoFieldByName($form_field, NULL, 'Interface language negotiation method unavailable.'); - // @todo Given the derived global $conf variables state tracking and - // automated rewriting of variable values upon - // LanguageNegotiator::purgeConfiguration(), it is impossible to - // synchronize the global $conf state correctly between the child site and - // the test runner (a refresh of global $conf variables would have to - // happen right within the functional code). Re-enable this assertion when - // converting language negotiation variables into configuration/state. - $negotiation = \Drupal::config('language.types')->get('negotiation.' . $type . '.enabled') ?: array(); + $negotiation = $this->container->get('config.factory')->get('language.types')->get('negotiation.' . $type . '.enabled'); $this->assertFalse(isset($negotiation[$interface_method_id]), 'Interface language negotiation method removed from the stored settings.'); + $this->drupalGet('admin/config/regional/language/detection'); + $this->assertNoFieldByName($form_field, NULL, 'Interface language negotiation method unavailable.'); + // Check that type-specific language negotiation methods can be assigned // only to the corresponding language types. foreach ($this->languageManager()->getLanguageTypes() as $type) { @@ -143,7 +135,7 @@ function testInfoAlterations() { // Check language negotiation results. $this->drupalGet(''); - $last = \Drupal::state()->get('language_test.language_negotiation_last'); + $last = $this->container->get('state')->get('language_test.language_negotiation_last'); foreach ($this->languageManager()->getDefinedLanguageTypes() as $type) { $langcode = $last[$type]; $value = $type == Language::TYPE_CONTENT || strpos($type, 'test') !== FALSE ? 'it' : 'en'; @@ -166,7 +158,7 @@ function testInfoAlterations() { // Check that unavailable language negotiation methods are not present in // the negotiation settings. - $negotiation = \Drupal::config('language.types')->get('negotiation.' . $type . '.enabled') ?: array(); + $negotiation = $this->container->get('config.factory')->get('language.types')->get('negotiation.' . $type . '.enabled'); $this->assertFalse(isset($negotiation[$test_method_id]), 'The disabled test language negotiation method is not part of the content language negotiation settings.'); // Check that configuration page presents the correct options and settings. @@ -181,7 +173,7 @@ protected function checkFixedLanguageTypes() { $configurable = $this->languageManager()->getLanguageTypes(); foreach ($this->languageManager()->getDefinedLanguageTypesInfo() as $type => $info) { if (!in_array($type, $configurable) && isset($info['fixed'])) { - $negotiation = \Drupal::config('language.types')->get('negotiation.' . $type . '.enabled') ?: array(); + $negotiation = $this->container->get('config.factory')->get('language.types')->get('negotiation.' . $type . '.enabled'); $equal = count($info['fixed']) == count($negotiation); while ($equal && list($id) = each($negotiation)) { list(, $info_id) = each($info['fixed']); diff --git a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php index f29224b..13a353d 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php @@ -834,7 +834,6 @@ public function run(array $methods = array()) { } try { $this->tearDown(); - break; } catch (\Exception $e) { $this->exceptionHandler($e); @@ -939,12 +938,6 @@ protected function beforePrepareEnvironment() { * consequences) and it must not be callable or overridable by test classes. * * @see TestBase::beforePrepareEnvironment() - * - * This method is private as it must only be called once by TestBase::run() - * (multiple invocations for the same test would have unpredictable - * consequences) and it must not be callable or overridable by test classes. - * - * @see TestBase::beforePrepareEnvironment() */ private function prepareEnvironment() { global $user, $conf; @@ -1160,6 +1153,10 @@ private function restoreEnvironment() { } } + // In case a fatal error occurred 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)); + // Delete test site directory. file_unmanaged_delete_recursive($this->siteDirectory, array($this, 'filePreDeleteCallback')); @@ -1190,16 +1187,6 @@ private function restoreEnvironment() { \Drupal::setContainer($this->originalContainer); $GLOBALS['config_directories'] = $this->originalConfigDirectories; - // Re-initialize original stream wrappers of the parent site. - // This must happen after static variables have been reset and the original - // container and $config_directories are restored, as simpletest_log_read() - // uses the public stream wrapper to locate the error.log. - file_get_stream_wrappers(); - - // In case a fatal error occurred 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); - if (isset($this->originalPrefix)) { drupal_valid_test_ua($this->originalPrefix); } diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Tests/BrokenSetUpTest.php b/core/modules/simpletest/lib/Drupal/simpletest/Tests/BrokenSetUpTest.php index 42b786a..8981519 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/Tests/BrokenSetUpTest.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/Tests/BrokenSetUpTest.php @@ -28,6 +28,13 @@ class BrokenSetUpTest extends WebTestBase { */ public static $modules = array('simpletest'); + /** + * The path to the shared trigger file. + * + * @var string + */ + protected $sharedTriggerFile; + public static function getInfo() { return array( 'name' => 'Broken SimpleTest method', @@ -38,15 +45,20 @@ public static function getInfo() { function setUp() { // If the test is being run from the main site, set up normally. - if (!drupal_valid_test_ua()) { + if (!$this->isInChildSite()) { parent::setUp(); + + $this->sharedTriggerFile = $this->public_files_directory . '/trigger'; + // Create and log in user. $admin_user = $this->drupalCreateUser(array('administer unit tests')); $this->drupalLogin($admin_user); } // If the test is being run from within simpletest, set up the broken test. else { - if (file_get_contents($this->originalFileDirectory . '/simpletest/trigger') === 'setup') { + $this->sharedTriggerFile = $this->originalFileDirectory . '/trigger'; + + if (file_get_contents($this->sharedTriggerFile) === 'setup') { throw new \Exception('Broken setup'); } $this->pass('The setUp() method has run.'); @@ -55,13 +67,13 @@ function setUp() { function tearDown() { // If the test is being run from the main site, tear down normally. - if (!drupal_valid_test_ua()) { - unlink($this->originalFileDirectory . '/simpletest/trigger'); + if (!$this->isInChildSite()) { + unlink($this->sharedTriggerFile); parent::tearDown(); } // If the test is being run from within simpletest, output a message. else { - if (file_get_contents($this->originalFileDirectory . '/simpletest/trigger') === 'teardown') { + if (file_get_contents($this->sharedTriggerFile) === 'teardown') { throw new \Exception('Broken teardown'); } $this->pass('The tearDown() method has run.'); @@ -74,9 +86,9 @@ function tearDown() { function testMethod() { // If the test is being run from the main site, run it again from the web // interface within the simpletest child site. - if (!drupal_valid_test_ua()) { + if (!$this->isInChildSite()) { // Verify that a broken setUp() method is caught. - file_put_contents($this->originalFileDirectory . '/simpletest/trigger', 'setup'); + file_put_contents($this->sharedTriggerFile, 'setup'); $edit['Drupal\simpletest\Tests\BrokenSetUpTest'] = TRUE; $this->drupalPostForm('admin/config/development/testing', $edit, t('Run tests')); $this->assertRaw('Broken setup'); @@ -87,7 +99,7 @@ function testMethod() { $this->assertNoRaw('The tearDown() method has run.'); // Verify that a broken tearDown() method is caught. - file_put_contents($this->originalFileDirectory . '/simpletest/trigger', 'teardown'); + file_put_contents($this->sharedTriggerFile, 'teardown'); $edit['Drupal\simpletest\Tests\BrokenSetUpTest'] = TRUE; $this->drupalPostForm('admin/config/development/testing', $edit, t('Run tests')); $this->assertNoRaw('Broken setup'); @@ -98,7 +110,7 @@ function testMethod() { $this->assertNoRaw('The tearDown() method has run.'); // Verify that a broken test method is caught. - file_put_contents($this->originalFileDirectory . '/simpletest/trigger', 'test'); + file_put_contents($this->sharedTriggerFile, 'test'); $edit['Drupal\simpletest\Tests\BrokenSetUpTest'] = TRUE; $this->drupalPostForm('admin/config/development/testing', $edit, t('Run tests')); $this->assertNoRaw('Broken setup'); @@ -110,7 +122,7 @@ function testMethod() { } // If the test is being run from within simpletest, output a message. else { - if (file_get_contents($this->originalFileDirectory . '/simpletest/trigger') === 'test') { + if (file_get_contents($this->sharedTriggerFile) === 'test') { throw new \Exception('Broken test'); } $this->pass('The test method has run.'); diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index 0a168a5..70099bb 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -774,7 +774,7 @@ protected function setUp() { // a file containing the private key for drupal_valid_test_ua(), the site // directory has to be writable. // Use chmod() without a Drupal wrapper, so potential errors are visible. - // WebTestBase::tearDown() will delete the entire test site directory. + // TestBase::restoreEnvironment() will delete the entire site directory. chmod(DRUPAL_ROOT . '/' . $this->siteDirectory, 0777); $this->rebuildContainer(); @@ -782,7 +782,7 @@ protected function setUp() { // Manually create and configure private and temporary files directories. // While these could be preset/enforced in settings.php like the public // files directory above, some tests expect them to be configurable in the - // UI. By setting them in settings.php, they are no longer configurable. + // UI. If declared in settings.php, they would no longer be configurable. file_prepare_directory($this->private_files_directory, FILE_CREATE_DIRECTORY); file_prepare_directory($this->temp_files_directory, FILE_CREATE_DIRECTORY); \Drupal::config('system.file') @@ -1016,8 +1016,8 @@ protected function refreshVariables() { // Clear the tag cache. drupal_static_reset('Drupal\Core\Cache\CacheBackendInterface::tagCache'); - \Drupal::service('config.factory')->reset(); - \Drupal::state()->resetCache(); + $this->container->get('config.factory')->reset(); + $this->container->get('state')->resetCache(); } /** diff --git a/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module index f78c6b0..def2ca4 100644 --- a/core/modules/simpletest/simpletest.module +++ b/core/modules/simpletest/simpletest.module @@ -371,13 +371,11 @@ function simpletest_last_test_get($test_id) { * The database prefix to which the log relates. * @param $test_class * The test class to which the log relates. - * @param $during_test - * Indicates that the current file directory path is a temporary file - * file directory used during testing. + * * @return * Found any entries in log. */ -function simpletest_log_read($test_id, $database_prefix, $test_class, $during_test = FALSE) { +function simpletest_log_read($test_id, $database_prefix, $test_class) { $log = DRUPAL_ROOT . '/sites/simpletest/' . substr($database_prefix, 10) . '/error.log'; $found = FALSE; if (file_exists($log)) {