/**
  * @covers ::handleRequest
  */
 public function testCatchingExceptionsDuringHandlingOfRequests()
 {
     $exceptionDidOccurCalled = false;
     $handledResponse = new Response('Handled exception');
     $this->application->getContainer()->get('event_manager')->subscribe(ExceptionDidOccur::getName(), function ($ev) use(&$exceptionDidOccurCalled, $handledResponse) {
         $exceptionDidOccurCalled = true;
         $ev->setResponse($handledResponse);
     });
     $response = $this->application->handleRequest(Request::create('/some/undefined/route'));
     $this->assertTrue($exceptionDidOccurCalled);
     $this->assertSame($handledResponse, $response);
 }
Ejemplo n.º 2
0
 /**
  * @covers \Splot\Framework\Events\ExceptionDidOccur::__construct
  * @covers \Splot\Framework\Events\ExceptionDidOccur::getException
  * @covers \Splot\Framework\Events\ExceptionDidOccur::isHandled
  * @covers \Splot\Framework\Events\ExceptionDidOccur::getResponse
  * @covers \Splot\Framework\Events\ExceptionDidOccur::getHandled
  * @covers \Splot\Framework\Events\ExceptionDidOccur::setResponse
  */
 public function testExceptionDidOccur()
 {
     $exception = new \Exception('Some exception', 500);
     $event = new Events\ExceptionDidOccur($exception);
     $this->assertSame($exception, $event->getException());
     $this->assertFalse($event->isHandled());
     $response = new Response('some response');
     $event->setResponse($response);
     $this->assertSame($response, $event->getResponse());
     $this->assertTrue($event->isHandled());
     $this->assertTrue($event->getHandled());
 }