LayoutBuilderAtTranslationTest.php in Layout Builder Asymmetric Translation 8.2
File
tests/src/Functional/LayoutBuilderAtTranslationTest.php
View source
<?php
namespace Drupal\Tests\layout_builder_at\Functional;
class LayoutBuilderAtTranslationTest extends LayoutBuilderAtBase {
public static $modules = [
'content_translation',
'contextual',
'entity_test',
'layout_builder',
'layout_builder_at',
'block',
];
protected $entity;
protected function setUp() {
parent::setUp();
$this
->setUpViewDisplay();
$this
->setUpFormDisplay();
$this
->setUpEntities();
}
public function testAsymmetricTranslation() {
$assert_session = $this
->assertSession();
$this
->drupalGet('entity_test_mul/structure/entity_test_mul/display/default/layout');
$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');
$this
->createDefaultTranslationEntity();
$this
->addLayoutOverride();
$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);
$assert_session
->pageTextContains(self::translatedTextFieldText);
$assert_session
->linkExists('Layout');
$assert_session
->pageTextNotContains('Powered by Drupal');
$this
->drupalGet($translated_layout_url);
$assert_session
->statusCodeEquals(200);
$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');
}
}