public function FormStateValuesTraitTest::testGetValueModifyReturn in Drupal 9
Same name and namespace in other branches
- 8 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));
}