function NestedArrayUnitTest::testSetValue

Tests setting nested array values.

File

drupal/core/tests/Drupal/Tests/Core/NestedArrayUnitTest.php, line 81
Contains \Drupal\Core\NestedArrayUnitTest.

Class

NestedArrayUnitTest
Tests the NestedArray helper class.

Namespace

Drupal\Tests\Core

Code

function testSetValue() {
  $new_value = array(
    '#value' => 'New value',
    '#required' => TRUE,
  );

  // Verify setting the value of a nested element.
  NestedArray::setValue($this->form, $this->parents, $new_value);
  $this
    ->assertEquals($this->form['details']['element']['#value'], 'New value', 'Changed nested element value found.');
  $this
    ->assertSame($this->form['details']['element']['#required'], TRUE, 'New nested element value found.');
}