function SubformStateTest::testGetValues

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Form/SubformStateTest.php \Drupal\Tests\Core\Form\SubformStateTest::testGetValues()
  2. 10 core/tests/Drupal/Tests/Core/Form/SubformStateTest.php \Drupal\Tests\Core\Form\SubformStateTest::testGetValues()
  3. 11.x core/tests/Drupal/Tests/Core/Form/SubformStateTest.php \Drupal\Tests\Core\Form\SubformStateTest::testGetValues()

@covers ::getValues @covers ::getParents

@dataProvider providerGetValues

Parameters

string[] $parents: The parents.

string $expected: The expected state values.

1 call to SubformStateTest::testGetValues()
SubformStateTest::testGetValuesBroken in core/tests/Drupal/Tests/Core/Form/SubformStateTest.php
@covers ::getValues @covers ::getParents

File

core/tests/Drupal/Tests/Core/Form/SubformStateTest.php, line 68

Class

SubformStateTest
@coversDefaultClass \Drupal\Core\Form\SubformState

Namespace

Drupal\Tests\Core\Form

Code

public function testGetValues(array $parents, $expected) {
    $parent_form_state = new FormState();
    $parent_form_state->setValues($this->formStateValues);
    $subform = NestedArray::getValue($this->parentForm, $parents);
    $subform_state = SubformState::createForSubform($subform, $this->parentForm, $parent_form_state);
    $subform_state_values =& $subform_state->getValues();
    $this->assertSame($expected, $subform_state_values);
    // Modify the retrieved values and confirm they are modified by reference in
    // the parent form state.
    $subform_state_values['fish'] = 'Jim';
    $this->assertSame($subform_state_values, $subform_state->getValues());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.