You are here

protected function TranslationTest::layoutBuilderSetup in Layout Builder Symmetric Translations 8

Setup for layout builder.

This is extracted ouf from the setUp() method in https://www.drupal.org/node/2946333 to test install the module before and after enabling overrides on a bundle.

1 call to TranslationTest::layoutBuilderSetup()
TranslationTest::testLabelTranslation in tests/src/FunctionalJavascript/TranslationTest.php
Tests that block labels can be translated.

File

tests/src/FunctionalJavascript/TranslationTest.php, line 133

Class

TranslationTest
Tests that block settings can be translated.

Namespace

Drupal\Tests\layout_builder_st\FunctionalJavascript

Code

protected function layoutBuilderSetup() {

  // @todo The Layout Builder UI relies on local tasks; fix in
  //   https://www.drupal.org/project/drupal/issues/2917777.
  $this
    ->drupalPlaceBlock('local_tasks_block');
  $this
    ->createContentType([
    'type' => 'bundle_with_section_field',
    'new_revision' => TRUE,
  ]);
  $this
    ->createNode([
    'type' => 'bundle_with_section_field',
    'title' => 'The node title',
    'body' => [
      [
        'value' => 'The node body',
      ],
    ],
  ]);

  // Adds a new language.
  ConfigurableLanguage::createFromLangcode('it')
    ->save();

  // Enable translation for the node type 'bundle_with_section_field'.
  \Drupal::service('content_translation.manager')
    ->setEnabled('node', 'bundle_with_section_field', TRUE);
  $this
    ->drupalLogin($this
    ->drupalCreateUser([
    'access contextual links',
    'configure any layout',
    'administer node display',
    'administer node fields',
    'translate bundle_with_section_field node',
    'create content translations',
  ]));

  // Create a translation.
  $add_translation_url = Url::fromRoute("entity.node.content_translation_add", [
    'node' => 1,
    'source' => 'en',
    'target' => 'it',
  ]);
  $this
    ->drupalPostForm($add_translation_url, [
    'title[0][value]' => 'The translated node title',
    'body[0][value]' => 'The translated node body',
  ], 'Save');

  // Allow layout overrides.
  $this
    ->drupalPostForm(static::FIELD_UI_PREFIX . '/display/default', [
    'layout[enabled]' => TRUE,
  ], 'Save');
  $this
    ->drupalPostForm(static::FIELD_UI_PREFIX . '/display/default', [
    'layout[allow_custom]' => TRUE,
  ], 'Save');
}