You are here

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

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

Tests the processing of form API #state .

File

tests/src/Unit/ElementsTest.php, line 148

Class

ElementsTest
Tests the form element implementation.

Namespace

Drupal\Tests\select_or_other\Unit

Code

public function testPrepareState() {

  // Test ElementBase.
  // Make the protected method accessible and invoke it.
  $method = new ReflectionMethod('Drupal\\select_or_other\\Element\\ElementBase', 'prepareState');
  $method
    ->setAccessible(TRUE);
  $result = $method
    ->invoke(null, 'state', 'name', 'key', 'value');
  $expected = [
    'state' => [
      ':input[name="name"]' => [
        'key' => 'value',
      ],
    ],
  ];
  $this
    ->assertArrayEquals($expected, $result);
}