diff -u b/core/modules/color/tests/src/Functional/ColorTranslationPreviewTest.php b/core/modules/color/tests/src/Functional/ColorTranslationPreviewTest.php --- b/core/modules/color/tests/src/Functional/ColorTranslationPreviewTest.php +++ b/core/modules/color/tests/src/Functional/ColorTranslationPreviewTest.php @@ -15,41 +15,51 @@ * Modules to enable. * - * @var string[] + * @var array */ - public static $modules = ['color', 'color_test']; + public static $modules = ['color', 'color_test', 'language', 'locale']; /** - * A user with administrative permissions. + * Profile to enable. * - * @var \Drupal\user\UserInterface + * @var string */ - protected $bigUser; + protected $profile = 'standard'; /** * {@inheritdoc} */ protected function setUp() { parent::setUp(); - // Create user. - $this->bigUser = $this->drupalCreateUser([ - 'administer themes', - ]); - $this->drupalLogin($this->bigUser); - // Install the color test theme. - \Drupal::service('theme_handler')->install(['color_test_theme']); - $this->config('system.theme')->set('default', 'color_test_theme')->save(); - $this->rebuildContainer(); + // Add a default locale storage. + $this->storage = $this->container->get('locale.storage'); } /** * Ensuring the the text in the preview.html.twig file is wrapped with trans tag. */ public function testTranslationPreview() { - // Markup is being printed from a Twig file located in: - // core/modules/color/tests/modules/color_test/themes/color_test_theme/color/preview.html.twig - $url_preview = 'core/modules/color/tests/modules/color_test/themes/color_test_theme/color/preview.html.twig'; - $this->preview = file_get_contents($url_preview); - $this->assertRegExp('/{% trans %}/', $this->preview); - $this->assertRegExp('/{% endtrans %}/', $this->preview); + $account = $this->drupalCreateUser(['administer languages', 'administer themes']); + $this->drupalLogin($account); + // Add French language. + $edit = [ + 'predefined_langcode' => 'fr', + ]; + $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language')); + $this->rebuildContainer(); + // Translate 'Example heading' to French ('Exemple de titre'). + $source = $this->storage->createString([ + 'source' => 'Example heading', + 'context' => '', + ])->save(); + $this->storage->createTranslation([ + 'lid' => $source->lid, + 'language' => 'fr', + 'translation' => 'Exemple de titre', + ])->save(); + //Checking the string 'Example heading' is translating to French. + $this->drupalGet('fr/admin/appearance/settings/bartik'); + $this->assertSession()->statusCodeEquals(200); + $this->assertSession()->pageTextContains('Exemple de titre'); + } }