コード例 #1
0
ファイル: RunnerTest.php プロジェクト: Mosaic/Mosaic
 public function test_can_handle_a_fatal_php_error_in_shutdown()
 {
     $e = new ErrorException('Some message');
     $handler = \Mockery::mock(LogHandler::class);
     $formatter = \Mockery::mock(JsonFormatter::class);
     $this->runner->addHandler(LogHandler::class);
     $this->runner->setFormatter(JsonFormatter::class);
     $handler->shouldReceive('handle')->once()->with(\Mockery::on(function ($e) {
         return $e instanceof ErrorException && $e->getMessage() == self::$error['message'] && $e->getCode() == self::$error['type'] && $e->getSeverity() == 0 && $e->getFile() == self::$error['file'] && $e->getLine() == self::$error['line'];
     }));
     $formatter->shouldReceive('render')->once()->andReturn(ErrorResponse::fromException($e));
     $this->container->shouldReceive('make')->with(LogHandler::class)->once()->andReturn($handler);
     $this->container->shouldReceive('make')->with(JsonFormatter::class)->once()->andReturn($formatter);
     $this->container->shouldReceive('make')->with(ResponseFactory::class)->once()->andReturn($factory = \Mockery::mock(ResponseFactory::class));
     $htmlResponse = new \Mosaic\Http\Adapters\Psr7\Response(new HtmlResponse('Some message'));
     $factory->shouldReceive('make')->once()->andReturn($htmlResponse);
     $this->emitter->shouldReceive('emit')->with($htmlResponse)->once();
     self::$error = ['message' => 'foo', 'type' => 1337, 'file' => __FILE__, 'line' => 7];
     $this->runner->handleShutdown();
 }
コード例 #2
0
ファイル: HtmlFormatter.php プロジェクト: Mosaic/Mosaic
 /**
  * @param Throwable $e
  *
  * @return ErrorResponse
  */
 public function render(Throwable $e) : ErrorResponse
 {
     return ErrorResponse::fromException($e, $this->content($e));
 }
コード例 #3
0
ファイル: WhoopsFormatter.php プロジェクト: Mosaic/Mosaic
 /**
  * @param Throwable $e
  *
  * @return ErrorResponse
  */
 public function render(Throwable $e) : ErrorResponse
 {
     $output = new HtmlString($this->whoops->handleException($e));
     return ErrorResponse::fromException($e, $output);
 }
コード例 #4
0
ファイル: JsonFormatter.php プロジェクト: Mosaic/Mosaic
 /**
  * @param Throwable $e
  *
  * @return ErrorResponse
  */
 public function render(Throwable $e) : ErrorResponse
 {
     $output = new ArrayObject(['error' => ['message' => $e->getMessage()]]);
     return ErrorResponse::fromException($e, $output);
 }
コード例 #5
0
ファイル: ConsoleFormatter.php プロジェクト: Mosaic/Mosaic
 /**
  * @param Throwable $e
  *
  * @return ErrorResponse
  */
 public function render(Throwable $e) : ErrorResponse
 {
     return ErrorResponse::fromException($e);
 }