Author: Nate Brunette (n@tebru.net)
Inheritance: extends Symfony\Component\EventDispatcher\Event
Exemplo n.º 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());
 }
Exemplo n.º 2
0
 /**
  * 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);
 }
 public function testGetters()
 {
     $event = new AfterSendEvent(new Response('body'));
     $this->assertInstanceOf(Response::class, $event->getResponse());
 }