diff --git a/core/modules/config/src/Tests/ConfigSchemaTest.php b/core/modules/config/src/Tests/ConfigSchemaTest.php index ca53a53..2bc22d8 100644 --- a/core/modules/config/src/Tests/ConfigSchemaTest.php +++ b/core/modules/config/src/Tests/ConfigSchemaTest.php @@ -284,7 +284,7 @@ function testSchemaData() { $meta = \Drupal::service('config.typed')->get('system.site'); $property = $meta->get('name'); $this->assertTrue($property instanceof StringInterface, 'Got the right wrapper fo the site name property.'); - $this->assertEqual($property->getValue(), 'Drupal', 'Got the right string value for site name data.'); + $this->assertEqual($property->getValue(), '', 'Got the empty default value for site name data.'); $definition = $property->getDataDefinition(); $this->assertTrue($definition['translatable'], 'Got the right translatability setting for site name data.'); diff --git a/core/modules/locale/src/Tests/LocaleConfigTranslationTest.php b/core/modules/locale/src/Tests/LocaleConfigTranslationTest.php index 27f120d..6a4522d 100644 --- a/core/modules/locale/src/Tests/LocaleConfigTranslationTest.php +++ b/core/modules/locale/src/Tests/LocaleConfigTranslationTest.php @@ -7,6 +7,7 @@ namespace Drupal\locale\Tests; +use Drupal\Component\Utility\SafeMarkup; use Drupal\simpletest\WebTestBase; use Drupal\core\language\languageInterface; @@ -45,7 +46,7 @@ protected function setUp() { public function testConfigTranslation() { // Add custom language. $langcode = 'xx'; - $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages', 'translate interface', 'administer modules', 'access site-wide contact form', 'administer contact forms')); + $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages', 'translate interface', 'administer modules', 'access site-wide contact form', 'administer contact forms', 'administer site configuration')); $this->drupalLogin($admin_user); $name = $this->randomMachineName(16); $edit = array( @@ -59,12 +60,13 @@ public function testConfigTranslation() { $edit = array("prefix[$langcode]" => $langcode); $this->drupalPostForm('admin/config/regional/language/detection/url', $edit, t('Save configuration')); - // Check site name string exists and create translation for it. - $string = $this->storage->findString(array('source' => 'Drupal', 'context' => '', 'type' => 'configuration')); + // Check that the maintenance message exists and create translation for it. + $source = '@site is currently under maintenance. We should be back shortly. Thank you for your patience.'; + $string = $this->storage->findString(array('source' => $source, 'context' => '', 'type' => 'configuration')); $this->assertTrue($string, 'Configuration strings have been created upon installation.'); // Translate using the UI so configuration is refreshed. - $site_name = $this->randomMachineName(20); + $message = $this->randomMachineName(20); $search = array( 'string' => $string->source, 'langcode' => $langcode, @@ -75,20 +77,16 @@ public function testConfigTranslation() { $textarea = current($textareas); $lid = (string) $textarea[0]['name']; $edit = array( - $lid => $site_name, + $lid => $message, ); $this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations')); - $wrapper = $this->container->get('locale.config.typed')->get('system.site'); - - // Get translation and check we've only got the site name. - $translation = $wrapper->getTranslation($langcode); - $properties = $translation->getElements(); - $this->assertEqual(count($properties), 1, 'Got the right number of properties after translation'); - - // Check the translated site name is displayed. - $this->drupalGet($langcode); - $this->assertText($site_name, 'The translated site name is displayed after translations refreshed.'); + // Check that the translation ended up in an override. + /** @var \Drupal\language\Config\LanguageConfigOverride $override */ + $override = $this->container->get('language_manager')->getLanguageConfigOverride($langcode, 'system.maintenance'); + $data = $override->get(); + $this->assertEqual(count($data), 1, 'Got the right number of properties in the translation.'); + $this->assertEqual($data['message'], $message); // Check default medium date format exists and create a translation for it. $string = $this->storage->findString(array('source' => 'D, m/d/Y - H:i', 'context' => 'PHP date format', 'type' => 'configuration')); diff --git a/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php b/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php index f489c75..779f2a4 100644 --- a/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php +++ b/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php @@ -19,6 +19,15 @@ class TokenReplaceUnitTest extends TokenReplaceUnitTestBase { /** + * @inheritdoc + */ + protected function setUp() { + parent::setUp(); + // Set the site name to something other than an empty string. + $this->config('system.site')->set('name', 'Drupal')->save(); + } + + /** * Test whether token-replacement works in various contexts. */ public function testSystemTokenRecognition() {