You are here

public function InspectorTest::testAssertAllHaveKey in Drupal 10

Same name and namespace in other branches
  1. 8 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()

Tests asserting all members have specified keys.

@covers ::assertAllHaveKey

File

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

Class

InspectorTest
@coversDefaultClass \Drupal\Component\Assertion\Inspector @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'));
}