function FormStateValuesTraitTest::testSetValue

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

@covers ::setValue

@dataProvider providerSetValue

File

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

Class

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

Namespace

Drupal\Tests\Core\Form

Code

public function testSetValue($key, $value, $expected) : void {
    $form_state = (new FormStateValuesTraitStub())->setValues([
        'bar' => 'wrong',
    ]);
    $form_state->setValue($key, $value);
    $this->assertSame($expected, $form_state->getValues());
}

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