Merge pull request #520 from abenerd/feature/new-expectation

add new expectation
This commit is contained in:
Nuno Maduro
2022-05-24 08:00:25 +01:00
committed by GitHub
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.
*