function NestedArrayUnitTest::testKeyExists

Tests existence of array key.

File

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

Class

NestedArrayUnitTest
Tests the NestedArray helper class.

Namespace

Drupal\Tests\Core

Code

function testKeyExists() {

  // Verify that existing key is found.
  $this
    ->assertSame(NestedArray::keyExists($this->form, $this->parents), TRUE, 'Nested key found.');

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