mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
Merge pull request #1357 from drsdre/patch-1
toMatchArray/Object wrong field fix
This commit is contained in:
@ -781,15 +781,13 @@ final class Expectation
|
|||||||
foreach ($array as $key => $value) {
|
foreach ($array as $key => $value) {
|
||||||
Assert::assertArrayHasKey($key, $valueAsArray, $message);
|
Assert::assertArrayHasKey($key, $valueAsArray, $message);
|
||||||
|
|
||||||
if ($message === '') {
|
$second_message = $message !== '' ? $message : sprintf(
|
||||||
$message = sprintf(
|
'Failed asserting that an array has a key %s with the value %s.',
|
||||||
'Failed asserting that an array has a key %s with the value %s.',
|
$this->export($key),
|
||||||
$this->export($key),
|
$this->export($valueAsArray[$key]),
|
||||||
$this->export($valueAsArray[$key]),
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Assert::assertEquals($value, $valueAsArray[$key], $message);
|
Assert::assertEquals($value, $valueAsArray[$key], $second_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@ -814,15 +812,13 @@ final class Expectation
|
|||||||
/* @phpstan-ignore-next-line */
|
/* @phpstan-ignore-next-line */
|
||||||
$propertyValue = $this->value->{$property};
|
$propertyValue = $this->value->{$property};
|
||||||
|
|
||||||
if ($message === '') {
|
$second_message = $message !== '' ? $message : sprintf(
|
||||||
$message = sprintf(
|
'Failed asserting that an object has a property %s with the value %s.',
|
||||||
'Failed asserting that an object has a property %s with the value %s.',
|
$this->export($property),
|
||||||
$this->export($property),
|
$this->export($propertyValue),
|
||||||
$this->export($propertyValue),
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Assert::assertEquals($value, $propertyValue, $message);
|
Assert::assertEquals($value, $propertyValue, $second_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|||||||
Reference in New Issue
Block a user