protected function ParagraphsAddModesTest::assertAddButtons

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

Asserts order and quantity of add buttons.

Parameters

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

1 call to ParagraphsAddModesTest::assertAddButtons()
ParagraphsAddModesTest::testDropDownMode in paragraphs/tests/src/Functional/WidgetLegacy/ParagraphsAddModesTest.php
Tests the add drop down button.

File

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

Class

ParagraphsAddModesTest
Tests paragraphs add modes.

Namespace

Drupal\Tests\paragraphs\Functional\WidgetLegacy

Code

protected function assertAddButtons($options) {
  $this
    ->drupalGet('node/add/paragraphed_test');
  $buttons = $this
    ->xpath('//input[@class="field-add-more-submit button--small button js-form-submit form-submit"]');

  // Check if the buttons 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 drop down options matches with the given array');
}