function ArrayUnitTest::testKeyExists

Tests existence of array key.

File

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

Class

ArrayUnitTest
Tests the various drupal_array_* helper functions.

Namespace

Drupal\system\Tests\Common

Code

function testKeyExists() {

  // Verify that existing key is found.
  $this
    ->assertIdentical(drupal_array_nested_key_exists($this->form, $this->parents), TRUE, 'Nested key found.');

  // Verify that non-existing keys are not found.
  $parents = $this->parents;
  $parents[] = 'foo';
  $this
    ->assertIdentical(drupal_array_nested_key_exists($this->form, $parents), FALSE, 'Non-existing nested key not found.');
}