20 protected $queue = array();
41 foreach ($items as $item) {
42 if ($item instanceof \Exception) {
54 return array(
'request.before_send' => array(
'onRequestBeforeSend', -999));
59 return array(
'mock.request');
72 if (!file_exists($path)) {
73 throw new InvalidArgumentException(
'Unable to open mock file: ' . $path);
101 return count($this->queue);
114 if (!($response instanceof
Response)) {
115 if (!is_string($response)) {
121 $this->queue[] = $response;
147 $this->queue = array();
182 $this->
dispatch(
'mock.request', array(
'plugin' => $this,
'request' => $request));
184 $item = array_shift($this->queue);
188 while ($data = $event[
'request']->getBody()->read(8096));
190 $event[
'request']->getEventDispatcher()->removeListener(
'request.sent', $f);
194 } elseif ($item instanceof CurlException) {
196 $item->setRequest($request);
210 public function flush()
212 $this->received = array();
234 throw new \OutOfBoundsException(
'Mock queue is empty');
237 $request = $event[
'request'];
238 $this->received[] = $request;
240 if ($this->temporary &&
count($this->queue) == 1 && $request->
getClient()) {
241 $request->
getClient()->getEventDispatcher()->removeSubscriber($this);