function FormStateValuesTraitTest::testGetValueModifyReturn
Same name in other branches
- 8.9.x core/tests/Drupal/Tests/Core/Form/FormStateValuesTraitTest.php \Drupal\Tests\Core\Form\FormStateValuesTraitTest::testGetValueModifyReturn()
- 10 core/tests/Drupal/Tests/Core/Form/FormStateValuesTraitTest.php \Drupal\Tests\Core\Form\FormStateValuesTraitTest::testGetValueModifyReturn()
- 11.x core/tests/Drupal/Tests/Core/Form/FormStateValuesTraitTest.php \Drupal\Tests\Core\Form\FormStateValuesTraitTest::testGetValueModifyReturn()
@covers ::getValue
File
-
core/
tests/ Drupal/ Tests/ Core/ Form/ FormStateValuesTraitTest.php, line 92
Class
- FormStateValuesTraitTest
- @coversDefaultClass \Drupal\Core\Form\FormStateValuesTrait
Namespace
Drupal\Tests\Core\FormCode
public function testGetValueModifyReturn() {
$initial_values = $values = [
'foo' => 'one',
'bar' => [
'baz' => 'two',
],
];
$form_state = (new FormStateValuesTraitStub())->setValues($values);
$value =& $form_state->getValue(NULL);
$this->assertSame($initial_values, $value);
$value = [
'bing' => 'bang',
];
$this->assertSame([
'bing' => 'bang',
], $form_state->getValues());
$this->assertSame('bang', $form_state->getValue('bing'));
$this->assertSame([
'bing' => 'bang',
], $form_state->getValue(NULL));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.