function NestedArrayTest::testKeyExists

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Component/Utility/NestedArrayTest.php \Drupal\Tests\Component\Utility\NestedArrayTest::testKeyExists()
  2. 8.9.x core/tests/Drupal/Tests/Component/Utility/NestedArrayTest.php \Drupal\Tests\Component\Utility\NestedArrayTest::testKeyExists()
  3. 10 core/tests/Drupal/Tests/Component/Utility/NestedArrayTest.php \Drupal\Tests\Component\Utility\NestedArrayTest::testKeyExists()

Tests existence of array key.

File

core/tests/Drupal/Tests/Component/Utility/NestedArrayTest.php, line 136

Class

NestedArrayTest
@coversDefaultClass \Drupal\Component\Utility\NestedArray @group Utility

Namespace

Drupal\Tests\Component\Utility

Code

public function testKeyExists() : void {
    // Verify that existing key is found.
    $this->assertTrue(NestedArray::keyExists($this->form, $this->parents), 'Nested key found.');
    // Verify that non-existing keys are not found.
    $parents = $this->parents;
    $parents[] = 'foo';
    $this->assertFalse(NestedArray::keyExists($this->form, $parents), 'Non-existing nested key not found.');
}

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