public function ParagraphsAddModesTest::testDropDownMode

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

Tests the add drop down button.

File

paragraphs/tests/src/Functional/WidgetStable/ParagraphsAddModesTest.php, line 48

Class

ParagraphsAddModesTest
Tests paragraphs add modes.

Namespace

Drupal\Tests\paragraphs\Functional\WidgetStable

Code

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

  // Add two Paragraph types.
  $this
    ->addParagraphsType('btext');
  $this
    ->addParagraphsType('dtext');
  $this
    ->addParagraphedContentType('paragraphed_test', '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',
  ]);
}