function InspectorTest::testAssertTraversable

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

Tests asserting argument is an array or traversable object.

@covers ::assertTraversable

@group legacy

File

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

Class

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

Namespace

Drupal\Tests\Component\Assertion

Code

public function testAssertTraversable() : void {
    $this->expectDeprecation('Drupal\\Component\\Assertion\\Inspector::assertTraversable() is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use is_iterable() instead. See https://www.drupal.org/node/3422775');
    $this->assertTrue(Inspector::assertTraversable([]));
    $this->assertTrue(Inspector::assertTraversable(new \ArrayObject()));
    $this->assertFalse(Inspector::assertTraversable(new \stdClass()));
    $this->assertFalse(Inspector::assertTraversable('foo'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.