Skip to content

Commit

Permalink
Add support for iterable in assertInternalType
Browse files Browse the repository at this point in the history
  • Loading branch information
gzumba authored and sebastianbergmann committed Mar 6, 2018
1 parent 3ff73dd commit bdfae3c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Framework/Constraint/IsType.php
Expand Up @@ -47,7 +47,8 @@ class IsType extends Constraint
'resource' => true,
'string' => true,
'scalar' => true,
'callable' => true
'callable' => true,
'iterable' => true,
];

/**
Expand Down Expand Up @@ -137,6 +138,9 @@ protected function matches($other): bool

case 'callable':
return \is_callable($other);

case 'iterable':
return \is_iterable($other);
}
}
}
8 changes: 8 additions & 0 deletions tests/Framework/Constraint/IsTypeTest.php
Expand Up @@ -91,6 +91,14 @@ public function resources()
];
}

public function testIterableTypeIsSupported(): void
{
$constraint = Assert::isType('iterable');

$this->assertFalse($constraint->evaluate('', '', true));
$this->assertTrue($constraint->evaluate([], '', true));
$this->assertEquals('is of type "iterable"', $constraint->toString());
}
/**
* Removes spaces in front of newlines
*
Expand Down

0 comments on commit bdfae3c

Please sign in to comment.