You are here

protected function Select2JavascriptTestBase::selectOption in Select 2 8

Selects an option in a select2 widget.

Parameters

string $field: Name of the field.

array $keys: Values for the field.

4 calls to Select2JavascriptTestBase::selectOption()
Select2WidgetTest::testLimitedCount in tests/src/FunctionalJavascript/FieldWidget/Select2WidgetTest.php
Test multiple field selection with 2 items.
Select2WidgetTest::testMultipleSelect in tests/src/FunctionalJavascript/FieldWidget/Select2WidgetTest.php
Test multiple field selection with unlimited items.
Select2WidgetTest::testSingleSelect in tests/src/FunctionalJavascript/FieldWidget/Select2WidgetTest.php
Test single field selection.
Select2WidgetTest::testSingleSelectRequired in tests/src/FunctionalJavascript/FieldWidget/Select2WidgetTest.php
Test single field selection.

File

tests/src/FunctionalJavascript/Select2JavascriptTestBase.php, line 53

Class

Select2JavascriptTestBase
Class Select2JavascriptTestBase.

Namespace

Drupal\Tests\select2\FunctionalJavascript

Code

protected function selectOption($field, array $keys) {
  $this
    ->getSession()
    ->executeScript("jQuery('#{$field}').val(['" . implode("', '", $keys) . "'])");
  $this
    ->getSession()
    ->executeScript("jQuery('#{$field}').trigger('change')");
}