You are here

public function MultilingualBehaviorTest::setUp in Paragraphs 8

Overrides ParagraphsTestBase::setUp

File

modules/paragraphs_library/tests/src/Functional/MultilingualBehaviorTest.php, line 28

Class

MultilingualBehaviorTest
Tests paragraphs library multilingual functionality.

Namespace

Drupal\Tests\paragraphs_library\Functional

Code

public function setUp() : void {
  parent::setUp();
  $this
    ->addParagraphedContentType('paragraphed_test');
  $this
    ->addParagraphsType('test_content');
  $this
    ->addParagraphsType('nested_paragraph');
  $user = $this
    ->createUser(array_merge($this->admin_permissions, [
    'create paragraphed_test content',
    'edit any paragraphed_test content',
    'administer paragraphs library',
    'administer languages',
    'administer content translation',
    'create content translations',
    'translate any entity',
  ]));
  $this
    ->drupalLogin($user);
  ConfigurableLanguage::createFromLangcode('de')
    ->save();

  // Enable translation for paragraphed_test content.
  $edit = [
    'language_configuration[content_translation]' => TRUE,
  ];
  $this
    ->drupalGet('admin/structure/types/manage/paragraphed_test');
  $this
    ->submitForm($edit, 'Save content type');
  $this
    ->fieldUIAddNewField('admin/structure/paragraphs_type/test_content', 'paragraphs_text', 'Test content', 'text_long', [], []);

  // Add nested paragraph field.
  $this
    ->fieldUIAddNewField('admin/structure/paragraphs_type/nested_paragraph', 'err_field', 'Nested', 'field_ui:entity_reference_revisions:paragraph', [
    'settings[target_type]' => 'paragraph',
    'cardinality' => '-1',
  ], []);

  // Enable translation for paragraphs_content, paragraph type
  // and paragraphs_library_item.
  $edit = [
    'entity_types[paragraph]' => TRUE,
    'entity_types[paragraphs_library_item]' => TRUE,
    'settings[node][paragraphed_test][fields][field_paragraphs]' => FALSE,
    'settings[paragraph][test_content][translatable]' => TRUE,
    'settings[paragraph][nested_paragraph][translatable]' => TRUE,
    'settings[paragraph][test_content][fields][field_paragraphs_text]' => TRUE,
    'settings[paragraphs_library_item][paragraphs_library_item][translatable]' => TRUE,
  ];
  $this
    ->drupalGet('admin/config/regional/content-language');
  $this
    ->submitForm($edit, 'Save configuration');
}