You are here

public function ParagraphsAddModesTest::testDropDownMode in Paragraphs 8

Same name in this branch
  1. 8 tests/src/Functional/WidgetLegacy/ParagraphsAddModesTest.php \Drupal\Tests\paragraphs\Functional\WidgetLegacy\ParagraphsAddModesTest::testDropDownMode()
  2. 8 tests/src/Functional/WidgetStable/ParagraphsAddModesTest.php \Drupal\Tests\paragraphs\Functional\WidgetStable\ParagraphsAddModesTest::testDropDownMode()

Tests the add drop down button.

File

tests/src/Functional/WidgetLegacy/ParagraphsAddModesTest.php, line 49

Class

ParagraphsAddModesTest
Tests paragraphs add modes.

Namespace

Drupal\Tests\paragraphs\Functional\WidgetLegacy

Code

public function testDropDownMode() {
  $this
    ->loginAsAdmin();

  // Add two Paragraph types.
  $this
    ->addParagraphsType('btext');
  $this
    ->addParagraphsType('dtext');
  $this
    ->addParagraphedContentType('paragraphed_test', 'paragraphs', 'entity_reference_paragraphs');

  // Enter to the field config since the weight is set through the form.
  $this
    ->drupalGet('admin/structure/types/manage/paragraphed_test/fields/node.paragraphed_test.paragraphs');
  $this
    ->submitForm([], 'Save settings');
  $this
    ->setAddMode('paragraphed_test', 'paragraphs', 'dropdown');
  $this
    ->assertAddButtons([
    'Add btext',
    'Add dtext',
  ]);
  $this
    ->addParagraphsType('atext');
  $this
    ->assertAddButtons([
    'Add btext',
    'Add dtext',
    'Add atext',
  ]);
  $this
    ->setParagraphsTypeWeight('paragraphed_test', 'dtext', 2, 'paragraphs');
  $this
    ->assertAddButtons([
    'Add dtext',
    'Add btext',
    'Add atext',
  ]);
  $this
    ->setAllowedParagraphsTypes('paragraphed_test', [
    'dtext',
    'atext',
  ], TRUE, 'paragraphs');
  $this
    ->assertAddButtons([
    'Add dtext',
    'Add atext',
  ]);
  $this
    ->setParagraphsTypeWeight('paragraphed_test', 'atext', 1, 'paragraphs');
  $this
    ->assertAddButtons([
    'Add atext',
    'Add dtext',
  ]);
  $this
    ->setAllowedParagraphsTypes('paragraphed_test', [
    'atext',
    'dtext',
    'btext',
  ], TRUE, 'paragraphs');
  $this
    ->assertAddButtons([
    'Add atext',
    'Add dtext',
    'Add btext',
  ]);
}