Upgrade to Laravel 9 (#4413)

Co-authored-by: DaneEveritt <dane@daneeveritt.com>
This commit is contained in:
Matthew Penner 2022-10-14 10:59:20 -06:00 committed by GitHub
parent 95e15d2c8a
commit cbcf62086f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
573 changed files with 4387 additions and 9411 deletions

View file

@ -5,6 +5,7 @@ namespace Pterodactyl\Tests\Integration\Api\Client\Server;
use Mockery;
use GuzzleHttp\Psr7\Request;
use Illuminate\Http\Response;
use Pterodactyl\Models\Server;
use Pterodactyl\Models\Permission;
use GuzzleHttp\Exception\BadResponseException;
use GuzzleHttp\Psr7\Response as GuzzleResponse;
@ -14,20 +15,6 @@ use Pterodactyl\Tests\Integration\Api\Client\ClientApiIntegrationTestCase;
class CommandControllerTest extends ClientApiIntegrationTestCase
{
/** @var \Mockery\MockInterface */
private $repository;
/**
* Setup tests.
*/
public function setUp(): void
{
parent::setUp();
$this->repository = Mockery::mock(DaemonCommandRepository::class);
$this->app->instance(DaemonCommandRepository::class, $this->repository);
}
/**
* Test that a validation error is returned if there is no command present in the
* request.
@ -36,7 +23,7 @@ class CommandControllerTest extends ClientApiIntegrationTestCase
{
[$user, $server] = $this->generateTestAccount();
$response = $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/command", [
$response = $this->actingAs($user)->postJson("/api/client/servers/$server->uuid/command", [
'command' => '',
]);
@ -52,7 +39,7 @@ class CommandControllerTest extends ClientApiIntegrationTestCase
{
[$user, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]);
$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',
]);
@ -66,12 +53,14 @@ class CommandControllerTest extends ClientApiIntegrationTestCase
{
[$user, $server] = $this->generateTestAccount([Permission::ACTION_CONTROL_CONSOLE]);
$this->repository->expects('setServer')->with(Mockery::on(function ($value) use ($server) {
return $value->uuid === $server->uuid;
}))->andReturnSelf();
$this->repository->expects('send')->with('say Test')->andReturn(new GuzzleResponse());
$mock = $this->mock(DaemonCommandRepository::class);
$mock->expects('setServer')
->with(Mockery::on(fn (Server $value) => $value->is($server)))
->andReturnSelf();
$response = $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/command", [
$mock->expects('send')->with('say Test')->andReturn(new GuzzleResponse());
$response = $this->actingAs($user)->postJson("/api/client/servers/$server->uuid/command", [
'command' => 'say Test',
]);
@ -86,13 +75,14 @@ class CommandControllerTest extends ClientApiIntegrationTestCase
{
[$user, $server] = $this->generateTestAccount();
$this->repository->expects('setServer->send')->andThrows(
$mock = $this->mock(DaemonCommandRepository::class);
$mock->expects('setServer->send')->andThrows(
new DaemonConnectionException(
new BadResponseException('', new Request('GET', 'test'), new GuzzleResponse(Response::HTTP_BAD_GATEWAY))
)
);
$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',
]);