Mock
in package
implements
MockInterface
Stores one request expectation, response strategy, and hit lifecycle.
Tags
Table of Contents
Interfaces
- MockInterface
- Internal contract for a stateful request expectation and its configured outcome.
Methods
- __construct() : mixed
- Mock constructor.
- available() : bool
- Returns true if mock is still can be used.
- getReplyFactory() : ReplyFactoryInterface|null
- Returns reply factory which should be used to form the mocked response.
- getResponse() : ResponseInterface|null
- Returns response which should be used as mock data.
- getThrowable() : Throwable|null
- Returns the throwable which will be thrown as mock data.
- matches() : bool
- Returns true if underlying matcher has matched provided request.
- registerHit() : MockInterface
- Registers a hit to the mock.
Methods
__construct()
Mock constructor.
public
__construct(RequestMatcherInterface $matcher, ReplyFactoryInterface|null $replyFactory, ResponseInterface|null $response, Throwable|null $throwable, int $maxHits, int $matchAt) : mixed
Parameters
- $matcher : RequestMatcherInterface
- $replyFactory : ReplyFactoryInterface|null
- $response : ResponseInterface|null
- $throwable : Throwable|null
- $maxHits : int
- $matchAt : int
available()
Returns true if mock is still can be used.
public
available() : bool
Tags
Return values
boolgetReplyFactory()
Returns reply factory which should be used to form the mocked response.
public
getReplyFactory() : ReplyFactoryInterface|null
Tags
Return values
ReplyFactoryInterface|nullgetResponse()
Returns response which should be used as mock data.
public
getResponse() : ResponseInterface|null
Tags
Return values
ResponseInterface|nullgetThrowable()
Returns the throwable which will be thrown as mock data.
public
getThrowable(RequestInterface $request) : Throwable|null
Parameters
- $request : RequestInterface
-
This request may be set into exception if possible
Tags
Return values
Throwable|nullmatches()
Returns true if underlying matcher has matched provided request.
public
matches(RequestInterface $request) : bool
Parameters
- $request : RequestInterface
Tags
Return values
boolregisterHit()
Registers a hit to the mock.
public
registerHit() : MockInterface