You are here

protected function QuickNodeCloneExcludeParagraphFieldsTest::createParagraphs in Quick Node Clone 8

Creates the paragraphs used by the tests.

1 call to QuickNodeCloneExcludeParagraphFieldsTest::createParagraphs()
QuickNodeCloneExcludeParagraphFieldsTest::setUp in tests/src/Functional/QuickNodeCloneExcludeParagraphFieldsTest.php

File

tests/src/Functional/QuickNodeCloneExcludeParagraphFieldsTest.php, line 45

Class

QuickNodeCloneExcludeParagraphFieldsTest
Tests node cloning excluding paragraph fields.

Namespace

Drupal\Tests\quick_node_clone\Functional

Code

protected function createParagraphs() {
  $this
    ->addParagraphedContentType('paragraphed_test', 'field_paragraphs', 'entity_reference_paragraphs');
  $this
    ->loginAsAdmin([
    'create paragraphed_test content',
    'edit any paragraphed_test content',
  ]);
  $paragraph_type = 'text_paragraph';
  $this
    ->addParagraphsType($paragraph_type);
  $this
    ->addParagraphsType('text');

  // Add two text fields to the text_paragraph type.
  static::fieldUIAddNewField('admin/structure/paragraphs_type/' . $paragraph_type, 'text1', 'Text 1', 'string', [], []);
  static::fieldUIAddNewField('admin/structure/paragraphs_type/' . $paragraph_type, 'text2', 'Text 2', 'string', [], []);
  $this
    ->drupalGet('node/add/paragraphed_test');
  $this
    ->submitForm([], 'field_paragraphs_text_paragraph_add_more');

  // Add config to exclude text 2 field.
  \Drupal::configFactory()
    ->getEditable('quick_node_clone.settings')
    ->set('exclude.paragraph.' . $paragraph_type, [
    'field_text2',
  ])
    ->save();
}