mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
Makes json expectation usable in Higher Order Tests
This commit is contained in:
@ -74,8 +74,20 @@ it('works with higher order tests')
|
||||
->name()->toEqual('Has Methods')
|
||||
->books()->each->toBeArray;
|
||||
|
||||
it('works consistently with the json expectation method', function () {
|
||||
expect(new HasMethods())
|
||||
->jsonString()->json()->id->toBe(1)
|
||||
->jsonString()->json()->name->toBe('Has Methods')->toBeString()
|
||||
->jsonString()->json()->quantity->toBe(20)->toBeInt();
|
||||
});
|
||||
|
||||
class HasMethods
|
||||
{
|
||||
public function jsonString(): string
|
||||
{
|
||||
return '{ "id": 1, "name": "Has Methods", "quantity": 20 }';
|
||||
}
|
||||
|
||||
public function name()
|
||||
{
|
||||
return 'Has Methods';
|
||||
|
||||
Reference in New Issue
Block a user