public function LayoutBuilderAtTranslationTest::testAsymmetricTranslation in Layout Builder Asymmetric Translation 8.2
Tests that layout overrides have different blocks.
Throws
\Behat\Mink\Exception\ElementNotFoundException
\Behat\Mink\Exception\ExpectationException
\Behat\Mink\Exception\ResponseTextException
\Drupal\Core\Entity\EntityMalformedException
File
- tests/
src/ Functional/ LayoutBuilderAtTranslationTest.php, line 49
Class
- LayoutBuilderAtTranslationTest
- Layout Builder Asymmetric Translations tests.
Namespace
Drupal\Tests\layout_builder_at\FunctionalCode
public function testAsymmetricTranslation() {
$assert_session = $this
->assertSession();
$this
->drupalGet('entity_test_mul/structure/entity_test_mul/display/default/layout');
// Make layout builder field translatable.
$this
->drupalGet('admin/config/regional/content-language');
$edit = [
'settings[entity_test_mul][entity_test_mul][fields][layout_builder__layout]' => TRUE,
];
$assert_session
->pageTextNotContains('Layout Builder does not support translating layouts.');
$this
->drupalPostForm(NULL, $edit, 'Save configuration');
// Create default entity.
$this
->createDefaultTranslationEntity();
// Add layout override.
$this
->addLayoutOverride();
// Now translate.
$this
->addEntityTranslation(NULL);
$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(self::translatedTextFieldText);
$assert_session
->pageTextContains(self::defaultTextFieldText);
$assert_session
->linkExists('Layout');
$assert_session
->pageTextContains('Powered by Drupal');
$this
->drupalGet($translated_entity_url);
$assert_session
->pageTextNotContains(self::defaultTextFieldText);
// Translated field is visible as the field block is copied over from the
// default.
$assert_session
->pageTextContains(self::translatedTextFieldText);
// Layout should be accessible.
$assert_session
->linkExists('Layout');
// Powered by Drupal block is not copied over.
$assert_session
->pageTextNotContains('Powered by Drupal');
$this
->drupalGet($translated_layout_url);
$assert_session
->statusCodeEquals(200);
// Test source language.
$second_language = \Drupal::languageManager()
->getLanguage($this->langcodes[1]);
$translated_entity_url = $this->entity
->toUrl('canonical', [
'language' => $second_language,
])
->toString();
$this
->addEntityTranslation(TRUE, 1, 'fr');
$this
->drupalGet($translated_entity_url);
$assert_session
->pageTextContains(self::translatedTextFieldText);
$assert_session
->pageTextNotContains('Powered by Drupal');
}