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(); }
/** * @param Throwable $e * * @return ErrorResponse */ public function render(Throwable $e) : ErrorResponse { return ErrorResponse::fromException($e, $this->content($e)); }
/** * @param Throwable $e * * @return ErrorResponse */ public function render(Throwable $e) : ErrorResponse { $output = new HtmlString($this->whoops->handleException($e)); return ErrorResponse::fromException($e, $output); }
/** * @param Throwable $e * * @return ErrorResponse */ public function render(Throwable $e) : ErrorResponse { $output = new ArrayObject(['error' => ['message' => $e->getMessage()]]); return ErrorResponse::fromException($e, $output); }
/** * @param Throwable $e * * @return ErrorResponse */ public function render(Throwable $e) : ErrorResponse { return ErrorResponse::fromException($e); }