function FormStateValuesTraitTest::testHasValue

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Form/FormStateValuesTraitTest.php \Drupal\Tests\Core\Form\FormStateValuesTraitTest::testHasValue()
  2. 10 core/tests/Drupal/Tests/Core/Form/FormStateValuesTraitTest.php \Drupal\Tests\Core\Form\FormStateValuesTraitTest::testHasValue()
  3. 11.x core/tests/Drupal/Tests/Core/Form/FormStateValuesTraitTest.php \Drupal\Tests\Core\Form\FormStateValuesTraitTest::testHasValue()

@covers ::hasValue

@dataProvider providerHasValue

File

core/tests/Drupal/Tests/Core/Form/FormStateValuesTraitTest.php, line 150

Class

FormStateValuesTraitTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Form%21FormStateValuesTrait.php/trait/FormStateValuesTrait/9" title="Provides methods to manage form state values." class="local">\Drupal\Core\Form\FormStateValuesTrait</a>

Namespace

Drupal\Tests\Core\Form

Code

public function testHasValue($key, $expected) {
    $form_state = (new FormStateValuesTraitStub())->setValues([
        'foo' => 'one',
        'bar' => [
            'baz' => 'two',
        ],
        'true' => TRUE,
        'false' => FALSE,
        'null' => NULL,
    ]);
    $this->assertSame($expected, $form_state->hasValue($key));
}

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