protected function ParagraphsAddModesTest::assertSelectOptions

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

Asserts order and quantity of select add options.

Parameters

array $options: Array of expected select options in its correct order.

string $paragraphs_field: Name of the paragraphs field to check.

1 call to ParagraphsAddModesTest::assertSelectOptions()
ParagraphsAddModesTest::testSelectMode in paragraphs/tests/src/Functional/WidgetLegacy/ParagraphsAddModesTest.php
Tests the add select mode.

File

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

Class

ParagraphsAddModesTest
Tests paragraphs add modes.

Namespace

Drupal\Tests\paragraphs\Functional\WidgetLegacy

Code

protected function assertSelectOptions($options, $paragraphs_field) {
  $this
    ->drupalGet('node/add/paragraphed_test');
  $buttons = $this
    ->xpath('//*[@name="' . $paragraphs_field . '[add_more][add_more_select]"]/option');

  // Check if the options are in the same order as the given array.
  foreach ($buttons as $key => $button) {
    $this
      ->assertEquals($button
      ->getValue(), $options[$key]);
  }
  $this
    ->assertEquals(count($buttons), count($options), 'The amount of select options matches with the given array');
  $this
    ->assertNotEquals($this
    ->xpath('//*[@name="' . $paragraphs_field . '_add_more"]'), [], 'The add button is displayed');
}