mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
Adds support for scoped in HigherOrderExpectations.
This commit is contained in:
@ -74,6 +74,23 @@ it('works with higher order tests')
|
||||
->name()->toEqual('Has Methods')
|
||||
->books()->each->toBeArray;
|
||||
|
||||
it('can use the scoped method to lock into the given level for expectations', function () {
|
||||
expect(new HasMethods())
|
||||
->attributes()->scoped(fn ($attributes) => $attributes
|
||||
->name->toBe('Has Methods')
|
||||
->quantity->toBe(20)
|
||||
)
|
||||
->name()->toBeString()->toBe('Has Methods')
|
||||
->newInstance()->newInstance()->scoped(fn ($instance) => $instance
|
||||
->name()->toBe('Has Methods')
|
||||
->quantity()->toBe(20)
|
||||
->attributes()->scoped(fn ($attributes) => $attributes
|
||||
->name->toBe('Has Methods')
|
||||
->quantity->toBe(20)
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
class HasMethods
|
||||
{
|
||||
public function name()
|
||||
|
||||
Reference in New Issue
Block a user