mirror of
https://github.com/pestphp/pest.git
synced 2026-03-09 09:17:23 +01:00
Merge pull request #465 from pestphp/v2_json_fix
Makes `json` expectation usable in Higher Order Tests
This commit is contained in:
@ -62,7 +62,7 @@ final class Expectation
|
||||
/**
|
||||
* Creates a new expectation with the decoded JSON value.
|
||||
*
|
||||
* @return self<mixed>
|
||||
* @return self<array<int|string, mixed>|bool>
|
||||
*/
|
||||
public function json(): Expectation
|
||||
{
|
||||
@ -70,7 +70,10 @@ final class Expectation
|
||||
InvalidExpectationValue::expected('string');
|
||||
}
|
||||
|
||||
return $this->toBeJson()->and(json_decode($this->value, true));
|
||||
/** @var array<int|string, mixed>|bool $value */
|
||||
$value = json_decode($this->value, true);
|
||||
|
||||
return $this->toBeJson()->and($value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -79,6 +79,16 @@ final class HigherOrderExpectation
|
||||
return $this->expect($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new expectation with the decoded JSON value.
|
||||
*
|
||||
* @return self<TOriginalValue, array<string|int, mixed>|bool>
|
||||
*/
|
||||
public function json(): self
|
||||
{
|
||||
return new self($this->original, $this->expectation->json()->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically calls methods on the class with the given arguments.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user