Exemplo n.º 1
0
 private function setUpDependencies(bool $fail = false)
 {
     $dispatcher = \Mockery::mock(DispatchRequest::class);
     $dispatcher->shouldReceive('__invoke')->once()->andReturn($response = new Response(new ZendResponse()));
     $container = \Mockery::mock(Container::class);
     $container->shouldReceive('make')->with(Request::class)->andReturn(\Mockery::mock(Request::class));
     $container->shouldReceive('make')->with(DispatchRequest::class)->once()->andReturn($dispatcher);
     $this->app->shouldReceive('getContainer')->andReturn($container);
     $this->app->shouldReceive('setExceptionRunner')->once()->with(\Mockery::type(ExceptionRunner::class));
     $this->app->shouldReceive('setContext')->once()->with('web');
     $this->app->shouldReceive('bootstrap')->once();
     if ($fail) {
         $this->emitter->shouldReceive('emit')->andThrow(\InvalidArgumentException::class);
     } else {
         $this->emitter->shouldReceive('emit')->with($response, 1)->once();
     }
 }
Exemplo n.º 2
0
 /**
  * @param Throwable $e
  */
 public function handleException(Throwable $e)
 {
     if (!in_array(get_class($e), $this->shouldNotHandle)) {
         foreach ($this->handlers as $handler) {
             $this->handle($e, $handler);
         }
     }
     $error = $this->render($e);
     $response = $this->factory()->make($error->getOutput(), $error->getStatus());
     $this->emitter->emit($response);
 }