diff --git a/core/tests/Drupal/Tests/Core/Form/FormStateTest.php b/core/tests/Drupal/Tests/Core/Form/FormStateTest.php index 3c60ddf..8e1ca97 100644 --- a/core/tests/Drupal/Tests/Core/Form/FormStateTest.php +++ b/core/tests/Drupal/Tests/Core/Form/FormStateTest.php @@ -159,4 +159,28 @@ public function testFormErrorsDuringSubmission() { $form_state->setErrorByName('test', 'message'); } + /** + * Tests that setting the value for an element adds to the values. + * + * @covers ::setValueForElement + */ + public function testSetValueForElement() { + $element = array( + '#parents' => array( + 'foo', + 'bar', + ), + ); + $value = $this->randomName(); + + $form_state = new FormState(); + $form_state->setValueForElement($element, $value); + $expected = array( + 'foo' => array( + 'bar' => $value, + ), + ); + $this->assertSame($expected, $form_state->getValues()); + } + }