Skip to content
This repository has been archived by the owner on Feb 2, 2018. It is now read-only.

Commit

Permalink
Update Ivory HTTP Adapter to 0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromegamez committed Aug 13, 2015
1 parent 98aef1c commit ee0f71e
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 84 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"symfony/event-dispatcher": "~2.6"
},
"require-dev": {
"egeloen/http-adapter": "~0.7.1",
"egeloen/http-adapter": "^0.8.0",
"phpunit/phpunit": "~4.6",
"fabpot/php-cs-fixer": "~1.6"
},
Expand Down
25 changes: 12 additions & 13 deletions src/Event/Subscriber/TapeRecorderSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@
namespace Kreait\Ivory\HttpAdapter\Event\Subscriber;

use Ivory\HttpAdapter\Event\Events;
use Ivory\HttpAdapter\Event\ExceptionEvent;
use Ivory\HttpAdapter\Event\PostSendEvent;
use Ivory\HttpAdapter\Event\PreSendEvent;
use Ivory\HttpAdapter\Event\RequestCreatedEvent;
use Ivory\HttpAdapter\Event\RequestErroredEvent;
use Ivory\HttpAdapter\Event\RequestSentEvent;
use Ivory\HttpAdapter\HttpAdapterException;
use Kreait\Ivory\HttpAdapter\Event\TapeRecorder\Tape;
use Kreait\Ivory\HttpAdapter\Event\TapeRecorder\TapeRecorderException;
use Kreait\Ivory\HttpAdapter\Event\TapeRecorder\TrackInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
Expand Down Expand Up @@ -85,9 +84,9 @@ public function __construct($path)
public static function getSubscribedEvents()
{
return [
Events::PRE_SEND => ['onPreSend', 400],
Events::POST_SEND => ['onPostSend', 400],
Events::EXCEPTION => ['onException', 400],
Events::REQUEST_CREATED => ['onPreSend', 400],
Events::REQUEST_SENT => ['onPostSend', 400],
Events::REQUEST_ERRORED => ['onException', 400],
];
}

Expand Down Expand Up @@ -165,11 +164,11 @@ public function stopRecording()
/**
* On pre send event.
*
* @param PreSendEvent $event The pre send event.
* @param RequestCreatedEvent $event The pre send event.
*
* @throws TapeRecorderException|HttpAdapterException
*/
public function onPreSend(PreSendEvent $event)
public function onPreSend(RequestCreatedEvent $event)
{
if (!$this->isRecording) {
return;
Expand All @@ -192,9 +191,9 @@ public function onPreSend(PreSendEvent $event)
*
* We reach this event when the request has not been intercepted.
*
* @param PostSendEvent $event The post send event.
* @param RequestSentEvent $event The post send event.
*/
public function onPostSend(PostSendEvent $event)
public function onPostSend(RequestSentEvent $event)
{
if (!$this->isRecording) {
return;
Expand All @@ -218,9 +217,9 @@ public function onPostSend(PostSendEvent $event)
/**
* We arrive here when the request has successfully been intercepted.
*
* @param ExceptionEvent $event The exception event.
* @param RequestErroredEvent $event The exception event.
*/
public function onException(ExceptionEvent $event)
public function onException(RequestErroredEvent $event)
{
if (!$this->isRecording) {
return;
Expand Down
32 changes: 16 additions & 16 deletions src/Event/TapeRecorder/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ public function internalRequestToArray(InternalRequestInterface $request)
$r = $request->withoutParameter('track');

return [
'uri' => (string) $r->getUri(),
'method' => $r->getMethod(),
'uri' => (string) $r->getUri(),
'method' => $r->getMethod(),
'protocol_version' => $r->getProtocolVersion(),
'headers' => $r->getHeaders(),
'datas' => $r->getDatas(),
'files' => $r->getFiles(),
'parameters' => $r->getParameters(),
'headers' => $r->getHeaders(),
'datas' => $r->getDatas(),
'files' => $r->getFiles(),
'parameters' => $r->getParameters(),
];
}

Expand Down Expand Up @@ -125,12 +125,12 @@ public function requestToArray(RequestInterface $request)
$r = $request->withoutParameter('track');

return [
'uri' => (string) $r->getUri(),
'method' => $r->getMethod(),
'uri' => (string) $r->getUri(),
'method' => $r->getMethod(),
'protocol_version' => $r->getProtocolVersion(),
'headers' => $r->getHeaders(),
'body' => (string) $request->getBody(),
'parameters' => $r->getParameters(),
'headers' => $r->getHeaders(),
'body' => (string) $request->getBody(),
'parameters' => $r->getParameters(),
];
}

Expand Down Expand Up @@ -161,11 +161,11 @@ public function arrayToRequest(array $data)
public function responseToArray(ResponseInterface $response)
{
return [
'status_code' => $response->getStatusCode(),
'status_code' => $response->getStatusCode(),
'protocol_version' => $response->getProtocolVersion(),
'headers' => $response->getHeaders(),
'body' => (string) $response->getBody(),
'parameters' => $response->getParameters(),
'headers' => $response->getHeaders(),
'body' => (string) $response->getBody(),
'parameters' => $response->getParameters(),
];
}

Expand Down Expand Up @@ -197,7 +197,7 @@ public function arrayToResponse(array $data)
public function exceptionToArray(HttpAdapterException $exception)
{
$array = [
'code' => $exception->getCode(),
'code' => $exception->getCode(),
'message' => $exception->getMessage(),
];

Expand Down
Loading

0 comments on commit ee0f71e

Please sign in to comment.