function InspectorTest::testAssertAllHaveKey

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

Tests asserting all members have specified keys.

@legacy-covers ::assertAllHaveKey

File

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

Class

InspectorTest
Tests Drupal\Component\Assertion\Inspector.

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.