Factory
Uses
Properties
$globalMiddleware array
The middleware to apply to every request.
$stubCallbacks Illuminate\...\Collection
The stub callables that will handle requests.
$recording bool
Indicates if the factory is recording requests and responses.
$recorded array
The recorded response array.
$responseSequences array
All created response sequences.
$preventStrayRequests bool
Indicates that an exception should be thrown if any request is not faked.
Methods
__construct ( Dispatcher $dispatcher ) : void
Create a new factory instance.
Parameters
- $dispatcher Dispatcher |null
globalMiddleware ( $middleware ) : $this
Add middleware to apply to every request.
Parameters
- $middleware callable
globalRequestMiddleware ( $middleware ) : $this
Add request middleware to apply to every request.
Parameters
- $middleware callable
globalResponseMiddleware ( $middleware ) : $this
Add response middleware to apply to every request.
Parameters
- $middleware callable
response ( $body , $status , $headers ) : GuzzleHttp\...\PromiseInterface
Create a new response instance for use during stubbing.
Parameters
- $body array|string|null
- $status int
- $headers array
sequence ( array $responses ) : ResponseSequence
Get an invokable object that returns a sequence of responses in order for use during stubbing.
Parameters
- $responses array
fake ( $callback ) : $this
Register a stub callable that will intercept requests and be able to return stub responses.
Parameters
- $callback callable|array|null
fakeSequence ( $url ) : ResponseSequence
Register a response sequence for the given URL pattern.
Parameters
- $url string
stubUrl ( $url , $callback ) : $this
Stub the given URL using the given callback.
Parameters
- $url string
- $callback Response |GuzzleHttp\...\PromiseInterface|callable
preventStrayRequests ( $prevent ) : $this
Indicate that an exception should be thrown if any request is not faked.
Parameters
- $prevent bool
allowStrayRequests ( ) : $this
Indicate that an exception should not be thrown if any request is not faked.
record ( ) : $this
Begin recording request / response pairs.
recordRequestResponsePair ( $request , $response ) : void
Record a request response pair.
Parameters
assertSent ( $callback ) : void
Assert that a request / response pair was recorded matching a given truth test.
Parameters
- $callback callable
assertSentInOrder ( $callbacks ) : void
Assert that the given request was sent in the given order.
Parameters
- $callbacks array
assertNotSent ( $callback ) : void
Assert that a request / response pair was not recorded matching a given truth test.
Parameters
- $callback callable
assertNothingSent ( ) : void
Assert that no request / response pair was recorded.
assertSentCount ( $count ) : void
Assert how many requests have been recorded.
Parameters
- $count int
assertSequencesAreEmpty ( ) : void
Assert that every created response sequence is empty.
recorded ( $callback ) : Illuminate\...\Collection
Get a collection of the request / response pairs matching the given truth test.
Parameters
- $callback callable
newPendingRequest ( ) : PendingRequest
Create a new pending request instance for this factory.
__call ( $method , $parameters ) : mixed
Execute a method against a new pending request instance.
Parameters
- $method string
- $parameters array