You are here

public function InspectorTest::testAssertAllObjects in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Component/Assertion/InspectorTest.php \Drupal\Tests\Component\Assertion\InspectorTest::testAssertAllObjects()

Tests asserting all members are objects.

@covers ::assertAllObjects

File

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

Class

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

Namespace

Drupal\Tests\Component\Assertion

Code

public function testAssertAllObjects() {
  $this
    ->assertTrue(Inspector::assertAllObjects([
    new \ArrayObject(),
    new \ArrayObject(),
  ]));
  $this
    ->assertFalse(Inspector::assertAllObjects([
    new \ArrayObject(),
    new \ArrayObject(),
    'foo',
  ]));
  $this
    ->assertTrue(Inspector::assertAllObjects([
    new \ArrayObject(),
    new \ArrayObject(),
  ], '\\Traversable'));
  $this
    ->assertFalse(Inspector::assertAllObjects([
    new \ArrayObject(),
    new \ArrayObject(),
    'foo',
  ], '\\Traversable'));
  $this
    ->assertFalse(Inspector::assertAllObjects([
    new \ArrayObject(),
    new StringObject(),
  ], '\\Traversable'));
  $this
    ->assertTrue(Inspector::assertAllObjects([
    new \ArrayObject(),
    new StringObject(),
  ], '\\Traversable', '\\Drupal\\Tests\\Component\\Assertion\\StringObject'));
  $this
    ->assertFalse(Inspector::assertAllObjects([
    new \ArrayObject(),
    new StringObject(),
    new \stdClass(),
  ], '\\ArrayObject', '\\Drupal\\Tests\\Component\\Assertion\\StringObject'));
}