function ArrayUnitTest::testSet

Tests setting nested array values.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Common/ArrayUnitTest.php, line 78
Definition of Drupal\system\Tests\Common\ArrayUnitTest.

Class

ArrayUnitTest
Tests the various drupal_array_* helper functions.

Namespace

Drupal\system\Tests\Common

Code

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

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