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