mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
Merge pull request #924 from hungthai1401/to_have_same_size_expectation
[2.x] Add `toHaveSameSize` expectation
This commit is contained in:
@ -272,6 +272,23 @@ final class Expectation
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the size of the value and $expected are the same.
|
||||
*
|
||||
* @param array<int|string, mixed> $expected
|
||||
* @return self<TValue>
|
||||
*/
|
||||
public function toHaveSameSize(iterable $expected, string $message = ''): self
|
||||
{
|
||||
if (! is_countable($this->value) && ! is_iterable($this->value)) {
|
||||
InvalidExpectationValue::expected('countable|iterable');
|
||||
}
|
||||
|
||||
Assert::assertSameSize($expected, $this->value, $message);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the value contains the property $name.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user