fix tests

This commit is contained in:
Fabio Ivona
2022-08-29 12:47:31 +02:00
parent 6252e288b9
commit 42ceddf374

View File

@ -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)) {