mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
add new assertion
This commit is contained in:
@ -154,9 +154,10 @@ final class Expectation
|
|||||||
throw new BadMethodCallException('Expectation value is not iterable.');
|
throw new BadMethodCallException('Expectation value is not iterable.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$value = is_array($this->value) ? $this->value : iterator_to_array($this->value);
|
$value = is_array($this->value) ? $this->value : iterator_to_array($this->value);
|
||||||
$keys = array_keys($value);
|
$keys = array_keys($value);
|
||||||
$values = array_values($value);
|
$values = array_values($value);
|
||||||
|
$callbacksCount = count($callbacks);
|
||||||
|
|
||||||
$index = 0;
|
$index = 0;
|
||||||
|
|
||||||
@ -165,6 +166,10 @@ final class Expectation
|
|||||||
$index = $index < count($values) - 1 ? $index + 1 : 0;
|
$index = $index < count($values) - 1 ? $index + 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($callbacksCount > count($values)) {
|
||||||
|
Assert::assertLessThanOrEqual(count($value), count($callbacks));
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($values as $key => $item) {
|
foreach ($values as $key => $item) {
|
||||||
if (is_callable($callbacks[$key])) {
|
if (is_callable($callbacks[$key])) {
|
||||||
call_user_func($callbacks[$key], new self($item), new self($keys[$key]));
|
call_user_func($callbacks[$key], new self($item), new self($keys[$key]));
|
||||||
|
|||||||
Reference in New Issue
Block a user