diff --git a/core/modules/language/src/Tests/LanguageListTest.php b/core/modules/language/src/Tests/LanguageListTest.php index 72e2b0a..5391a9f 100644 --- a/core/modules/language/src/Tests/LanguageListTest.php +++ b/core/modules/language/src/Tests/LanguageListTest.php @@ -154,6 +154,7 @@ function testLanguageList() { 'direction' => Language::DIRECTION_LTR, ); $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language')); + $this->rebuildContainer(); $this->assertUrl(\Drupal::url('entity.configurable_language.collection', [], ['absolute' => TRUE])); $this->assertText($name, 'Name found.'); diff --git a/core/modules/simpletest/src/Tests/SimpleTestWithLanguageTest.php b/core/modules/simpletest/src/Tests/SimpleTestWithLanguageTest.php new file mode 100644 index 0000000..a0e379b --- /dev/null +++ b/core/modules/simpletest/src/Tests/SimpleTestWithLanguageTest.php @@ -0,0 +1,63 @@ +isInChildSite()) { + $this->drupalLogin($this->drupalCreateUser(array('administer unit tests'))); + } + } + + /** + * Ensures the tests run well with language module enabled. + */ + public function testLanguageList() { + if ($this->isInChildSite()) { + // Ensure the .htkey file exists since this is only created just before a + // request. This allows the stub test to make requests. The event does not + // fire here and drupal_generate_test_ua() can not generate a key for a + // test in a test since the prefix has changed. + // @see \Drupal\Core\Test\HttpClientMiddleware\TestHttpClientMiddleware::onBeforeSendRequest() + // @see drupal_generate_test_ua(); + $key_file = DRUPAL_ROOT . '/sites/simpletest/' . substr($this->databasePrefix, 10) . '/.htkey'; + $private_key = Crypt::randomBytesBase64(55); + file_put_contents($key_file, $private_key); + + // Only run following code if this test is running itself through a CURL + // request. + parent::testLanguageList(); + } + else { + $edit['tests[Drupal\simpletest\Tests\SimpleTestWithLanguageTest]'] = TRUE; + $this->drupalPostForm('admin/config/development/testing', $edit, t('Run tests')); + $this->assertRaw('0 exceptions'); + $this->assertRaw('0 fails'); + } + } + +}