assertTraversable example


  public static function assertAll(callable $callable$traversable) {
    if (static::assertTraversable($traversable)) {
      foreach ($traversable as $member) {
        if (!$callable($member)) {
          return FALSE;
        }
      }
      return TRUE;
    }
    return FALSE;
  }

  /** * Asserts that all members are strings. * * Use this only if it is vital that the members not be objects, otherwise * test with ::assertAllStringable(). * * @param mixed $traversable * Variable to be examined. * * @return bool * TRUE if $traversable can be traversed and all members are strings. */

class InspectorTest extends TestCase {

  /** * Tests asserting argument is an array or traversable object. * * @covers ::assertTraversable */
  public function testAssertTraversable() {
    $this->assertTrue(Inspector::assertTraversable([]));
    $this->assertTrue(Inspector::assertTraversable(new \ArrayObject()));
    $this->assertFalse(Inspector::assertTraversable(new \stdClass()));
    $this->assertFalse(Inspector::assertTraversable('foo'));
  }

  /** * Tests asserting all members are strings. * * @covers ::assertAllStrings * @dataProvider providerTestAssertAllStrings */
  
Home | Imprint | This part of the site doesn't use cookies.