exception = m::mock(RequestException::class)->makePartial(); $this->repository = m::mock(ServerRepositoryInterface::class); $this->server = factory(Server::class)->make(['node_id' => 1]); $this->service = new ContainerRebuildService($this->repository); } /** * Test that a server is marked for rebuild. */ public function testServerIsMarkedForRebuild() { $this->repository->shouldReceive('setServer')->with($this->server)->once()->andReturnSelf() ->shouldReceive('rebuild')->withNoArgs()->once()->andReturn(new Response); $this->service->handle($this->server); } /** * Test that an exception thrown by guzzle is rendered as a displayable exception. * * @expectedException \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ public function testExceptionThrownByGuzzle() { $this->repository->shouldReceive('setServer')->with($this->server)->once()->andThrow($this->exception); $this->service->handle($this->server); } }