You are here

public function FormHelperTest::testProcessStates in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Form/FormHelperTest.php \Drupal\Tests\Core\Form\FormHelperTest::testProcessStates()
  2. 9 core/tests/Drupal/Tests/Core/Form/FormHelperTest.php \Drupal\Tests\Core\Form\FormHelperTest::testProcessStates()

@covers ::processStates @dataProvider providerElements

File

core/tests/Drupal/Tests/Core/Form/FormHelperTest.php, line 90

Class

FormHelperTest
@coversDefaultClass \Drupal\Core\Form\FormHelper @group Form

Namespace

Drupal\Tests\Core\Form

Code

public function testProcessStates($elements, $key) {
  $json = Json::encode($elements['#states']);
  FormHelper::processStates($elements);
  $this
    ->assertEquals([
    'core/drupal.states',
  ], $elements['#attached']['library']);
  $this
    ->assertEquals($json, $elements[$key]['data-drupal-states']);
}