class Illuminate / Http / Client / Factory

Factory

Uses

Properties

protected

$dispatcher Dispatcher |null

The event dispatcher implementation.

Default: null
protected

$globalMiddleware array

The middleware to apply to every request.

Default: []
protected

$stubCallbacks Illuminate\...\Collection

The stub callables that will handle requests.

Default: null
protected

$recording bool

Indicates if the factory is recording requests and responses.

Default: false
protected

$recorded array

The recorded response array.

Default: []
protected

$responseSequences array

All created response sequences.

Default: []
protected

$preventStrayRequests bool

Indicates that an exception should be thrown if any request is not faked.

Default: false

Methods

public

__construct ( Dispatcher $dispatcher ) : void

Create a new factory instance.

Parameters

public

globalMiddleware ( $middleware ) : $this

Add middleware to apply to every request.

Parameters

  • $middleware callable
public

globalRequestMiddleware ( $middleware ) : $this

Add request middleware to apply to every request.

Parameters

  • $middleware callable
public

globalResponseMiddleware ( $middleware ) : $this

Add response middleware to apply to every request.

Parameters

  • $middleware callable
public static

response ( $body , $status , $headers ) : GuzzleHttp\...\PromiseInterface

Create a new response instance for use during stubbing.

Parameters

  • $body array|string|null
  • $status int
  • $headers array
public

sequence ( array $responses ) : ResponseSequence

Get an invokable object that returns a sequence of responses in order for use during stubbing.

Parameters

  • $responses array
public

fake ( $callback ) : $this

Register a stub callable that will intercept requests and be able to return stub responses.

Parameters

  • $callback callable|array|null
public

fakeSequence ( $url ) : ResponseSequence

Register a response sequence for the given URL pattern.

Parameters

  • $url string
public

stubUrl ( $url , $callback ) : $this

Stub the given URL using the given callback.

Parameters

  • $url string
  • $callback Response |GuzzleHttp\...\PromiseInterface|callable
public

preventStrayRequests ( $prevent ) : $this

Indicate that an exception should be thrown if any request is not faked.

Parameters

  • $prevent bool
public

allowStrayRequests ( ) : $this

Indicate that an exception should not be thrown if any request is not faked.

protected

record ( ) : $this

Begin recording request / response pairs.

public

recordRequestResponsePair ( $request , $response ) : void

Record a request response pair.

Parameters

public

assertSent ( $callback ) : void

Assert that a request / response pair was recorded matching a given truth test.

Parameters

  • $callback callable
public

assertSentInOrder ( $callbacks ) : void

Assert that the given request was sent in the given order.

Parameters

  • $callbacks array
public

assertNotSent ( $callback ) : void

Assert that a request / response pair was not recorded matching a given truth test.

Parameters

  • $callback callable
public

assertNothingSent ( ) : void

Assert that no request / response pair was recorded.

public

assertSentCount ( $count ) : void

Assert how many requests have been recorded.

Parameters

  • $count int
public

assertSequencesAreEmpty ( ) : void

Assert that every created response sequence is empty.

public

recorded ( $callback ) : Illuminate\...\Collection

Get a collection of the request / response pairs matching the given truth test.

Parameters

  • $callback callable
protected

newPendingRequest ( ) : PendingRequest

Create a new pending request instance for this factory.

public

getDispatcher ( ) : Dispatcher |null

Get the current event dispatcher implementation.

public

__call ( $method , $parameters ) : mixed

Execute a method against a new pending request instance.

Parameters

  • $method string
  • $parameters array