mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
feat: casts to array using toArray
This commit is contained in:
@ -412,7 +412,11 @@ final class Expectation
|
|||||||
*/
|
*/
|
||||||
public function toHaveKey($key, $value = null): Expectation
|
public function toHaveKey($key, $value = null): Expectation
|
||||||
{
|
{
|
||||||
$array = (array) $this->value;
|
if (is_object($this->value) && method_exists($this->value, 'toArray')) {
|
||||||
|
$array = $this->value->toArray();
|
||||||
|
} else {
|
||||||
|
$array = (array) $this->value;
|
||||||
|
}
|
||||||
|
|
||||||
Assert::assertArrayHasKey($key, $array);
|
Assert::assertArrayHasKey($key, $array);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user