You are here

protected function MultiselectElementJavascriptTest::assertOptions in Multiselect 8

Same name and namespace in other branches
  1. 2.x tests/src/FunctionalJavascript/MultiselectElementJavascriptTest.php \Drupal\Tests\multiselect\FunctionalJavascript\MultiselectElementJavascriptTest::assertOptions()

Asserts that the given options are contained in a certain select element.

Parameters

string $selector: The CSS selector of the select element that contains the options.

array $options: An array of options where the array keys are the option values and the array values are the option labels.

2 calls to MultiselectElementJavascriptTest::assertOptions()
MultiselectElementJavascriptTest::testDefaultValue in tests/src/FunctionalJavascript/MultiselectElementJavascriptTest.php
Tests the default values of multiselect elements.
MultiselectElementJavascriptTest::testSelection in tests/src/FunctionalJavascript/MultiselectElementJavascriptTest.php
Tests selection and deselection of multiselect element.

File

tests/src/FunctionalJavascript/MultiselectElementJavascriptTest.php, line 109

Class

MultiselectElementJavascriptTest
Tests the multiselect element using JavaScript.

Namespace

Drupal\Tests\multiselect\FunctionalJavascript

Code

protected function assertOptions($selector, array $options) {
  $this
    ->assertSession()
    ->elementsCount('css', "{$selector} option", count($options));
  foreach ($options as $value => $label) {
    $option_selector = "{$selector} option[value={$value}]";
    $this
      ->assertSession()
      ->elementExists('css', $option_selector);
    $this
      ->assertSession()
      ->elementTextContains('css', $option_selector, $label);
  }
}