protected final function assertThatExecutionIsDeferred(callable $traversableQuery)
{
$exception = new CustomException();
$throwingFunction = function () use($exception) {
throw $exception;
};
try {
$traversable = $traversableQuery($throwingFunction);
} catch (CustomException $thrownException) {
$this->assertFalse(true, 'Traversable query method should not have thrown the exception');
}
try {
foreach ($traversable as $key => $value) {
$this->assertFalse(true, 'Iteration should caused the exception to be thrown');
}
} catch (CustomException $thrownException) {
$this->assertSame($exception, $thrownException);
}
}