function InspectorTest::testAssertAllHaveKey

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Component/Assertion/InspectorTest.php \Drupal\Tests\Component\Assertion\InspectorTest::testAssertAllHaveKey()
  2. 10 core/tests/Drupal/Tests/Component/Assertion/InspectorTest.php \Drupal\Tests\Component\Assertion\InspectorTest::testAssertAllHaveKey()
  3. 11.x core/tests/Drupal/Tests/Component/Assertion/InspectorTest.php \Drupal\Tests\Component\Assertion\InspectorTest::testAssertAllHaveKey()

Tests asserting all members have specified keys.

@covers ::assertAllHaveKey

File

core/tests/Drupal/Tests/Component/Assertion/InspectorTest.php, line 117

Class

InspectorTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Component%21Assertion%21Inspector.php/class/Inspector/8.9.x" title="Generic inspections for the assert() statement." class="local">\Drupal\Component\Assertion\Inspector</a> @group Assertion

Namespace

Drupal\Tests\Component\Assertion

Code

public function testAssertAllHaveKey() {
    $this->assertTrue(Inspector::assertAllHaveKey([]));
    $this->assertTrue(Inspector::assertAllHaveKey([
        [
            'foo' => 'bar',
            'bar' => 'foo',
        ],
    ]));
    $this->assertTrue(Inspector::assertAllHaveKey([
        [
            'foo' => 'bar',
            'bar' => 'foo',
        ],
    ], 'foo'));
    $this->assertTrue(Inspector::assertAllHaveKey([
        [
            'foo' => 'bar',
            'bar' => 'foo',
        ],
    ], 'bar', 'foo'));
    $this->assertFalse(Inspector::assertAllHaveKey([
        [
            'foo' => 'bar',
            'bar' => 'foo',
        ],
    ], 'bar', 'foo', 'moo'));
}

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