class Illuminate / Http / Client / Factory
You are viewing an older version of the documentation. For the latest, please visit master documentation.

Factory

Uses

See

  • \Illuminate\Http\Client\PendingRequest

Properties

protected

$dispatcher Dispatcher |null

The event dispatcher implementation.

Default: null
protected

$stubCallbacks 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: []

Methods

public

__construct ( Dispatcher $dispatcher ) : void

Create a new factory instance.

Parameters

public static

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

Create a new response instance for use during stubbing.

Parameters

  • $body array|string
  • $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
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
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 ) : 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