You are here

public function ParagraphsDragAndDropModeTest::setUp in Paragraphs 8

Overrides ParagraphsTestBase::setUp

File

tests/src/Functional/WidgetStable/ParagraphsDragAndDropModeTest.php, line 28

Class

ParagraphsDragAndDropModeTest
Tests the drag and drop mode of paragraphs.

Namespace

Drupal\Tests\paragraphs\Functional\WidgetStable

Code

public function setUp() : void {
  parent::setUp();
  $this
    ->addParagraphedContentType('paragraphed_test', 'field_paragraphs');
  $this
    ->addParagraphsType('paragraphs_container');
  $this
    ->addParagraphsType('text');
  $this
    ->addFieldtoParagraphType('text', 'field_text', 'text');
  $this
    ->addParagraphsField('paragraphs_container', 'paragraphs_container_paragraphs', 'paragraph');

  // Make sure the paragraph fields use closed edit mode by default.
  $component = [
    'type' => 'paragraphs',
    'region' => 'content',
    'settings' => [
      'edit_mode' => 'closed',
      'form_display_mode' => 'default',
    ],
  ];
  EntityFormDisplay::load('paragraph.paragraphs_container.default')
    ->setComponent('paragraphs_container_paragraphs', $component)
    ->save();
  EntityFormDisplay::load('node.paragraphed_test.default')
    ->setComponent('field_paragraphs', $component)
    ->save();
  $admin = $this
    ->drupalCreateUser([
    'create paragraphed_test content',
    'edit any paragraphed_test content',
  ]);
  $this
    ->drupalLogin($admin);

  // By default, paragraphs does not show the Drag & drop button if the
  // library is not present. Override this for tests, as they don't need the
  // JS.
  \Drupal::state()
    ->set('paragraphs_test_dragdrop_force_show', TRUE);
}