You are here

protected function Select2Test::assertOptionExists in Select 2 8

Tests that a select option exists.

Parameters

string $selector: The data-drupal-selector.

string $value: The value of the option.

2 calls to Select2Test::assertOptionExists()
Select2Test::testAutocompleteOptions in tests/src/Kernel/Element/Select2Test.php
Tests that in autocomplete are only the default options rendered.
Select2Test::testEmptyOption in tests/src/Kernel/Element/Select2Test.php
Tests that an empty option is added or not.

File

tests/src/Kernel/Element/Select2Test.php, line 92

Class

Select2Test
@coversDefaultClass \Drupal\select2\Element\Select2

Namespace

Drupal\Tests\select2\Kernel\Element

Code

protected function assertOptionExists($selector, $value) {
  $select = $this
    ->xpath('//select[@data-drupal-selector="' . $selector . '"]/option[@value="' . $value . '"]');
  $this
    ->assertEquals(1, count($select));
}