You are here

public function InspectorTest::testAssertAllHaveKey in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 116
Contains \Drupal\Tests\Component\Assertion\InspectorTest.

Class

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

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'));
}