You are here

public function FormStateTest::testSetValueForElement in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Form/FormStateTest.php \Drupal\Tests\Core\Form\FormStateTest::testSetValueForElement()

Tests that setting the value for an element adds to the values.

@covers ::setValueForElement

File

core/tests/Drupal/Tests/Core/Form/FormStateTest.php, line 150
Contains \Drupal\Tests\Core\Form\FormStateTest.

Class

FormStateTest
@coversDefaultClass \Drupal\Core\Form\FormState

Namespace

Drupal\Tests\Core\Form

Code

public function testSetValueForElement() {
  $element = array(
    '#parents' => array(
      'foo',
      'bar',
    ),
  );
  $value = $this
    ->randomMachineName();
  $form_state = new FormState();
  $form_state
    ->setValueForElement($element, $value);
  $expected = array(
    'foo' => array(
      'bar' => $value,
    ),
  );
  $this
    ->assertSame($expected, $form_state
    ->getValues());
}