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(); } }