You are here

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

Same name and namespace in other branches
  1. 8.3 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 22

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);
}