mirror of
https://github.com/pestphp/pest.git
synced 2026-03-07 00:07:22 +01:00
Merge pull request #461 from pestphp/json_fix
Fixes `json` in Higher Order Expectations
This commit is contained in:
@ -77,6 +77,11 @@ final class HigherOrderExpectation
|
|||||||
return $this->expect($value);
|
return $this->expect($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function json(): HigherOrderExpectation
|
||||||
|
{
|
||||||
|
return new self($this->original, $this->expectation->json()->value);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dynamically calls methods on the class with the given arguments.
|
* Dynamically calls methods on the class with the given arguments.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -124,6 +124,7 @@
|
|||||||
✓ it can compose complex expectations
|
✓ it can compose complex expectations
|
||||||
✓ it can handle nested method calls
|
✓ it can handle nested method calls
|
||||||
✓ it works with higher order tests
|
✓ it works with higher order tests
|
||||||
|
✓ it can call the json method in higher order expectations
|
||||||
|
|
||||||
PASS Tests\Features\Expect\HigherOrder\methodsAndProperties
|
PASS Tests\Features\Expect\HigherOrder\methodsAndProperties
|
||||||
✓ it can access methods and properties
|
✓ it can access methods and properties
|
||||||
@ -720,5 +721,5 @@
|
|||||||
✓ it is a test
|
✓ it is a test
|
||||||
✓ it uses correct parent class
|
✓ it uses correct parent class
|
||||||
|
|
||||||
Tests: 4 incompleted, 9 skipped, 478 passed
|
Tests: 4 incompleted, 9 skipped, 479 passed
|
||||||
|
|
||||||
@ -74,8 +74,19 @@ it('works with higher order tests')
|
|||||||
->name()->toEqual('Has Methods')
|
->name()->toEqual('Has Methods')
|
||||||
->books()->each->toBeArray;
|
->books()->each->toBeArray;
|
||||||
|
|
||||||
|
it('can call the json method in higher order expectations', function () {
|
||||||
|
expect(new HasMethods())
|
||||||
|
->getJsonContent()->json()->id->toBe(1)->toBeGreaterThan(0)
|
||||||
|
->getJsonContent()->json()->email->toBe('foo@bar.com');
|
||||||
|
});
|
||||||
|
|
||||||
class HasMethods
|
class HasMethods
|
||||||
{
|
{
|
||||||
|
public function getJsonContent(): string
|
||||||
|
{
|
||||||
|
return '{"id":1,"username":"dan","email":"foo@bar.com"}';
|
||||||
|
}
|
||||||
|
|
||||||
public function name()
|
public function name()
|
||||||
{
|
{
|
||||||
return 'Has Methods';
|
return 'Has Methods';
|
||||||
|
|||||||
Reference in New Issue
Block a user