mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
Allows and in Higher Order Expectations.
This commit is contained in:
@ -63,6 +63,16 @@ final class HigherOrderExpectation
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new expectation.
|
||||||
|
*
|
||||||
|
* @param mixed $value
|
||||||
|
*/
|
||||||
|
public function and($value): HigherOrderExpectation
|
||||||
|
{
|
||||||
|
return new self($this->expect($value), $value);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dynamically calls methods on the class with the given arguments.
|
* Dynamically calls methods on the class with the given arguments.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -22,6 +22,17 @@ it('can handle nested methods and properties', function () {
|
|||||||
->newInstance()->books()->toBeArray();
|
->newInstance()->books()->toBeArray();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('can start a new higher order expectation using the and syntax', function () {
|
||||||
|
expect(new HasMethodsAndProperties())
|
||||||
|
->toBeInstanceOf(HasMethodsAndProperties::class)
|
||||||
|
->meta->toBeArray
|
||||||
|
->and(['foo' => 'bar'])
|
||||||
|
->toBeArray()
|
||||||
|
->foo->toEqual('bar');
|
||||||
|
|
||||||
|
expect(static::getCount())->toEqual(4);
|
||||||
|
});
|
||||||
|
|
||||||
class HasMethodsAndProperties
|
class HasMethodsAndProperties
|
||||||
{
|
{
|
||||||
public $name = 'Has Methods and Properties';
|
public $name = 'Has Methods and Properties';
|
||||||
|
|||||||
Reference in New Issue
Block a user