Update tests
This commit is contained in:
parent
bff1dfd169
commit
2c72fdc716
|
@ -5,11 +5,11 @@ namespace Pterodactyl\Tests\Integration\Api\Client\Server;
|
|||
use Mockery;
|
||||
use GuzzleHttp\Psr7\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Mockery\MockInterface;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Models\Permission;
|
||||
use GuzzleHttp\Exception\BadResponseException;
|
||||
use GuzzleHttp\Psr7\Response as GuzzleResponse;
|
||||
use Pterodactyl\Repositories\Wings\DaemonCommandRepository;
|
||||
use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
|
||||
use Pterodactyl\Tests\Integration\Api\Client\ClientApiIntegrationTestCase;
|
||||
|
||||
|
@ -53,12 +53,12 @@ class CommandControllerTest extends ClientApiIntegrationTestCase
|
|||
{
|
||||
[$user, $server] = $this->generateTestAccount([Permission::ACTION_CONTROL_CONSOLE]);
|
||||
|
||||
$mock = $this->mock(DaemonCommandRepository::class);
|
||||
$mock->expects('setServer')
|
||||
->with(Mockery::on(fn (Server $value) => $value->is($server)))
|
||||
->andReturnSelf();
|
||||
$server = \Mockery::mock($server)->makePartial();
|
||||
$server->expects('query->where->firstOrFail')->andReturns($server);
|
||||
|
||||
$mock->expects('send')->with('say Test')->andReturn(new GuzzleResponse());
|
||||
$this->instance(Server::class, $server);
|
||||
|
||||
$server->expects('send')->with('say Test')->andReturn(new GuzzleResponse());
|
||||
|
||||
$response = $this->actingAs($user)->postJson("/api/client/servers/$server->uuid/command", [
|
||||
'command' => 'say Test',
|
||||
|
@ -75,13 +75,16 @@ class CommandControllerTest extends ClientApiIntegrationTestCase
|
|||
{
|
||||
[$user, $server] = $this->generateTestAccount();
|
||||
|
||||
$mock = $this->mock(DaemonCommandRepository::class);
|
||||
$mock->expects('setServer->send')->andThrows(
|
||||
$server = \Mockery::mock($server)->makePartial();
|
||||
$server->expects('query->where->firstOrFail')->andReturns($server);
|
||||
$server->expects('send')->andThrows(
|
||||
new DaemonConnectionException(
|
||||
new BadResponseException('', new Request('GET', 'test'), new GuzzleResponse(Response::HTTP_BAD_GATEWAY))
|
||||
)
|
||||
);
|
||||
|
||||
$this->instance(Server::class, $server);
|
||||
|
||||
$response = $this->actingAs($user)->postJson("/api/client/servers/$server->uuid/command", [
|
||||
'command' => 'say Test',
|
||||
]);
|
||||
|
|
Loading…
Reference in New Issue