public function ParagraphsAddModesTest::testSelectMode

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

Tests the add select mode.

File

paragraphs/tests/src/Functional/WidgetLegacy/ParagraphsAddModesTest.php, line 83

Class

ParagraphsAddModesTest
Tests paragraphs add modes.

Namespace

Drupal\Tests\paragraphs\Functional\WidgetLegacy

Code

public function testSelectMode() {
  $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', 'select');
  $this
    ->assertSelectOptions([
    'btext',
    'dtext',
  ], 'paragraphs');
  $this
    ->addParagraphsType('atext');
  $this
    ->assertSelectOptions([
    'btext',
    'dtext',
    'atext',
  ], 'paragraphs');
  $this
    ->setParagraphsTypeWeight('paragraphed_test', 'dtext', 2, 'paragraphs');
  $this
    ->assertSelectOptions([
    'dtext',
    'btext',
    'atext',
  ], 'paragraphs');
  $this
    ->setAllowedParagraphsTypes('paragraphed_test', [
    'dtext',
    'atext',
  ], TRUE, 'paragraphs');
  $this
    ->assertSelectOptions([
    'dtext',
    'atext',
  ], 'paragraphs');
  $this
    ->setParagraphsTypeWeight('paragraphed_test', 'atext', 1, 'paragraphs');
  $this
    ->assertSelectOptions([
    'atext',
    'dtext',
  ], 'paragraphs');
  $this
    ->setAllowedParagraphsTypes('paragraphed_test', [
    'atext',
    'dtext',
    'btext',
  ], TRUE, 'paragraphs');
  $this
    ->assertSelectOptions([
    'atext',
    'dtext',
    'btext',
  ], 'paragraphs');
}