mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-18 06:13:45 +02:00
Refactor how repositories for the daemon work.
This commit is contained in:
@@ -12,6 +12,7 @@ namespace Tests\Unit\Services\DaemonKeys;
|
||||
use Mockery as m;
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Log\Writer;
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Models\DaemonKey;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
@@ -98,8 +99,8 @@ class DaemonKeyDeletionServiceTest extends TestCase
|
||||
])->once()->andReturn($key);
|
||||
|
||||
$this->repository->shouldReceive('delete')->with($key->id)->once()->andReturn(1);
|
||||
$this->daemonRepository->shouldReceive('setNode')->with($server->node_id)->once()->andReturnSelf()
|
||||
->shouldReceive('revokeAccessKey')->with($key->secret)->once()->andReturnNull();
|
||||
$this->daemonRepository->shouldReceive('setServer')->with($server)->once()->andReturnSelf()
|
||||
->shouldReceive('revokeAccessKey')->with($key->secret)->once()->andReturn(new Response);
|
||||
$this->connection->shouldReceive('commit')->withNoArgs()->once()->andReturnNull();
|
||||
|
||||
$this->service->handle($server, 100);
|
||||
@@ -122,8 +123,8 @@ class DaemonKeyDeletionServiceTest extends TestCase
|
||||
])->once()->andReturn($key);
|
||||
|
||||
$this->repository->shouldReceive('delete')->with($key->id)->once()->andReturn(1);
|
||||
$this->daemonRepository->shouldReceive('setNode')->with($server->node_id)->once()->andReturnSelf()
|
||||
->shouldReceive('revokeAccessKey')->with($key->secret)->once()->andReturnNull();
|
||||
$this->daemonRepository->shouldReceive('setServer')->with($server)->once()->andReturnSelf()
|
||||
->shouldReceive('revokeAccessKey')->with($key->secret)->once()->andReturn(new Response);
|
||||
$this->connection->shouldReceive('commit')->withNoArgs()->once()->andReturnNull();
|
||||
|
||||
$this->service->handle($server->id, 100);
|
||||
@@ -145,7 +146,7 @@ class DaemonKeyDeletionServiceTest extends TestCase
|
||||
])->once()->andReturn($key);
|
||||
|
||||
$this->repository->shouldReceive('delete')->with($key->id)->once()->andReturn(1);
|
||||
$this->daemonRepository->shouldReceive('setNode')->with($server->node_id)->once()->andThrow($this->exception);
|
||||
$this->daemonRepository->shouldReceive('setServer')->with($server)->once()->andThrow($this->exception);
|
||||
$this->exception->shouldReceive('getResponse')->withNoArgs()->once()->andReturnNull();
|
||||
$this->connection->shouldReceive('rollBack')->withNoArgs()->once()->andReturnNull();
|
||||
$this->writer->shouldReceive('warning')->with($this->exception)->once()->andReturnNull();
|
||||
|
||||
Reference in New Issue
Block a user