protected function ParagraphsLegacyContentModerationTranslationsTest::setUp

Overrides ParagraphsTestBase::setUp

File

paragraphs/tests/src/Functional/WidgetLegacy/ParagraphsLegacyContentModerationTranslationsTest.php, line 44

Class

ParagraphsLegacyContentModerationTranslationsTest
Test paragraphs and content moderation with translations.

Namespace

Drupal\Tests\paragraphs\Functional\WidgetLegacy

Code

protected function setUp() : void {
  parent::setUp();
  $this
    ->placeDefaultBlocks();
  $this
    ->addParagraphedContentType('paragraphed_test', 'field_paragraphs', 'entity_reference_paragraphs');
  ConfigurableLanguage::createFromLangcode('de')
    ->save();
  $this
    ->createEditorialWorkflow('paragraphed_test');
  $this
    ->loginAsAdmin([
    'access administration pages',
    'view any unpublished content',
    'view all revisions',
    'revert all revisions',
    'view latest version',
    'view any unpublished content',
    'use ' . $this->workflow
      ->id() . ' transition create_new_draft',
    'use ' . $this->workflow
      ->id() . ' transition publish',
    'use ' . $this->workflow
      ->id() . ' transition archived_published',
    'use ' . $this->workflow
      ->id() . ' transition archived_draft',
    'use ' . $this->workflow
      ->id() . ' transition archive',
    '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');
  $this
    ->addParagraphsType('container');

  // Add a text field to the text_paragraph type.
  static::fieldUIAddNewField('admin/structure/paragraphs_type/text', 'text', 'Text', 'text_long', [], []);

  // Add an untranslatable string field.
  static::fieldUIAddNewField('admin/structure/paragraphs_type/text', 'untranslatable', 'Untranslatable text', 'string', [], []);
  $this
    ->addParagraphsField('container', 'field_paragraphs', 'paragraph', 'entity_reference_paragraphs');
  $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]' => TRUE,
    'settings[paragraph][container][translatable]' => TRUE,
    // Because the paragraph entity itself is not directly enabled in the
    // workflow, these options must be enabled manually.
    'settings[paragraph][text][settings][content_translation][untranslatable_fields_hide]' => TRUE,
    'settings[paragraph][container][settings][content_translation][untranslatable_fields_hide]' => TRUE,
    'settings[paragraph][text][fields][field_text]' => TRUE,
    'settings[paragraph][text][fields][field_untranslatable]' => FALSE,
    'settings[paragraph][container][fields][field_paragraphs]' => FALSE,
  ];
  $this
    ->submitForm($edit, 'Save configuration');
}