diff --git a/core/modules/language/tests/src/Functional/ConfigurableLanguageManagerTest.php b/core/modules/language/tests/src/Functional/ConfigurableLanguageManagerTest.php index 66b322e..d0a0555 100644 --- a/core/modules/language/tests/src/Functional/ConfigurableLanguageManagerTest.php +++ b/core/modules/language/tests/src/Functional/ConfigurableLanguageManagerTest.php @@ -1,19 +1,17 @@ 'page', - 'name' => t('Page') + 'name' => t('Page'), ])->save(); $config = ContentLanguageSettings::loadByEntityTypeBundle('node', 'page'); @@ -73,25 +82,22 @@ protected function setUp() { 'title' => 'English', ]); $node->save(); - $node->addTranslation('es', [ - 'title' => 'Español' - ]); + $node->addTranslation('es', ['title' => 'Español']); $node->save(); - // Enable both language_interface and language_content language negotiation. $this->languageNegotiator = \Drupal::getContainer() ->get('language_negotiator'); $this->languageNegotiator->updateConfiguration([ 'language_interface', - 'language_content' + 'language_content', ]); // Set the preferred language of the user for admin pages to English. $this->user->set('preferred_admin_langcode', 'en')->save(); // Make sure node edit pages are administration pages. - $this->configFactory = \Drupal::getContainer()->get('config.factory'); + $this->configFactory = \Drupal::getContainer()->get('config.factory'); $this->configFactory->getEditable('node.settings')->set('use_admin_theme', '1')->save(); $this->container->get('router.builder')->rebuild(); @@ -113,10 +119,8 @@ protected function setUp() { 'language' => 'es', 'translation' => 'Funciona con ...', ])->save(); - } - /** * Test translation with URL and Preferred Admin Language negotiators. * @@ -124,84 +128,85 @@ protected function setUp() { * user and after that the URL. The Content uses just the URL. */ public function testUrlContentTranslationWithPreferredAdminLanguage() { + $assert_session = $this->assertSession(); // Set the interface language to use the preferred administration language // and then the URL. $this->languageNegotiator->saveConfiguration('language_interface', [ 'language-user-admin' => 1, 'language-url' => 2, - 'language-selected' => 3 + 'language-selected' => 3, ]); // Set Content Language Negotiator to use just the URL. $this->languageNegotiator->saveConfiguration('language_content', [ 'language-url' => 4, - 'language-selected' => 5 + 'language-selected' => 5, ]); // See if the full view of the node in english is present and the // string in the Powered By Block is in English. $this->drupalGet('/node/1'); - $this->assertSession()->responseContains('English'); - $this->assertSession()->responseContains('Powered by'); + $assert_session->pageTextContains('English'); + $assert_session->pageTextContains('Powered by'); // Load the spanish node page again and see if both the node and the string // are translated. $this->drupalGet('/es/node/1'); - $this->assertSession()->responseContains('Español'); - $this->assertSession()->responseContains('Funciona con'); - $this->assertSession()->responseNotContains('Powered by'); + $assert_session->pageTextContains('Español'); + $assert_session->pageTextContains('Funciona con'); + $assert_session->pageTextNotContains('Powered by'); // Check if the Powered by string is shown in English on an // administration page, and the node content is shown in Spanish. $this->drupalGet('/es/node/1/edit'); - $this->assertSession()->responseContains('Español'); - $this->assertSession()->responseContains('Powered by'); - $this->assertSession()->responseNotContains('Funciona con'); - + $assert_session->pageTextContains('Español'); + $assert_session->pageTextContains('Powered by'); + $assert_session->pageTextNotContains('Funciona con'); } - /** * Test translation with URL and Session Language Negotiators. */ public function testUrlContentTranslationWithSessionLanguage() { + $assert_session = $this->assertSession(); // Set Interface Language Negotiator to Session. $this->languageNegotiator->saveConfiguration('language_interface', [ 'language-session' => 1, 'language-url' => 2, - 'language-selected' => 3 + 'language-selected' => 3, ]); // Set Content Language Negotiator to URL. $this->languageNegotiator->saveConfiguration('language_content', [ 'language-url' => 4, - 'language-selected' => 5 + 'language-selected' => 5, ]); // See if the full view of the node in english is present and the // string in the Powered By Block is in English. $this->drupalGet('/node/1'); - $this->assertSession()->responseContains('English'); - $this->assertSession()->responseContains('Powered by'); + $assert_session->pageTextContains('English'); + $assert_session->pageTextContains('Powered by'); // The language session variable has not been set yet, so // The string should be in Spanish. $this->drupalGet('/es/node/1'); - $this->assertSession()->responseContains('Español'); - $this->assertSession()->responseNotContains('Powered by'); - $this->assertSession()->responseContains('Funciona con'); + $assert_session->pageTextContains('Español'); + $assert_session->pageTextNotContains('Powered by'); + $assert_session->pageTextContains('Funciona con'); // Set the session language to Spanish but load the English node page. $this->drupalGet('/node/1', ['query' => ['language' => 'es']]); - $this->assertSession()->responseContains('English'); - $this->assertSession()->responseNotContains('Español'); - $this->assertSession()->responseContains('Funciona con'); - $this->assertSession()->responseNotContains('Powered by'); + $assert_session->pageTextContains('English'); + $assert_session->pageTextNotContains('Español'); + $assert_session->pageTextContains('Funciona con'); + $assert_session->pageTextNotContains('Powered by'); // Set the session language to English but load the node page in Spanish. $this->drupalGet('/es/node/1', ['query' => ['language' => 'en']]); - $this->assertSession()->responseNotContains('English'); - $this->assertSession()->responseContains('Español'); - $this->assertSession()->responseNotContains('Funciona con'); - $this->assertSession()->responseContains('Powered by'); + $assert_session->pageTextNotContains('English'); + $assert_session->pageTextContains('Español'); + $assert_session->pageTextNotContains('Funciona con'); + $assert_session->pageTextContains('Powered by'); } + }