Class MockPlugin
Queues mock responses or exceptions and delivers mock responses or exceptions in a fifo order.
- Guzzle\Common\AbstractHasDispatcher implements Guzzle\Common\HasDispatcherInterface
-
Guzzle\Plugin\Mock\MockPlugin
implements
Symfony\Component\EventDispatcher\EventSubscriberInterface,
Countable
Methods summary
-
public__construct ( array $items = null, bool $temporary = false, bool $readBodies = false ) -
public staticgetSubscribedEvents ( ) -
public staticgetAllEvents ( )Get a list of all of the events emitted from the class
-
public staticgetMockFile ( string $path )Get a mock response from a file
-
publicreadBodies ( bool $readBodies )Set whether or not to consume the entity body of a request when a mock response is used
-
publiccount ( )Returns the number of remaining mock responses
-
publicaddResponse ( string|Response $response )Add a response to the end of the queue
-
publicaddException ( Guzzle\Http\Exception\CurlException $e )Add an exception to the end of the queue
-
publicclearQueue ( )Clear the queue
-
publicgetQueue ( )Returns an array of mock responses remaining in the queue
-
publicisTemporary ( )Check if this is a temporary plugin
-
publicdequeue ( Guzzle\Http\Message\RequestInterface $request )Get a response from the front of the list and add it to a request
-
publicflush ( )Clear the array of received requests
-
publicgetReceivedRequests ( )Get an array of requests that were mocked by this plugin
-
publiconRequestBeforeSend ( Guzzle\Common\Event $event )Called when a request is about to be sent
Methods detail
public
__construct( array $items = null, boolean $temporary = false, boolean $readBodies = false )
Parameters
- $items
array
$items Array of responses or exceptions to queue- $temporary
boolean
$temporary Set to TRUE to remove the plugin when the queue is empty- $readBodies
boolean
$readBodies Set to TRUE to consume the entity body when a mock is served
Get a list of all of the events emitted from the class
Returns
arrayOverrides
Get a mock response from a file
Parameters
- $path
string
$path File to retrieve a mock response from
Returns
Throws
Set whether or not to consume the entity body of a request when a mock response is used
Parameters
- $readBodies
boolean
$readBodies Set to true to read and consume entity bodies
Returns
Add a response to the end of the queue
Parameters
- $response
string|Guzzle\Http\Message\Response
$response Response object or path to response file
Returns
Throws
Add an exception to the end of the queue
Parameters
- $e
Guzzle\Http\Exception\CurlException
$e Exception to throw when the request is executed
Returns
Returns an array of mock responses remaining in the queue
Returns
arrayCheck if this is a temporary plugin
Returns
booleanGet a response from the front of the list and add it to a request
Parameters
- $request
Guzzle\Http\Message\RequestInterface
$request Request to mock
Returns
Throws
Clear the array of received requests
Get an array of requests that were mocked by this plugin
Returns
arrayMethods inherited from Guzzle\Common\AbstractHasDispatcher
addSubscriber(),
dispatch(),
getEventDispatcher(),
setEventDispatcher()
Magic methods summary
Properties summary
protected
array
|
$queue |
#
Array of mock responses / exceptions |
protected
boolean
|
$temporary |
#
Whether or not to remove the plugin when the queue is empty |
protected
array
|
$received |
#
Array of requests that were mocked |
protected
boolean
|
$readBodies |
#
Whether or not to consume an entity body when a mock response is served |