From 42ceddf37475560ab55f9e8c33843eef0a27bfca Mon Sep 17 00:00:00 2001 From: Fabio Ivona Date: Mon, 29 Aug 2022 12:47:31 +0200 Subject: [PATCH] fix tests --- src/Mixins/Expectation.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Mixins/Expectation.php b/src/Mixins/Expectation.php index ace37cf9..8c9dd99d 100644 --- a/src/Mixins/Expectation.php +++ b/src/Mixins/Expectation.php @@ -710,11 +710,11 @@ final class Expectation /** * Asserts that the value array matches the given array subset. * - * @param iterable $array + * @param iterable|object $array * * @return Expectation */ - 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|object $object + * @param object|array $object * * @return Expectation */ - 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)) {