mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
fix tests
This commit is contained in:
@ -710,11 +710,11 @@ final class Expectation
|
||||
/**
|
||||
* Asserts that the value array matches the given array subset.
|
||||
*
|
||||
* @param iterable<int|string, mixed> $array
|
||||
* @param iterable<int|string, mixed>|object $array
|
||||
*
|
||||
* @return Expectation<TValue>
|
||||
*/
|
||||
public function toMatchArray(iterable|object $array): Expectation
|
||||
public function toMatchArray(array|object $array): Expectation
|
||||
{
|
||||
if (is_object($this->value) && method_exists($this->value, 'toArray')) {
|
||||
$valueAsArray = $this->value->toArray();
|
||||
@ -722,6 +722,10 @@ final class Expectation
|
||||
$valueAsArray = (array) $this->value;
|
||||
}
|
||||
|
||||
if (is_object($array) && method_exists($array, 'toArray')) {
|
||||
$array = $array->toArray();
|
||||
}
|
||||
|
||||
foreach ($array as $key => $value) {
|
||||
Assert::assertArrayHasKey($key, $valueAsArray);
|
||||
|
||||
@ -743,11 +747,11 @@ final class Expectation
|
||||
* Asserts that the value object matches a subset
|
||||
* of the properties of an given object.
|
||||
*
|
||||
* @param iterable<string, mixed>|object $object
|
||||
* @param object|array<string, mixed> $object
|
||||
*
|
||||
* @return Expectation<TValue>
|
||||
*/
|
||||
public function toMatchObject(iterable|object $object): Expectation
|
||||
public function toMatchObject(object|array $object): Expectation
|
||||
{
|
||||
foreach ((array) $object as $property => $value) {
|
||||
if (!is_object($this->value) && !is_string($this->value)) {
|
||||
|
||||
Reference in New Issue
Block a user