protected function ParagraphsAddModesTest::assertSelectOptions in Paragraphs 8
Same name in this branch
- 8 tests/src/Functional/WidgetLegacy/ParagraphsAddModesTest.php \Drupal\Tests\paragraphs\Functional\WidgetLegacy\ParagraphsAddModesTest::assertSelectOptions()
- 8 tests/src/Functional/WidgetStable/ParagraphsAddModesTest.php \Drupal\Tests\paragraphs\Functional\WidgetStable\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 tests/
src/ Functional/ WidgetStable/ ParagraphsAddModesTest.php - Tests the add select mode.
File
- tests/
src/ Functional/ WidgetStable/ ParagraphsAddModesTest.php, line 137
Class
- ParagraphsAddModesTest
- Tests paragraphs add modes.
Namespace
Drupal\Tests\paragraphs\Functional\WidgetStableCode
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');
}