Refactor how repositories for the daemon work.
This commit is contained in:
parent
5f9fe4a69b
commit
d2afc29a80
58 changed files with 388 additions and 997 deletions
|
@ -13,6 +13,7 @@ use Exception;
|
|||
use Mockery as m;
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Log\Writer;
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
use Pterodactyl\Models\Server;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use Illuminate\Database\ConnectionInterface;
|
||||
|
@ -104,9 +105,8 @@ class SuspensionServiceTest extends TestCase
|
|||
$this->repository->shouldReceive('withoutFreshModel')->withNoArgs()->once()->andReturnSelf()
|
||||
->shouldReceive('update')->with($this->server->id, ['suspended' => true])->once()->andReturnNull();
|
||||
|
||||
$this->daemonServerRepository->shouldReceive('setNode')->with($this->server->node_id)->once()->andReturnSelf()
|
||||
->shouldReceive('setAccessServer')->with($this->server->uuid)->once()->andReturnSelf()
|
||||
->shouldReceive('suspend')->withNoArgs()->once()->andReturnNull();
|
||||
$this->daemonServerRepository->shouldReceive('setServer')->with($this->server)->once()->andReturnSelf()
|
||||
->shouldReceive('suspend')->withNoArgs()->once()->andReturn(new Response);
|
||||
$this->database->shouldReceive('commit')->withNoArgs()->once()->andReturnNull();
|
||||
|
||||
$this->assertTrue($this->service->toggle($this->server));
|
||||
|
@ -123,9 +123,8 @@ class SuspensionServiceTest extends TestCase
|
|||
$this->repository->shouldReceive('withoutFreshModel')->withNoArgs()->once()->andReturnSelf()
|
||||
->shouldReceive('update')->with($this->server->id, ['suspended' => false])->once()->andReturnNull();
|
||||
|
||||
$this->daemonServerRepository->shouldReceive('setNode')->with($this->server->node_id)->once()->andReturnSelf()
|
||||
->shouldReceive('setAccessServer')->with($this->server->uuid)->once()->andReturnSelf()
|
||||
->shouldReceive('unsuspend')->withNoArgs()->once()->andReturnNull();
|
||||
$this->daemonServerRepository->shouldReceive('setServer')->with($this->server)->once()->andReturnSelf()
|
||||
->shouldReceive('unsuspend')->withNoArgs()->once()->andReturn(new Response);
|
||||
$this->database->shouldReceive('commit')->withNoArgs()->once()->andReturnNull();
|
||||
|
||||
$this->assertTrue($this->service->toggle($this->server, 'unsuspend'));
|
||||
|
@ -162,7 +161,7 @@ class SuspensionServiceTest extends TestCase
|
|||
$this->repository->shouldReceive('withoutFreshModel')->withNoArgs()->once()->andReturnSelf()
|
||||
->shouldReceive('update')->with($this->server->id, ['suspended' => true])->once()->andReturnNull();
|
||||
|
||||
$this->daemonServerRepository->shouldReceive('setNode')->with($this->server->node_id)
|
||||
$this->daemonServerRepository->shouldReceive('setServer')->with($this->server)
|
||||
->once()->andThrow($this->exception);
|
||||
|
||||
$this->exception->shouldReceive('getResponse')->withNoArgs()->once()->andReturnSelf()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue