public function testHandleException()
 {
     $mock = new ErrorHandlerMock();
     $registry = new ErrorHandlerRegistry();
     $exception = new \Exception('Test', 1);
     $registry->addErrorHandler($mock);
     $registry->handleException($exception);
     $this->assertSame(1, count($mock->handledExceptions), 'The handled exception count does not match');
     $this->assertSame($exception, $mock->handledExceptions[0]['exception'], 'The handled exception is not the same');
     $registry->handleException($exception);
     $this->assertSame($mock->handledExceptions[0]['errorId'], $mock->handledExceptions[1]['errorId'], 'The errorIDs do not match for the same exception');
     $exception = new \Exception('Test', 1);
     $registry->handleException($exception);
     $this->assertFalse($mock->handledExceptions[0]['errorId'] == $mock->handledExceptions[2]['errorId'], 'The errorIDs match for different exceptions');
 }
Пример #2
0
 /**
  * Handles a fatal exception.
  *
  * @param \Exception $exception   The exception to handle.
  *
  * @return void
  *
  * @throws \Exception   Re-throws the received exception for the exception handler to handle.
  */
 protected function handleFatalException(\Exception $exception)
 {
     if ($this->request instanceof \YapepBase\Request\HttpRequest) {
         $this->errorHandlerRegistry->handleException($exception);
         // We have an HTTP request, try to run
         try {
             $this->runErrorAction(500);
         } catch (\Exception $exception) {
             $this->outputError();
         }
     } else {
         // Not an HTTP request, just use default error output
         $this->outputError();
     }
 }