function InspectorTest::testAssertAllHaveKey

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Component/Assertion/InspectorTest.php \Drupal\Tests\Component\Assertion\InspectorTest::testAssertAllHaveKey()
  2. 8.9.x 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 120

Class

InspectorTest
@coversDefaultClass \Drupal\Component\Assertion\Inspector @group Assertion

Namespace

Drupal\Tests\Component\Assertion

Code

public function testAssertAllHaveKey() : void {
    $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.