You are here

protected function ParagraphsAddModesTest::assertAddButtons in Paragraphs 8

Same name in this branch
  1. 8 tests/src/Functional/WidgetLegacy/ParagraphsAddModesTest.php \Drupal\Tests\paragraphs\Functional\WidgetLegacy\ParagraphsAddModesTest::assertAddButtons()
  2. 8 tests/src/Functional/WidgetStable/ParagraphsAddModesTest.php \Drupal\Tests\paragraphs\Functional\WidgetStable\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 tests/src/Functional/WidgetStable/ParagraphsAddModesTest.php
Tests the add drop down button.

File

tests/src/Functional/WidgetStable/ParagraphsAddModesTest.php, line 119

Class

ParagraphsAddModesTest
Tests paragraphs add modes.

Namespace

Drupal\Tests\paragraphs\Functional\WidgetStable

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