mirror of
https://github.com/pestphp/pest.git
synced 2026-03-07 00:07:22 +01:00
feat: toHaveSameSize expectation
This commit is contained in:
@ -6,6 +6,7 @@ namespace Pest\Mixins;
|
|||||||
|
|
||||||
use BadMethodCallException;
|
use BadMethodCallException;
|
||||||
use Closure;
|
use Closure;
|
||||||
|
use Countable;
|
||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
use Error;
|
use Error;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
@ -272,6 +273,22 @@ final class Expectation
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts that the size of the value and $expected are the same.
|
||||||
|
*
|
||||||
|
* @return self<TValue>
|
||||||
|
*/
|
||||||
|
public function toHaveSameSize(Countable|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.
|
* Asserts that the value contains the property $name.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user