add new expectation

This commit is contained in:
abenerd
2022-05-08 11:09:35 +02:00
parent 3dd7b677bd
commit 452d4b26b9
2 changed files with 36 additions and 0 deletions

View File

@ -799,6 +799,22 @@ final class Expectation
return $this;
}
/**
* @param class-string $class
*
* @return Expectation<TValue>
*/
public function toContainOnlyInstancesOf(string $class): Expectation
{
if (!is_iterable($this->value)) {
InvalidExpectationValue::expected('iterable');
}
Assert::assertContainsOnlyInstancesOf($class, $this->value);
return $this;
}
/**
* Asserts that executing value throws an exception.
*