Ejemplo n.º 1
0
 public function testGetResponseForException()
 {
     $em = new EventManager();
     $em->addEventListener(KernelEvents::EXCEPTION, function (ExceptionEvent $event) {
         $event->setResponse(Response::createFromRequest($event->getRequest(), $event->getException()->getMessage()));
     });
     $kernel = new HttpKernel($em, new ClosureControllerFactory());
     $response = $kernel->handle(Request::create('GET', '/home'));
     $this->assertSame('NO CONTROLLER FOUND!', $response->getBody());
 }
Ejemplo n.º 2
0
 public function testStopRequestEvent()
 {
     $request = new Request('GET', '/home', 'HTTP', '1.1');
     $response = Response::createFromRequest($request, '', 200);
     $event = new KernelEvent($request);
     $this->assertSame($request, $event->getRequest());
     $this->assertNull($event->getResponse());
     $this->assertFalse($event->hasResponse());
     $this->assertFalse($event->isStopped());
     $event->setResponse($response);
     $this->assertTrue($event->hasResponse());
     $this->assertSame($response, $event->getResponse());
     $this->assertTrue($event->isStopped());
 }
Ejemplo n.º 3
0
 private function createResponse(RequestInterface $request, $content, $statusCode = ResponseInterface::HTTP_OK)
 {
     return Response::createFromRequest($request, $content, $statusCode);
 }
Ejemplo n.º 4
0
 public function handle(Request $request)
 {
     return Response::createFromRequest($request, 'DUMMY!');
 }