Open Journal Systems
3.3.0
|
Public Member Functions | |
__construct (array $items=null, $temporary=false, $readBodies=false) | |
addException (CurlException $e) | |
addResponse ($response) | |
clearQueue () | |
count () | |
dequeue (RequestInterface $request) | |
flush () | |
getQueue () | |
getReceivedRequests () | |
isTemporary () | |
onRequestBeforeSend (Event $event) | |
readBodies ($readBodies) | |
![]() | |
addSubscriber (EventSubscriberInterface $subscriber) | |
dispatch ($eventName, array $context=array()) | |
getEventDispatcher () | |
setEventDispatcher (EventDispatcherInterface $eventDispatcher) | |
Static Public Member Functions | |
static | getAllEvents () |
static | getMockFile ($path) |
static | getSubscribedEvents () |
Protected Attributes | |
$queue = array() | |
$readBodies | |
$received = array() | |
$temporary = false | |
![]() | |
$eventDispatcher | |
Queues mock responses or exceptions and delivers mock responses or exceptions in a fifo order.
Definition at line 17 of file MockPlugin.php.
Guzzle\Plugin\Mock\MockPlugin::__construct | ( | array | $items = null , |
$temporary = false , |
|||
$readBodies = false |
|||
) |
array | $items | Array of responses or exceptions to queue |
bool | $temporary | Set to TRUE to remove the plugin when the queue is empty |
bool | $readBodies | Set to TRUE to consume the entity body when a mock is served |
Definition at line 48 of file MockPlugin.php.
References Guzzle\Plugin\Mock\MockPlugin\$readBodies, Guzzle\Plugin\Mock\MockPlugin\$temporary, Guzzle\Plugin\Mock\MockPlugin\addException(), Guzzle\Plugin\Mock\MockPlugin\addResponse(), and Guzzle\Plugin\Mock\MockPlugin\readBodies().
Guzzle\Plugin\Mock\MockPlugin::addException | ( | CurlException | $e | ) |
Add an exception to the end of the queue
CurlException | $e | Exception to throw when the request is executed |
Definition at line 145 of file MockPlugin.php.
Referenced by Guzzle\Plugin\Mock\MockPlugin\__construct().
Guzzle\Plugin\Mock\MockPlugin::addResponse | ( | $response | ) |
Add a response to the end of the queue
string | Response | $response | Response object or path to response file |
InvalidArgumentException | if a string or Response is not passed |
Definition at line 124 of file MockPlugin.php.
References Guzzle\Plugin\Mock\MockPlugin\getMockFile().
Referenced by Guzzle\Plugin\Mock\MockPlugin\__construct().
Guzzle\Plugin\Mock\MockPlugin::clearQueue | ( | ) |
Guzzle\Plugin\Mock\MockPlugin::count | ( | ) |
Returns the number of remaining mock responses
Definition at line 111 of file MockPlugin.php.
Referenced by Guzzle\Plugin\Mock\MockPlugin\onRequestBeforeSend().
Guzzle\Plugin\Mock\MockPlugin::dequeue | ( | RequestInterface | $request | ) |
Get a response from the front of the list and add it to a request
RequestInterface | $request | Request to mock |
CurlException | When request.send is called and an exception is queued |
Definition at line 192 of file MockPlugin.php.
References Guzzle\Common\AbstractHasDispatcher\dispatch(), Guzzle\Common\HasDispatcherInterface\getEventDispatcher(), Guzzle\Plugin\Mock\MockPlugin\readBodies(), Guzzle\Http\Message\RequestInterface\setResponse(), Guzzle\Http\Message\RequestInterface\setState(), and Guzzle\Http\Message\RequestInterface\STATE_ERROR.
Referenced by Guzzle\Plugin\Mock\MockPlugin\onRequestBeforeSend().
Guzzle\Plugin\Mock\MockPlugin::flush | ( | ) |
Clear the array of received requests
Definition at line 222 of file MockPlugin.php.
|
static |
Get a list of all of the events emitted from the class
Reimplemented from Guzzle\Common\AbstractHasDispatcher.
Definition at line 69 of file MockPlugin.php.
Referenced by Guzzle\Tests\Plugin\Mock\MockPluginTest\testDescribesEvents().
|
static |
Get a mock response from a file
string | $path | File to retrieve a mock response from |
InvalidArgumentException | if the file is not found |
Definition at line 82 of file MockPlugin.php.
References Guzzle\Http\Message\Response\fromMessage().
Referenced by Guzzle\Plugin\Mock\MockPlugin\addResponse(), Guzzle\Tests\GuzzleTestCase\getMockResponse(), Guzzle\Tests\Plugin\Mock\MockPluginTest\testAddsMockResponseToRequestFromClient(), Guzzle\Tests\Plugin\Mock\MockPluginTest\testDetachesTemporaryWhenEmpty(), Guzzle\Tests\Plugin\Mock\MockPluginTest\testRetrievesResponsesFromFiles(), and Guzzle\Tests\Plugin\Mock\MockPluginTest\testThrowsExceptionWhenResponseFileIsNotFound().
Guzzle\Plugin\Mock\MockPlugin::getQueue | ( | ) |
Returns an array of mock responses remaining in the queue
Definition at line 169 of file MockPlugin.php.
References Guzzle\Plugin\Mock\MockPlugin\$queue.
Guzzle\Plugin\Mock\MockPlugin::getReceivedRequests | ( | ) |
Get an array of requests that were mocked by this plugin
Definition at line 232 of file MockPlugin.php.
References Guzzle\Plugin\Mock\MockPlugin\$received.
|
static |
Returns an array of event names this subscriber wants to listen to.
The array keys are event names and the value can be:
For instance:
Implements Symfony\Component\EventDispatcher\EventSubscriberInterface.
Definition at line 63 of file MockPlugin.php.
Referenced by Guzzle\Tests\Plugin\Mock\MockPluginTest\testDescribesSubscribedEvents().
Guzzle\Plugin\Mock\MockPlugin::isTemporary | ( | ) |
Check if this is a temporary plugin
Definition at line 179 of file MockPlugin.php.
References Guzzle\Plugin\Mock\MockPlugin\$temporary.
Guzzle\Plugin\Mock\MockPlugin::onRequestBeforeSend | ( | Event | $event | ) |
Called when a request is about to be sent
Event | $event |
Definition at line 243 of file MockPlugin.php.
References Guzzle\Plugin\Mock\MockPlugin\count(), and Guzzle\Plugin\Mock\MockPlugin\dequeue().
Guzzle\Plugin\Mock\MockPlugin::readBodies | ( | $readBodies | ) |
Set whether or not to consume the entity body of a request when a mock response is used
bool | $readBodies | Set to true to read and consume entity bodies |
Definition at line 99 of file MockPlugin.php.
References Guzzle\Plugin\Mock\MockPlugin\$readBodies.
Referenced by Guzzle\Plugin\Mock\MockPlugin\__construct(), and Guzzle\Plugin\Mock\MockPlugin\dequeue().
|
protected |
Array of mock responses / exceptions
Definition at line 23 of file MockPlugin.php.
Referenced by Guzzle\Plugin\Mock\MockPlugin\getQueue().
|
protected |
Whether or not to consume an entity body when a mock response is served
Definition at line 41 of file MockPlugin.php.
Referenced by Guzzle\Plugin\Mock\MockPlugin\__construct(), and Guzzle\Plugin\Mock\MockPlugin\readBodies().
|
protected |
Array of requests that were mocked
Definition at line 35 of file MockPlugin.php.
Referenced by Guzzle\Plugin\Mock\MockPlugin\getReceivedRequests().
|
protected |
Whether or not to remove the plugin when the queue is empty
Definition at line 29 of file MockPlugin.php.
Referenced by Guzzle\Plugin\Mock\MockPlugin\__construct(), and Guzzle\Plugin\Mock\MockPlugin\isTemporary().