function FormHelperTest::testProcessStates

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Form/FormHelperTest.php \Drupal\Tests\Core\Form\FormHelperTest::testProcessStates()
  2. 8.9.x core/tests/Drupal/Tests/Core/Form/FormHelperTest.php \Drupal\Tests\Core\Form\FormHelperTest::testProcessStates()
  3. 10 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 92

Class

FormHelperTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Form%21FormHelper.php/class/FormHelper/11.x" title="Provides helpers to operate on forms." class="local">\Drupal\Core\Form\FormHelper</a> @group Form

Namespace

Drupal\Tests\Core\Form

Code

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.