You are here

public function ParagraphsAddModesTest::testSelectMode in Paragraphs 8

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

Tests the add select mode.

File

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');
}