Author: Nate Brunette (n@tebru.net)
Inheritance: extends Symfony\Component\EventDispatcher\Event
コード例 #1
0
 public function testSetters()
 {
     $response = new Response(200, [], 'body');
     $event = new AfterSendEvent(new Request('GET', 'http://mockservice.com/get'), $response);
     $response = $response->withStatus(500);
     $event->setResponse($response);
     $this->assertSame(500, $event->getResponse()->getStatusCode());
 }
コード例 #2
0
ファイル: LogSubscriber.php プロジェクト: tebru/retrofit-php
 /**
  * Log the request and response if it exists
  *
  * @param AfterSendEvent $event
  */
 public function onAfterSend(AfterSendEvent $event)
 {
     $request = $event->getRequest();
     $response = $event->getResponse();
     $log['request'] = ['method' => $request->getMethod(), 'uri' => rawurldecode((string) $request->getUri()), 'headers' => $request->getHeaders(), 'body' => (string) $request->getBody()];
     if (null !== $response) {
         $log['response'] = ['statusCode' => $response->getStatusCode(), 'reasonPhrase' => $response->getReasonPhrase(), 'body' => (string) $response->getBody(), 'headers' => $response->getHeaders()];
     }
     $this->logger->debug('Sent Request', $log);
 }
コード例 #3
0
 public function testGetters()
 {
     $event = new AfterSendEvent(new Response('body'));
     $this->assertInstanceOf(Response::class, $event->getResponse());
 }