protected function ParagraphsTranslationsTest::setUp

Overrides ParagraphsTestBase::setUp

File

paragraphs/tests/src/Functional/WidgetStable/ParagraphsTranslationsTest.php, line 44

Class

ParagraphsTranslationsTest
Test paragraphs with translations.

Namespace

Drupal\Tests\paragraphs\Functional\WidgetStable

Code

protected function setUp() : void {
  parent::setUp();
  $this
    ->placeDefaultBlocks();
  $this
    ->addParagraphedContentType('paragraphed_test', 'field_paragraphs', 'paragraphs');
  ConfigurableLanguage::createFromLangcode('de')
    ->save();
  $this
    ->loginAsAdmin([
    'access administration pages',
    'view all revisions',
    'revert all revisions',
    'administer nodes',
    'bypass node access',
    'administer content translation',
    'translate any entity',
    'create content translations',
    'administer languages',
    'administer content types',
    'administer node form display',
    'edit any paragraphed_test content',
    'create paragraphed_test content',
    'edit behavior plugin settings',
  ]);
  $this->visitorUser = $this
    ->drupalCreateUser([
    'access content',
    'view all revisions',
  ]);

  // Add a Paragraph type.
  $this
    ->addParagraphsType('text_translatable');
  $this
    ->addParagraphsType('text_untranslatable');
  $this
    ->addParagraphsType('text_untranslatable_hide');
  $this
    ->addParagraphsType('container');
  $this
    ->addFieldtoParagraphType('text_translatable', 'field_text_translatable', 'text');
  $this
    ->addFieldtoParagraphType('text_untranslatable', 'field_text_untranslatable', 'text');
  $this
    ->addFieldtoParagraphType('text_untranslatable_hide', 'field_text_untranslatable_hide', 'text');
  $this
    ->addParagraphsField('container', 'field_paragraphs', 'paragraph');
  $this
    ->drupalGet('admin/config/regional/content-language');
  $this
    ->assertSession()
    ->pageTextContains('Paragraph types that are used in moderated content requires non-translatable fields to be edited in the original language form and this must be checked.');
  $edit = [
    'entity_types[paragraph]' => TRUE,
    'entity_types[node]' => TRUE,
    'settings[node][paragraphed_test][translatable]' => TRUE,
    'settings[node][paragraphed_test][fields][field_paragraphs]' => FALSE,
    'settings[node][paragraphed_test][settings][language][language_alterable]' => TRUE,
    'settings[paragraph][text_translatable][translatable]' => TRUE,
    'settings[paragraph][text_untranslatable][translatable]' => TRUE,
    'settings[paragraph][text_untranslatable_hide][translatable]' => TRUE,
    'settings[paragraph][container][translatable]' => TRUE,
    'settings[paragraph][text_translatable][settings][content_translation][untranslatable_fields_hide]' => TRUE,
    'settings[paragraph][text_untranslatable][settings][content_translation][untranslatable_fields_hide]' => FALSE,
    'settings[paragraph][text_untranslatable_hide][settings][content_translation][untranslatable_fields_hide]' => TRUE,
    'settings[paragraph][container][settings][content_translation][untranslatable_fields_hide]' => TRUE,
    'settings[paragraph][text_translatable][fields][field_text_translatable]' => TRUE,
    'settings[paragraph][text_untranslatable][fields][field_text_untranslatable]' => FALSE,
    'settings[paragraph][text_untranslatable_hide][fields][field_text_untranslatable_hide]' => FALSE,
    'settings[paragraph][container][fields][field_paragraphs]' => FALSE,
  ];
  $this
    ->submitForm($edit, 'Save configuration');
}