public function LayoutBuilderTranslationTest::testLayoutOverrideBeforeTranslation in Drupal 9
Same name and namespace in other branches
- 8 core/modules/layout_builder/tests/src/Functional/LayoutBuilderTranslationTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderTranslationTest::testLayoutOverrideBeforeTranslation()
Tests that layout overrides work when created before a translation.
File
- core/
modules/ layout_builder/ tests/ src/ Functional/ LayoutBuilderTranslationTest.php, line 91
Class
- LayoutBuilderTranslationTest
- Tests that the Layout Builder works with translated content.
Namespace
Drupal\Tests\layout_builder\FunctionalCode
public function testLayoutOverrideBeforeTranslation() {
$assert_session = $this
->assertSession();
$entity_url = $this->entity
->toUrl()
->toString();
$language = \Drupal::languageManager()
->getLanguage($this->langcodes[2]);
$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');
$assert_session
->linkExists('Layout');
$this
->addEntityTranslation();
$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
->pageTextContains('Powered by Drupal');
$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
->pageTextContains('Powered by Drupal');
$assert_session
->linkNotExists('Layout');
$this
->drupalGet($translated_layout_url);
$assert_session
->pageTextContains('Access denied');
}