You are here

public function ElementsTest::testAddOtherOption in Select (or other) 8.3

Same name and namespace in other branches
  1. 8 tests/src/Unit/ElementsTest.php \Drupal\Tests\select_or_other\Unit\ElementsTest::testAddOtherOption()
  2. 4.x tests/src/Unit/ElementsTest.php \Drupal\Tests\select_or_other\Unit\ElementsTest::testAddOtherOption()

Tests the addition of the other option to an options array.

File

Tests/src/Unit/ElementsTest.php, line 25

Class

ElementsTest
Tests the form element implementation.

Namespace

Drupal\Tests\select_or_other\Unit

Code

public function testAddOtherOption() {
  $options = [];

  // Make the protected method accessible and invoke it.
  $method = new ReflectionMethod('Drupal\\select_or_other\\Element\\ElementBase', 'addOtherOption');
  $method
    ->setAccessible(TRUE);
  $options = $method
    ->invoke(NULL, $options);
  $this
    ->assertArrayEquals([
    'select_or_other' => "Other",
  ], $options);
}