You are here

public function FormStateValuesTraitTest::testSetValue in Drupal 8

Same name and namespace in other branches
  1. 9 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 114

Class

FormStateValuesTraitTest
@coversDefaultClass \Drupal\Core\Form\FormStateValuesTrait

Namespace

Drupal\Tests\Core\Form

Code

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