function LayoutBuilderTranslationTest::testTranslationBeforeLayoutOverride
Same name in other branches
- 9 core/modules/layout_builder/tests/src/Functional/LayoutBuilderTranslationTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderTranslationTest::testTranslationBeforeLayoutOverride()
- 8.9.x core/modules/layout_builder/tests/src/Functional/LayoutBuilderTranslationTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderTranslationTest::testTranslationBeforeLayoutOverride()
- 10 core/modules/layout_builder/tests/src/Functional/LayoutBuilderTranslationTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderTranslationTest::testTranslationBeforeLayoutOverride()
Tests that layout overrides work when created after a translation.
File
-
core/
modules/ layout_builder/ tests/ src/ Functional/ LayoutBuilderTranslationTest.php, line 54
Class
- LayoutBuilderTranslationTest
- Tests that the Layout Builder works with translated content.
Namespace
Drupal\Tests\layout_builder\FunctionalCode
public function testTranslationBeforeLayoutOverride() : void {
$assert_session = $this->assertSession();
$this->addEntityTranslation();
$entity_url = $this->entity
->toUrl()
->toString();
$language = \Drupal::languageManager()->getLanguage($this->langcodes[2]);
$translated_entity_url = $this->entity
->toUrl('canonical', [
'language' => $language,
])
->toString();
$translated_layout_url = $translated_entity_url . '/layout';
$this->drupalGet($entity_url);
$assert_session->pageTextNotContains('The translated field value');
$assert_session->pageTextContains('The untranslated field value');
$assert_session->linkExists('Layout');
$this->drupalGet($translated_entity_url);
$assert_session->pageTextNotContains('The untranslated field value');
$assert_session->pageTextContains('The translated field value');
$assert_session->linkNotExists('Layout');
$this->drupalGet($translated_layout_url);
$assert_session->pageTextContains('Access denied');
$this->addLayoutOverride();
$this->drupalGet($entity_url);
$assert_session->pageTextNotContains('The translated field value');
$assert_session->pageTextContains('The untranslated field value');
$assert_session->pageTextContains('Powered by Drupal');
// Ensure that the layout change propagates to the translated entity.
$this->drupalGet($translated_entity_url);
$assert_session->pageTextNotContains('The untranslated field value');
$assert_session->pageTextContains('The translated field value');
$assert_session->pageTextContains('Powered by Drupal');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.