function 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[[api-linebreak]] @group Assertion
 
Namespace
Drupal\Tests\Component\AssertionCode
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.