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

@ -31,10 +31,8 @@ trait AssertsActivityLogged
/**
* Asserts that a given activity log event was stored with the subjects being
* any of the values provided.
*
* @param \Illuminate\Database\Eloquent\Model|array $subjects
*/
public function assertActivitySubjects(string $event, $subjects): void
public function assertActivitySubjects(string $event, Model|array $subjects): void
{
if (is_array($subjects)) {
\Webmozart\Assert\Assert::lessThanEq(count(func_get_args()), 2, 'Invalid call to ' . __METHOD__ . ': cannot provide additional arguments if providing an array.');

View file

@ -9,7 +9,7 @@ trait MiddlewareAttributeAssertionsTrait
/**
* Assert a request has an attribute assigned to it.
*/
public function assertRequestHasAttribute(string $attribute)
public function assertRequestHasAttribute(string $attribute): void
{
Assert::assertTrue($this->request->attributes->has($attribute), 'Assert that request mock has ' . $attribute . ' attribute.');
}
@ -17,17 +17,15 @@ trait MiddlewareAttributeAssertionsTrait
/**
* Assert a request does not have an attribute assigned to it.
*/
public function assertRequestMissingAttribute(string $attribute)
public function assertRequestMissingAttribute(string $attribute): void
{
Assert::assertFalse($this->request->attributes->has($attribute), 'Assert that request mock does not have ' . $attribute . ' attribute.');
}
/**
* Assert a request attribute matches an expected value.
*
* @param mixed $expected
*/
public function assertRequestAttributeEquals($expected, string $attribute)
public function assertRequestAttributeEquals(mixed $expected, string $attribute): void
{
Assert::assertEquals($expected, $this->request->attributes->get($attribute));
}

View file

@ -2,16 +2,15 @@
namespace Pterodactyl\Tests;
use Illuminate\Foundation\Application;
use Illuminate\Contracts\Console\Kernel;
trait CreatesApplication
{
/**
* Creates the application.
*
* @return \Illuminate\Foundation\Application
*/
public function createApplication()
public function createApplication(): Application
{
$app = require __DIR__ . '/../bootstrap/app.php';

View file

@ -20,15 +20,9 @@ abstract class ApplicationApiIntegrationTestCase extends IntegrationTestCase
use DatabaseTransactions;
use IntegrationJsonRequestAssertions;
/**
* @var \Pterodactyl\Models\ApiKey
*/
private $key;
private ApiKey $key;
/**
* @var \Pterodactyl\Models\User
*/
private $user;
private User $user;
/**
* Bootstrap application API tests. Creates a default admin user and associated API key

View file

@ -161,7 +161,7 @@ class LocationControllerTest extends ApplicationApiIntegrationTestCase
}
/**
* Test that all of the defined relationships for a location can be loaded successfully.
* Test that all the defined relationships for a location can be loaded successfully.
*/
public function testRelationshipsCanBeLoaded()
{

View file

@ -49,7 +49,7 @@ class EggControllerTest extends ApplicationApiIntegrationTestCase
$this->assertSame(
$expected,
$actual,
'Unable to find JSON fragment: ' . PHP_EOL . PHP_EOL . "[{$expected}]" . PHP_EOL . PHP_EOL . 'within' . PHP_EOL . PHP_EOL . "[{$actual}]."
'Unable to find JSON fragment: ' . PHP_EOL . PHP_EOL . "[$expected]" . PHP_EOL . PHP_EOL . 'within' . PHP_EOL . PHP_EOL . "[$actual]."
);
}
}
@ -77,7 +77,7 @@ class EggControllerTest extends ApplicationApiIntegrationTestCase
}
/**
* Test that a single egg and all of the defined relationships can be returned.
* Test that a single egg and all the defined relationships can be returned.
*/
public function testReturnSingleEggWithRelationships()
{

View file

@ -9,10 +9,7 @@ use Pterodactyl\Tests\Integration\Api\Application\ApplicationApiIntegrationTestC
class NestControllerTest extends ApplicationApiIntegrationTestCase
{
/**
* @var \Pterodactyl\Contracts\Repository\NestRepositoryInterface
*/
private $repository;
private NestRepositoryInterface $repository;
/**
* Setup tests.
@ -25,7 +22,7 @@ class NestControllerTest extends ApplicationApiIntegrationTestCase
}
/**
* Test that the expected nests are returned in the request.
* Test that the expected nests are returned by the request.
*/
public function testNestResponse()
{

View file

@ -55,7 +55,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
'first_name' => $this->getApiUser()->name_first,
'last_name' => $this->getApiUser()->name_last,
'language' => $this->getApiUser()->language,
'root_admin' => (bool) $this->getApiUser()->root_admin,
'root_admin' => $this->getApiUser()->root_admin,
'2fa' => (bool) $this->getApiUser()->totp_enabled,
'created_at' => $this->formatTimestamp($this->getApiUser()->created_at),
'updated_at' => $this->formatTimestamp($this->getApiUser()->updated_at),

View file

@ -52,7 +52,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase
}
/**
* Tests that an email is not updated if the password provided in the reuqest is not
* Tests that an email is not updated if the password provided in the request is not
* valid for the account.
*/
public function testEmailIsNotUpdatedWhenPasswordIsInvalid()

View file

@ -52,7 +52,7 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase
/** @var \Pterodactyl\Models\User $user */
$user = User::factory()->create();
// Small sub-test to ensure we're always comparing the number of keys to the
// Small subtest to ensure we're always comparing the number of keys to the
// specific logged in account, and not just the total number of keys stored in
// the database.
ApiKey::factory()->times(10)->create([
@ -218,7 +218,7 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase
}
/**
* Tests that an application API key also belonging to the logged in user cannot be
* Tests that an application API key also belonging to the logged-in user cannot be
* deleted through this endpoint if it exists.
*/
public function testApplicationApiKeyCannotBeDeleted()

View file

@ -7,6 +7,7 @@ use Pterodactyl\Models\Node;
use Pterodactyl\Models\Task;
use Pterodactyl\Models\User;
use InvalidArgumentException;
use Pterodactyl\Models\Model;
use Pterodactyl\Models\Backup;
use Pterodactyl\Models\Server;
use Pterodactyl\Models\Database;
@ -17,6 +18,7 @@ use Pterodactyl\Models\Allocation;
use Pterodactyl\Models\DatabaseHost;
use Pterodactyl\Tests\Integration\TestResponse;
use Pterodactyl\Tests\Integration\IntegrationTestCase;
use Illuminate\Database\Eloquent\Model as EloquentModel;
use Pterodactyl\Transformers\Api\Client\BaseClientTransformer;
abstract class ClientApiIntegrationTestCase extends IntegrationTestCase
@ -53,27 +55,24 @@ abstract class ClientApiIntegrationTestCase extends IntegrationTestCase
/**
* Returns a link to the specific resource using the client API.
*
* @param mixed $model
* @param string|null $append
*/
protected function link($model, $append = null): string
protected function link(mixed $model, string $append = null): string
{
switch (get_class($model)) {
case Server::class:
$link = "/api/client/servers/{$model->uuid}";
$link = "/api/client/servers/$model->uuid";
break;
case Schedule::class:
$link = "/api/client/servers/{$model->server->uuid}/schedules/{$model->id}";
$link = "/api/client/servers/{$model->server->uuid}/schedules/$model->id";
break;
case Task::class:
$link = "/api/client/servers/{$model->schedule->server->uuid}/schedules/{$model->schedule->id}/tasks/{$model->id}";
$link = "/api/client/servers/{$model->schedule->server->uuid}/schedules/{$model->schedule->id}/tasks/$model->id";
break;
case Allocation::class:
$link = "/api/client/servers/{$model->server->uuid}/network/allocations/{$model->id}";
$link = "/api/client/servers/{$model->server->uuid}/network/allocations/$model->id";
break;
case Backup::class:
$link = "/api/client/servers/{$model->server->uuid}/backups/{$model->uuid}";
$link = "/api/client/servers/{$model->server->uuid}/backups/$model->uuid";
break;
default:
throw new InvalidArgumentException(sprintf('Cannot create link for Model of type %s', class_basename($model)));
@ -85,10 +84,8 @@ abstract class ClientApiIntegrationTestCase extends IntegrationTestCase
/**
* Asserts that the data passed through matches the output of the data from the transformer. This
* will remove the "relationships" key when performing the comparison.
*
* @param \Pterodactyl\Models\Model|\Illuminate\Database\Eloquent\Model $model
*/
protected function assertJsonTransformedWith(array $data, $model)
protected function assertJsonTransformedWith(array $data, Model|EloquentModel $model)
{
$reflect = new ReflectionClass($model);
$transformer = sprintf('\\Pterodactyl\\Transformers\\Api\\Client\\%sTransformer', $reflect->getShortName());

View file

@ -11,7 +11,7 @@ use Pterodactyl\Models\Permission;
class ClientControllerTest extends ClientApiIntegrationTestCase
{
/**
* Test that only the servers a logged in user is assigned to are returned by the
* Test that only the servers a logged-in user is assigned to are returned by the
* API endpoint. Obviously there are cases such as being an administrator or being
* a subuser, but for this test we just want to test a basic scenario and pretend
* subusers do not exist at all.
@ -241,7 +241,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase
]);
// Only servers 2 & 3 (0 indexed) should be returned by the API at this point. The user making
// the request is the owner of server 0, and a subuser of server 1 so they should be exluded.
// the request is the owner of server 0, and a subuser of server 1, so they should be excluded.
$response = $this->actingAs($users[0])->getJson('/api/client?type=admin');
$response->assertOk();
@ -286,10 +286,9 @@ class ClientControllerTest extends ClientApiIntegrationTestCase
* Test that no servers get returned if the user requests all admin level servers by using
* ?type=admin or ?type=admin-all in the request.
*
* @param string $type
* @dataProvider filterTypeDataProvider
*/
public function testNoServersAreReturnedIfAdminFilterIsPassedByRegularUser($type)
public function testNoServersAreReturnedIfAdminFilterIsPassedByRegularUser(string $type)
{
/** @var \Pterodactyl\Models\User[] $users */
$users = User::factory()->times(3)->create();
@ -332,10 +331,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase
$response->assertJsonPath('data.0.attributes.relationships.allocations.data.0.attributes.notes', null);
}
/**
* @return array
*/
public function filterTypeDataProvider()
public function filterTypeDataProvider(): array
{
return [['admin'], ['admin-all']];
}

View file

@ -46,9 +46,6 @@ class AllocationAuthorizationTest extends ClientApiIntegrationTestCase
$this->actingAs($user)->json($method, $this->link($server3, '/network/allocations/' . $allocation3->id . $endpoint))->assertNotFound();
}
/**
* @return \string[][]
*/
public function methodDataProvider(): array
{
return [

View file

@ -72,7 +72,7 @@ class CreateNewAllocationTest extends ClientApiIntegrationTestCase
}
/**
* Test that an allocation cannot be created if the server has reached it's allocation limit.
* Test that an allocation cannot be created if the server has reached its allocation limit.
*/
public function testAllocationCannotBeCreatedIfServerIsAtLimit()
{
@ -86,10 +86,7 @@ class CreateNewAllocationTest extends ClientApiIntegrationTestCase
->assertJsonPath('errors.0.detail', 'Cannot assign additional allocations to this server: limit has been reached.');
}
/**
* @return array
*/
public function permissionDataProvider()
public function permissionDataProvider(): array
{
return [[[Permission::ACTION_ALLOCATION_CREATE]], [[]]];
}

View file

@ -55,9 +55,6 @@ class BackupAuthorizationTest extends ClientApiIntegrationTestCase
$this->actingAs($user)->json($method, $this->link($server3, '/backups/' . $backup3->uuid . $endpoint))->assertNotFound();
}
/**
* @return \string[][]
*/
public function methodDataProvider(): array
{
return [

View file

@ -3,6 +3,7 @@
namespace Pterodactyl\Tests\Integration\Api\Client\Server\Backup;
use Mockery;
use Mockery\MockInterface;
use Illuminate\Http\Response;
use Pterodactyl\Models\Backup;
use Pterodactyl\Models\Permission;
@ -13,7 +14,7 @@ use Pterodactyl\Tests\Integration\Api\Client\ClientApiIntegrationTestCase;
class DeleteBackupTest extends ClientApiIntegrationTestCase
{
private $repository;
private MockInterface $repository;
public function setUp(): void
{

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',
]);

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Tests\Integration\Api\Client\Server\Database;
use Mockery;
use Pterodactyl\Models\Subuser;
use Pterodactyl\Models\Database;
use Pterodactyl\Models\DatabaseHost;
@ -35,14 +34,10 @@ class DatabaseAuthorizationTest extends ClientApiIntegrationTestCase
$database2 = Database::factory()->create(['server_id' => $server2->id, 'database_host_id' => $host->id]);
$database3 = Database::factory()->create(['server_id' => $server3->id, 'database_host_id' => $host->id]);
$this->instance(DatabasePasswordService::class, $mock = Mockery::mock(DatabasePasswordService::class));
$this->instance(DatabaseManagementService::class, $mock2 = Mockery::mock(DatabaseManagementService::class));
if ($method === 'POST') {
$mock->expects('handle')->andReturnUndefined();
} else {
$mock2->expects('delete')->andReturnUndefined();
}
$this
->mock($method === 'POST' ? DatabasePasswordService::class : DatabaseManagementService::class)
->expects($method === 'POST' ? 'handle' : 'delete')
->andReturn($method === 'POST' ? 'foo' : null);
$hashids = $this->app->make(HashidsInterface::class);
// This is the only valid call for this test, accessing the database for the same
@ -63,9 +58,6 @@ class DatabaseAuthorizationTest extends ClientApiIntegrationTestCase
$this->actingAs($user)->json($method, $this->link($server3, '/databases/' . $hashids->encode($database3->id) . $endpoint))->assertNotFound();
}
/**
* @return \string[][]
*/
public function methodDataProvider(): array
{
return [

View file

@ -133,7 +133,7 @@ class NetworkAllocationControllerTest extends ClientApiIntegrationTestCase
->assertForbidden();
}
public function updatePermissionsDataProvider()
public function updatePermissionsDataProvider(): array
{
return [[[]], [[Permission::ACTION_ALLOCATION_UPDATE]]];
}

View file

@ -16,6 +16,7 @@ class PowerControllerTest extends ClientApiIntegrationTestCase
* the command to the server.
*
* @param string[] $permissions
*
* @dataProvider invalidPermissionDataProvider
*/
public function testSubuserWithoutPermissionsReceivesError(string $action, array $permissions)
@ -23,7 +24,7 @@ class PowerControllerTest extends ClientApiIntegrationTestCase
[$user, $server] = $this->generateTestAccount($permissions);
$this->actingAs($user)
->postJson("/api/client/servers/{$server->uuid}/power", ['signal' => $action])
->postJson("/api/client/servers/$server->uuid/power", ['signal' => $action])
->assertStatus(Response::HTTP_FORBIDDEN);
}
@ -34,7 +35,7 @@ class PowerControllerTest extends ClientApiIntegrationTestCase
{
[$user, $server] = $this->generateTestAccount();
$response = $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/power", [
$response = $this->actingAs($user)->postJson("/api/client/servers/$server->uuid/power", [
'signal' => 'invalid',
]);
@ -65,7 +66,7 @@ class PowerControllerTest extends ClientApiIntegrationTestCase
->with(trim($action));
$this->actingAs($user)
->postJson("/api/client/servers/{$server->uuid}/power", ['signal' => $action])
->postJson("/api/client/servers/$server->uuid/power", ['signal' => $action])
->assertStatus(Response::HTTP_NO_CONTENT);
}

View file

@ -7,7 +7,7 @@ use Pterodactyl\Models\Permission;
use Pterodactyl\Repositories\Wings\DaemonServerRepository;
use Pterodactyl\Tests\Integration\Api\Client\ClientApiIntegrationTestCase;
class ResourceUtilitizationControllerTest extends ClientApiIntegrationTestCase
class ResourceUtilizationControllerTest extends ClientApiIntegrationTestCase
{
/**
* Test that the resource utilization for a server is returned in the expected format.
@ -23,7 +23,7 @@ class ResourceUtilitizationControllerTest extends ClientApiIntegrationTestCase
return $server->uuid === $value->uuid;
}))->andReturnSelf()->getMock()->expects('getDetails')->andReturns([]);
$response = $this->actingAs($user)->getJson("/api/client/servers/{$server->uuid}/resources");
$response = $this->actingAs($user)->getJson("/api/client/servers/$server->uuid/resources");
$response->assertOk();
$response->assertJson([

View file

@ -12,14 +12,13 @@ class CreateServerScheduleTest extends ClientApiIntegrationTestCase
/**
* Test that a schedule can be created for the server.
*
* @param array $permissions
* @dataProvider permissionsDataProvider
*/
public function testScheduleCanBeCreatedForServer($permissions)
public function testScheduleCanBeCreatedForServer(array $permissions)
{
[$user, $server] = $this->generateTestAccount($permissions);
$response = $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/schedules", [
$response = $this->actingAs($user)->postJson("/api/client/servers/$server->uuid/schedules", [
'name' => 'Test Schedule',
'is_active' => false,
'minute' => '0',
@ -55,17 +54,17 @@ class CreateServerScheduleTest extends ClientApiIntegrationTestCase
{
[$user, $server] = $this->generateTestAccount();
$response = $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/schedules", []);
$response = $this->actingAs($user)->postJson("/api/client/servers/$server->uuid/schedules", []);
$response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
foreach (['name', 'minute', 'hour', 'day_of_month', 'day_of_week'] as $i => $field) {
$response->assertJsonPath("errors.{$i}.code", 'ValidationException');
$response->assertJsonPath("errors.{$i}.meta.rule", 'required');
$response->assertJsonPath("errors.{$i}.meta.source_field", $field);
$response->assertJsonPath("errors.$i.code", 'ValidationException');
$response->assertJsonPath("errors.$i.meta.rule", 'required');
$response->assertJsonPath("errors.$i.meta.source_field", $field);
}
$this->actingAs($user)
->postJson("/api/client/servers/{$server->uuid}/schedules", [
->postJson("/api/client/servers/$server->uuid/schedules", [
'name' => 'Testing',
'is_active' => 'no',
'minute' => '*',
@ -86,7 +85,7 @@ class CreateServerScheduleTest extends ClientApiIntegrationTestCase
[$user, $server] = $this->generateTestAccount([Permission::ACTION_SCHEDULE_UPDATE]);
$this->actingAs($user)
->postJson("/api/client/servers/{$server->uuid}/schedules", [])
->postJson("/api/client/servers/$server->uuid/schedules", [])
->assertForbidden();
}

View file

@ -13,10 +13,9 @@ class DeleteServerScheduleTest extends ClientApiIntegrationTestCase
/**
* Test that a schedule can be deleted from the system.
*
* @param array $permissions
* @dataProvider permissionsDataProvider
*/
public function testScheduleCanBeDeleted($permissions)
public function testScheduleCanBeDeleted(array $permissions)
{
[$user, $server] = $this->generateTestAccount($permissions);
@ -24,7 +23,7 @@ class DeleteServerScheduleTest extends ClientApiIntegrationTestCase
$task = Task::factory()->create(['schedule_id' => $schedule->id]);
$this->actingAs($user)
->deleteJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}")
->deleteJson("/api/client/servers/$server->uuid/schedules/$schedule->id")
->assertStatus(Response::HTTP_NO_CONTENT);
$this->assertDatabaseMissing('schedules', ['id' => $schedule->id]);
@ -39,7 +38,7 @@ class DeleteServerScheduleTest extends ClientApiIntegrationTestCase
[$user, $server] = $this->generateTestAccount();
$this->actingAs($user)
->deleteJson("/api/client/servers/{$server->uuid}/schedules/123456789")
->deleteJson("/api/client/servers/$server->uuid/schedules/123456789")
->assertStatus(Response::HTTP_NOT_FOUND);
}
@ -55,7 +54,7 @@ class DeleteServerScheduleTest extends ClientApiIntegrationTestCase
$schedule = Schedule::factory()->create(['server_id' => $server2->id]);
$this->actingAs($user)
->deleteJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}")
->deleteJson("/api/client/servers/$server->uuid/schedules/$schedule->id")
->assertStatus(Response::HTTP_NOT_FOUND);
$this->assertDatabaseHas('schedules', ['id' => $schedule->id]);
@ -72,7 +71,7 @@ class DeleteServerScheduleTest extends ClientApiIntegrationTestCase
$schedule = Schedule::factory()->create(['server_id' => $server->id]);
$this->actingAs($user)
->deleteJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}")
->deleteJson("/api/client/servers/$server->uuid/schedules/$schedule->id")
->assertStatus(Response::HTTP_FORBIDDEN);
$this->assertDatabaseHas('schedules', ['id' => $schedule->id]);

View file

@ -23,11 +23,9 @@ class GetServerSchedulesTest extends ClientApiIntegrationTestCase
/**
* Test that schedules for a server are returned.
*
* @param array $permissions
* @param bool $individual
* @dataProvider permissionsDataProvider
*/
public function testServerSchedulesAreReturned($permissions, $individual)
public function testServerSchedulesAreReturned(array $permissions, bool $individual)
{
[$user, $server] = $this->generateTestAccount($permissions);
@ -39,8 +37,8 @@ class GetServerSchedulesTest extends ClientApiIntegrationTestCase
$response = $this->actingAs($user)
->getJson(
$individual
? "/api/client/servers/{$server->uuid}/schedules/{$schedule->id}"
: "/api/client/servers/{$server->uuid}/schedules"
? "/api/client/servers/$server->uuid/schedules/$schedule->id"
: "/api/client/servers/$server->uuid/schedules"
)
->assertOk();
@ -69,7 +67,7 @@ class GetServerSchedulesTest extends ClientApiIntegrationTestCase
$schedule = Schedule::factory()->create(['server_id' => $server2->id]);
$this->actingAs($user)
->getJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}")
->getJson("/api/client/servers/$server->uuid/schedules/$schedule->id")
->assertNotFound();
}
@ -81,13 +79,13 @@ class GetServerSchedulesTest extends ClientApiIntegrationTestCase
[$user, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]);
$this->actingAs($user)
->getJson("/api/client/servers/{$server->uuid}/schedules")
->getJson("/api/client/servers/$server->uuid/schedules")
->assertForbidden();
$schedule = Schedule::factory()->create(['server_id' => $server->id]);
$this->actingAs($user)
->getJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}")
->getJson("/api/client/servers/$server->uuid/schedules/$schedule->id")
->assertForbidden();
}

View file

@ -54,9 +54,6 @@ class ScheduleAuthorizationTest extends ClientApiIntegrationTestCase
$this->actingAs($user)->json($method, $this->link($server3, '/schedules/' . $schedule3->id . $endpoint))->assertNotFound();
}
/**
* @return \string[][]
*/
public function methodDataProvider(): array
{
return [

View file

@ -11,10 +11,8 @@ class UpdateServerScheduleTest extends ClientApiIntegrationTestCase
{
/**
* The data to use when updating a schedule.
*
* @var array
*/
private $updateData = [
private array $updateData = [
'name' => 'Updated Schedule Name',
'minute' => '5',
'hour' => '*',
@ -27,10 +25,9 @@ class UpdateServerScheduleTest extends ClientApiIntegrationTestCase
/**
* Test that a schedule can be updated.
*
* @param array $permissions
* @dataProvider permissionsDataProvider
*/
public function testScheduleCanBeUpdated($permissions)
public function testScheduleCanBeUpdated(array $permissions)
{
[$user, $server] = $this->generateTestAccount($permissions);
@ -48,7 +45,7 @@ class UpdateServerScheduleTest extends ClientApiIntegrationTestCase
$this->assertFalse($schedule->is_active);
$this->assertJsonTransformedWith($response->json('attributes'), $schedule);
$this->assertSame($expected->toIso8601String(), $schedule->next_run_at->toIso8601String());
$this->assertSame($expected->toAtomString(), $schedule->next_run_at->toAtomString());
}
/**

View file

@ -13,10 +13,9 @@ class CreateServerScheduleTaskTest extends ClientApiIntegrationTestCase
/**
* Test that a task can be created.
*
* @param array $permissions
* @dataProvider permissionsDataProvider
*/
public function testTaskCanBeCreated($permissions)
public function testTaskCanBeCreated(array $permissions)
{
[$user, $server] = $this->generateTestAccount($permissions);
@ -56,8 +55,8 @@ class CreateServerScheduleTaskTest extends ClientApiIntegrationTestCase
$response = $this->actingAs($user)->postJson($this->link($schedule, '/tasks'))->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
foreach (['action', 'payload', 'time_offset'] as $i => $field) {
$response->assertJsonPath("errors.{$i}.meta.rule", $field === 'payload' ? 'required_unless' : 'required');
$response->assertJsonPath("errors.{$i}.meta.source_field", $field);
$response->assertJsonPath("errors.$i.meta.rule", $field === 'payload' ? 'required_unless' : 'required');
$response->assertJsonPath("errors.$i.meta.source_field", $field);
}
$this->actingAs($user)->postJson($this->link($schedule, '/tasks'), [
@ -151,7 +150,7 @@ class CreateServerScheduleTaskTest extends ClientApiIntegrationTestCase
$schedule = Schedule::factory()->create(['server_id' => $server2->id]);
$this->actingAs($user)
->postJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}/tasks")
->postJson("/api/client/servers/$server->uuid/schedules/$schedule->id/tasks")
->assertNotFound();
}

View file

@ -27,7 +27,7 @@ class DeleteScheduleTaskTest extends ClientApiIntegrationTestCase
/**
* Test that an error is returned if the task and schedule in the URL do not line up
* with eachother.
* with each other.
*/
public function testTaskBelongingToDifferentScheduleReturnsError()
{
@ -37,7 +37,7 @@ class DeleteScheduleTaskTest extends ClientApiIntegrationTestCase
$schedule2 = Schedule::factory()->create(['server_id' => $server->id]);
$task = Task::factory()->create(['schedule_id' => $schedule->id]);
$this->actingAs($user)->deleteJson("/api/client/servers/{$server->uuid}/schedules/{$schedule2->id}/tasks/{$task->id}")->assertNotFound();
$this->actingAs($user)->deleteJson("/api/client/servers/$server->uuid/schedules/$schedule2->id/tasks/$task->id")->assertNotFound();
}
/**

View file

@ -14,16 +14,15 @@ class SettingsControllerTest extends ClientApiIntegrationTestCase
/**
* Test that the server's name can be changed.
*
* @param array $permissions
* @dataProvider renamePermissionsDataProvider
*/
public function testServerNameCanBeChanged($permissions)
public function testServerNameCanBeChanged(array $permissions)
{
/** @var \Pterodactyl\Models\Server $server */
[$user, $server] = $this->generateTestAccount($permissions);
$originalName = $server->name;
$response = $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/settings/rename", [
$response = $this->actingAs($user)->postJson("/api/client/servers/$server->uuid/settings/rename", [
'name' => '',
]);
@ -34,7 +33,7 @@ class SettingsControllerTest extends ClientApiIntegrationTestCase
$this->assertSame($originalName, $server->name);
$this->actingAs($user)
->postJson("/api/client/servers/{$server->uuid}/settings/rename", [
->postJson("/api/client/servers/$server->uuid/settings/rename", [
'name' => 'Test Server Name',
])
->assertStatus(Response::HTTP_NO_CONTENT);
@ -53,7 +52,7 @@ class SettingsControllerTest extends ClientApiIntegrationTestCase
$originalName = $server->name;
$this->actingAs($user)
->postJson("/api/client/servers/{$server->uuid}/settings/rename", [
->postJson("/api/client/servers/$server->uuid/settings/rename", [
'name' => 'Test Server Name',
])
->assertStatus(Response::HTTP_FORBIDDEN);
@ -66,10 +65,9 @@ class SettingsControllerTest extends ClientApiIntegrationTestCase
* Test that a server can be reinstalled. Honestly this test doesn't do much of anything other
* than make sure the endpoint works since.
*
* @param array $permissions
* @dataProvider reinstallPermissionsDataProvider
*/
public function testServerCanBeReinstalled($permissions)
public function testServerCanBeReinstalled(array $permissions)
{
/** @var \Pterodactyl\Models\Server $server */
[$user, $server] = $this->generateTestAccount($permissions);
@ -87,7 +85,7 @@ class SettingsControllerTest extends ClientApiIntegrationTestCase
->expects('reinstall')
->andReturnUndefined();
$this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/settings/reinstall")
$this->actingAs($user)->postJson("/api/client/servers/$server->uuid/settings/reinstall")
->assertStatus(Response::HTTP_ACCEPTED);
$server = $server->refresh();
@ -103,7 +101,7 @@ class SettingsControllerTest extends ClientApiIntegrationTestCase
[$user, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]);
$this->actingAs($user)
->postJson("/api/client/servers/{$server->uuid}/settings/reinstall")
->postJson("/api/client/servers/$server->uuid/settings/reinstall")
->assertStatus(Response::HTTP_FORBIDDEN);
$server = $server->refresh();

View file

@ -13,16 +13,15 @@ class GetStartupAndVariablesTest extends ClientApiIntegrationTestCase
* Test that the startup command and variables are returned for a server, but only the variables
* that can be viewed by a user (e.g. user_viewable=true).
*
* @param array $permissions
* @dataProvider permissionsDataProvider
*/
public function testStartupVariablesAreReturnedForServer($permissions)
public function testStartupVariablesAreReturnedForServer(array $permissions)
{
/** @var \Pterodactyl\Models\Server $server */
[$user, $server] = $this->generateTestAccount($permissions);
$egg = $this->cloneEggAndVariables($server->egg);
// BUNGEE_VERSION should never be returned back to the user in this API call, either in
// BUNGEE_VERSION should never be returned to the user in this API call, either in
// the array of variables, or revealed in the startup command.
$egg->variables()->first()->update([
'user_viewable' => false,
@ -59,10 +58,7 @@ class GetStartupAndVariablesTest extends ClientApiIntegrationTestCase
$this->actingAs($user2)->getJson($this->link($server) . '/startup')->assertNotFound();
}
/**
* @return array[]
*/
public function permissionsDataProvider()
public function permissionsDataProvider(): array
{
return [[[]], [[Permission::ACTION_STARTUP_READ]]];
}

View file

@ -13,10 +13,9 @@ class UpdateStartupVariableTest extends ClientApiIntegrationTestCase
/**
* Test that a startup variable can be edited successfully for a server.
*
* @param array $permissions
* @dataProvider permissionsDataProvider
*/
public function testStartupVariableCanBeUpdated($permissions)
public function testStartupVariableCanBeUpdated(array $permissions)
{
/** @var \Pterodactyl\Models\Server $server */
[$user, $server] = $this->generateTestAccount($permissions);
@ -150,10 +149,7 @@ class UpdateStartupVariableTest extends ClientApiIntegrationTestCase
$this->actingAs($user2)->putJson($this->link($server) . '/startup/variable')->assertNotFound();
}
/**
* @return \array[][]
*/
public function permissionsDataProvider()
public function permissionsDataProvider(): array
{
return [[[]], [[Permission::ACTION_STARTUP_UPDATE]]];
}

View file

@ -17,10 +17,9 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase
/**
* Test that a subuser can be created for a server.
*
* @param array $permissions
* @dataProvider permissionsDataProvider
*/
public function testSubuserCanBeCreated($permissions)
public function testSubuserCanBeCreated(array $permissions)
{
[$user, $server] = $this->generateTestAccount($permissions);
@ -62,7 +61,7 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase
]);
$response = $this->actingAs($user)->postJson($this->link($server) . '/users', [
'email' => $email = $this->faker->email,
'email' => $this->faker->email,
'permissions' => [
Permission::ACTION_USER_CREATE,
Permission::ACTION_USER_UPDATE, // This permission is not assigned to the subuser.

View file

@ -47,7 +47,7 @@ class DeleteSubuserTest extends ClientApiIntegrationTestCase
$mock->expects('setServer->revokeUserJTI')->with($subuser->id)->andReturnUndefined();
$this->actingAs($user)->deleteJson($this->link($server) . "/users/{$subuser->uuid}")->assertNoContent();
$this->actingAs($user)->deleteJson($this->link($server) . "/users/$subuser->uuid")->assertNoContent();
// Try the same test, but this time with a UUID that if cast to an int (shouldn't) line up with
// anything in the database.
@ -63,6 +63,6 @@ class DeleteSubuserTest extends ClientApiIntegrationTestCase
$mock->expects('setServer->revokeUserJTI')->with($subuser->id)->andReturnUndefined();
$this->actingAs($user)->deleteJson($this->link($server) . "/users/{$subuser->uuid}")->assertNoContent();
$this->actingAs($user)->deleteJson($this->link($server) . "/users/$subuser->uuid")->assertNoContent();
}
}

View file

@ -50,9 +50,6 @@ class SubuserAuthorizationTest extends ClientApiIntegrationTestCase
$this->actingAs($user)->json($method, $this->link($server3, '/users/' . $internal->uuid))->assertNotFound();
}
/**
* @return \string[][]
*/
public function methodDataProvider(): array
{
return [['GET'], ['POST'], ['DELETE']];

View file

@ -14,14 +14,14 @@ use Pterodactyl\Tests\Integration\Api\Client\ClientApiIntegrationTestCase;
class WebsocketControllerTest extends ClientApiIntegrationTestCase
{
/**
* Test that a subuser attempting to connect to the websocket recieves an error if they
* Test that a subuser attempting to connect to the websocket receives an error if they
* do not explicitly have the permission.
*/
public function testSubuserWithoutWebsocketPermissionReceivesError()
{
[$user, $server] = $this->generateTestAccount([Permission::ACTION_CONTROL_RESTART]);
$this->actingAs($user)->getJson("/api/client/servers/{$server->uuid}/websocket")
$this->actingAs($user)->getJson("/api/client/servers/$server->uuid/websocket")
->assertStatus(Response::HTTP_FORBIDDEN)
->assertJsonPath('errors.0.code', 'HttpForbiddenException')
->assertJsonPath('errors.0.detail', 'You do not have permission to connect to this server\'s websocket.');
@ -33,9 +33,9 @@ class WebsocketControllerTest extends ClientApiIntegrationTestCase
public function testUserWithoutPermissionForServerReceivesError()
{
[, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]);
[$user,] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]);
[$user] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]);
$this->actingAs($user)->getJson("/api/client/servers/{$server->uuid}/websocket")
$this->actingAs($user)->getJson("/api/client/servers/$server->uuid/websocket")
->assertStatus(Response::HTTP_NOT_FOUND);
}
@ -53,14 +53,14 @@ class WebsocketControllerTest extends ClientApiIntegrationTestCase
$server->node->scheme = 'https';
$server->node->save();
$response = $this->actingAs($user)->getJson("/api/client/servers/{$server->uuid}/websocket");
$response = $this->actingAs($user)->getJson("/api/client/servers/$server->uuid/websocket");
$response->assertOk();
$response->assertJsonStructure(['data' => ['token', 'socket']]);
$connection = $response->json('data.socket');
$this->assertStringStartsWith('wss://', $connection, 'Failed asserting that websocket connection address has expected "wss://" prefix.');
$this->assertStringEndsWith("/api/servers/{$server->uuid}/ws", $connection, 'Failed asserting that websocket connection address uses expected Wings endpoint.');
$this->assertStringEndsWith("/api/servers/$server->uuid/ws", $connection, 'Failed asserting that websocket connection address uses expected Wings endpoint.');
$config = Configuration::forSymmetricSigner(new Sha256(), $key = InMemory::plainText($server->node->getDecryptedKey()));
$config->setValidationConstraints(new SignedWith(new Sha256(), $key));
@ -102,7 +102,7 @@ class WebsocketControllerTest extends ClientApiIntegrationTestCase
/** @var \Pterodactyl\Models\Server $server */
[$user, $server] = $this->generateTestAccount($permissions);
$response = $this->actingAs($user)->getJson("/api/client/servers/{$server->uuid}/websocket");
$response = $this->actingAs($user)->getJson("/api/client/servers/$server->uuid/websocket");
$response->assertOk();
$response->assertJsonStructure(['data' => ['token', 'socket']]);

View file

@ -122,7 +122,7 @@ class TwoFactorControllerTest extends ClientApiIntegrationTestCase
}
/**
* Test that two factor authentication can be disabled on an account as long as the password
* Test that two-factor authentication can be disabled on an account as long as the password
* provided is valid for the account.
*/
public function testTwoFactorCanBeDisabledOnAccount()
@ -149,7 +149,7 @@ class TwoFactorControllerTest extends ClientApiIntegrationTestCase
$user = $user->refresh();
$this->assertFalse($user->use_totp);
$this->assertNotNull($user->totp_authenticated_at);
$this->assertSame(Carbon::now()->toIso8601String(), $user->totp_authenticated_at->toIso8601String());
$this->assertSame(Carbon::now()->toAtomString(), $user->totp_authenticated_at->toAtomString());
}
/**

View file

@ -97,7 +97,7 @@ class SftpAuthenticationControllerTest extends IntegrationTestCase
*
* @dataProvider authorizationTypeDataProvider
*/
public function testUserIsThrottledIfInvalidCredentialsAreProvided(string $type)
public function testUserIsThrottledIfInvalidCredentialsAreProvided()
{
for ($i = 0; $i <= 10; ++$i) {
$this->postJson('/api/remote/sftp/auth', [

View file

@ -21,7 +21,7 @@ class UserControllerTest extends IntegrationTestCase
*/
public function testIndexReturnsExpectedData()
{
$unique = Str::random(16);
$unique = Str::random();
$users = [
User::factory()->create(['username' => $unique . '_1']),
User::factory()->create(['username' => $unique . '_2']),
@ -40,7 +40,7 @@ class UserControllerTest extends IntegrationTestCase
/** @var \Pterodactyl\Http\Controllers\Admin\UserController $controller */
$controller = $this->app->make(UserController::class);
$request = Request::create('/admin/users?filter[username]=' . $unique, 'GET');
$request = Request::create('/admin/users?filter[username]=' . $unique);
$this->app->instance(Request::class, $request);
$data = $controller->index($request)->getData();

View file

@ -3,6 +3,7 @@
namespace Pterodactyl\Tests\Integration;
use Carbon\CarbonImmutable;
use Carbon\CarbonInterface;
use Pterodactyl\Tests\TestCase;
use Illuminate\Support\Facades\Event;
use Pterodactyl\Events\ActivityLogged;
@ -33,8 +34,8 @@ abstract class IntegrationTestCase extends TestCase
*/
protected function formatTimestamp(string $timestamp): string
{
return CarbonImmutable::createFromFormat(CarbonImmutable::DEFAULT_TO_STRING_FORMAT, $timestamp)
return CarbonImmutable::createFromFormat(CarbonInterface::DEFAULT_TO_STRING_FORMAT, $timestamp)
->setTimezone(BaseTransformer::RESPONSE_TIMEZONE)
->toIso8601String();
->toAtomString();
}
}

View file

@ -48,7 +48,7 @@ class RunTaskJobTest extends IntegrationTestCase
$this->assertFalse($task->is_queued);
$this->assertFalse($schedule->is_processing);
$this->assertFalse($schedule->is_active);
$this->assertTrue(CarbonImmutable::now()->isSameAs(CarbonImmutable::ISO8601, $schedule->last_run_at));
$this->assertTrue(CarbonImmutable::now()->isSameAs(DateTimeInterface::ATOM, $schedule->last_run_at));
}
public function testJobWithInvalidActionThrowsException()
@ -105,7 +105,7 @@ class RunTaskJobTest extends IntegrationTestCase
$this->assertFalse($task->is_queued);
$this->assertFalse($schedule->is_processing);
$this->assertTrue(CarbonImmutable::now()->isSameAs(CarbonImmutable::ISO8601, $schedule->last_run_at));
$this->assertTrue(CarbonImmutable::now()->isSameAs(DateTimeInterface::ATOM, $schedule->last_run_at));
}
/**
@ -144,7 +144,7 @@ class RunTaskJobTest extends IntegrationTestCase
$this->assertFalse($task->is_queued);
$this->assertFalse($schedule->is_processing);
$this->assertTrue(CarbonImmutable::now()->isSameAs(CarbonImmutable::ISO8601, $schedule->last_run_at));
$this->assertTrue(CarbonImmutable::now()->isSameAs(DateTimeInterface::ATOM, $schedule->last_run_at));
}
}
@ -178,10 +178,7 @@ class RunTaskJobTest extends IntegrationTestCase
$this->assertTrue(Carbon::now()->isSameAs(DateTimeInterface::ATOM, $schedule->last_run_at));
}
/**
* @return array
*/
public function isManualRunDataProvider()
public function isManualRunDataProvider(): array
{
return [[true], [false]];
}

View file

@ -25,7 +25,7 @@ class FindAssignableAllocationServiceTest extends IntegrationTestCase
}
/**
* Test that an unassigned allocation is prefered rather than creating an entirely new
* Test that an unassigned allocation is preferred rather than creating an entirely new
* allocation for the server.
*/
public function testExistingAllocationIsPreferred()
@ -141,7 +141,7 @@ class FindAssignableAllocationServiceTest extends IntegrationTestCase
try {
$this->getService()->handle($server);
$this->assertTrue(false, 'This assertion should not be reached.');
$this->fail('This assertion should not be reached.');
} catch (Exception $exception) {
$this->assertInstanceOf(InvalidArgumentException::class, $exception);
$this->assertSame('Expected an integerish value. Got: string', $exception->getMessage());
@ -152,7 +152,7 @@ class FindAssignableAllocationServiceTest extends IntegrationTestCase
try {
$this->getService()->handle($server);
$this->assertTrue(false, 'This assertion should not be reached.');
$this->fail('This assertion should not be reached.');
} catch (Exception $exception) {
$this->assertInstanceOf(InvalidArgumentException::class, $exception);
$this->assertSame('Expected an integerish value. Got: string', $exception->getMessage());
@ -169,10 +169,7 @@ class FindAssignableAllocationServiceTest extends IntegrationTestCase
$this->getService()->handle($server);
}
/**
* @return \Pterodactyl\Services\Allocations\FindAssignableAllocationService
*/
private function getService()
private function getService(): FindAssignableAllocationService
{
return $this->app->make(FindAssignableAllocationService::class);
}

View file

@ -2,12 +2,12 @@
namespace Pterodactyl\Tests\Integration\Services\Backups;
use Mockery;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
use Pterodactyl\Models\Backup;
use GuzzleHttp\Exception\ClientException;
use Pterodactyl\Extensions\Backups\BackupManager;
use Pterodactyl\Extensions\Filesystem\S3Filesystem;
use Pterodactyl\Services\Backups\DeleteBackupService;
use Pterodactyl\Tests\Integration\IntegrationTestCase;
use Pterodactyl\Repositories\Wings\DaemonBackupRepository;
@ -16,17 +16,6 @@ use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
class DeleteBackupServiceTest extends IntegrationTestCase
{
private $repository;
public function setUp(): void
{
parent::setUp();
$this->repository = Mockery::mock(DaemonBackupRepository::class);
$this->app->instance(DaemonBackupRepository::class, $this->repository);
}
public function testLockedBackupCannotBeDeleted()
{
$server = $this->createServerModel();
@ -49,9 +38,8 @@ class DeleteBackupServiceTest extends IntegrationTestCase
'is_successful' => false,
]);
$this->repository->expects('setServer->delete')->with($backup)->andReturn(
new Response()
);
$mock = $this->mock(DaemonBackupRepository::class);
$mock->expects('setServer->delete')->with($backup)->andReturn(new Response());
$this->app->make(DeleteBackupService::class)->handle($backup);
@ -65,7 +53,8 @@ class DeleteBackupServiceTest extends IntegrationTestCase
$server = $this->createServerModel();
$backup = Backup::factory()->create(['server_id' => $server->id]);
$this->repository->expects('setServer->delete')->with($backup)->andThrow(
$mock = $this->mock(DaemonBackupRepository::class);
$mock->expects('setServer->delete')->with($backup)->andThrow(
new DaemonConnectionException(
new ClientException('', new Request('DELETE', '/'), new Response(404))
)
@ -83,7 +72,8 @@ class DeleteBackupServiceTest extends IntegrationTestCase
$server = $this->createServerModel();
$backup = Backup::factory()->create(['server_id' => $server->id]);
$this->repository->expects('setServer->delete')->with($backup)->andThrow(
$mock = $this->mock(DaemonBackupRepository::class);
$mock->expects('setServer->delete')->with($backup)->andThrow(
new DaemonConnectionException(
new ClientException('', new Request('DELETE', '/'), new Response(500))
)
@ -107,17 +97,18 @@ class DeleteBackupServiceTest extends IntegrationTestCase
]);
$manager = $this->mock(BackupManager::class);
$manager->expects('getBucket')->andReturns('foobar');
$manager->expects('adapter')->with(Backup::ADAPTER_AWS_S3)->andReturnSelf();
$manager->expects('getClient->deleteObject')->with([
$adapter = $this->mock(S3Filesystem::class);
$manager->expects('adapter')->with(Backup::ADAPTER_AWS_S3)->andReturn($adapter);
$adapter->expects('getBucket')->andReturn('foobar');
$adapter->expects('getClient->deleteObject')->with([
'Bucket' => 'foobar',
'Key' => sprintf('%s/%s.tar.gz', $server->uuid, $backup->uuid),
]);
$this->app->make(DeleteBackupService::class)->handle($backup);
$backup->refresh();
$this->assertNotNull($backup->deleted_at);
$this->assertSoftDeleted($backup);
}
}

View file

@ -3,6 +3,7 @@
namespace Pterodactyl\Tests\Integration\Services\Databases;
use Mockery;
use Mockery\MockInterface;
use BadMethodCallException;
use InvalidArgumentException;
use Pterodactyl\Models\Database;
@ -16,8 +17,7 @@ use Pterodactyl\Exceptions\Service\Database\DatabaseClientFeatureNotEnabledExcep
class DatabaseManagementServiceTest extends IntegrationTestCase
{
/** @var \Mockery\MockInterface */
private $repository;
private MockInterface $repository;
/**
* Setup tests.
@ -28,8 +28,7 @@ class DatabaseManagementServiceTest extends IntegrationTestCase
config()->set('pterodactyl.client_features.databases.enabled', true);
$this->repository = Mockery::mock(DatabaseRepository::class);
$this->swap(DatabaseRepository::class, $this->repository);
$this->repository = $this->mock(DatabaseRepository::class);
}
/**
@ -74,10 +73,9 @@ class DatabaseManagementServiceTest extends IntegrationTestCase
/**
* Test that a missing or invalid database name format causes an exception to be thrown.
*
* @param array $data
* @dataProvider invalidDataDataProvider
*/
public function testEmptyDatabaseNameOrInvalidNameTriggersAnException($data)
public function testEmptyDatabaseNameOrInvalidNameTriggersAnException(array $data)
{
$server = $this->createServerModel();
@ -166,7 +164,7 @@ class DatabaseManagementServiceTest extends IntegrationTestCase
$this->assertInstanceOf(Database::class, $response);
$this->assertSame($response->server_id, $server->id);
$this->assertMatchesRegularExpression('/^(u[\d]+_)(\w){10}$/', $username);
$this->assertMatchesRegularExpression('/^(u\d+_)(\w){10}$/', $username);
$this->assertSame($username, $secondUsername);
$this->assertSame(24, strlen($password));
@ -174,8 +172,8 @@ class DatabaseManagementServiceTest extends IntegrationTestCase
}
/**
* Test that an exception encountered while creating the database leads to cleanup code being called
* and any exceptions encountered while cleaning up go unreported.
* Test that an exception encountered while creating the database leads to the cleanup code
* being called and any exceptions encountered while cleaning up go unreported.
*/
public function testExceptionEncounteredWhileCreatingDatabaseAttemptsToCleanup()
{
@ -211,10 +209,7 @@ class DatabaseManagementServiceTest extends IntegrationTestCase
];
}
/**
* @return \Pterodactyl\Services\Databases\DatabaseManagementService
*/
private function getService()
private function getService(): DatabaseManagementService
{
return $this->app->make(DatabaseManagementService::class);
}

View file

@ -3,6 +3,7 @@
namespace Pterodactyl\Tests\Integration\Services\Databases;
use Mockery;
use Mockery\MockInterface;
use Pterodactyl\Models\Node;
use InvalidArgumentException;
use Pterodactyl\Models\Database;
@ -14,8 +15,7 @@ use Pterodactyl\Exceptions\Service\Database\NoSuitableDatabaseHostException;
class DeployServerDatabaseServiceTest extends IntegrationTestCase
{
/** @var \Mockery\MockInterface */
private $managementService;
private MockInterface $managementService;
/**
* Setup tests.
@ -44,10 +44,9 @@ class DeployServerDatabaseServiceTest extends IntegrationTestCase
/**
* Test that an error is thrown if either the database name or the remote host are empty.
*
* @param array $data
* @dataProvider invalidDataProvider
*/
public function testErrorIsThrownIfDatabaseNameIsEmpty($data)
public function testErrorIsThrownIfDatabaseNameIsEmpty(array $data)
{
$server = $this->createServerModel();
@ -154,10 +153,7 @@ class DeployServerDatabaseServiceTest extends IntegrationTestCase
];
}
/**
* @return \Pterodactyl\Services\Databases\DeployServerDatabaseService
*/
private function getService()
private function getService(): DeployServerDatabaseService
{
return $this->app->make(DeployServerDatabaseService::class);
}

View file

@ -53,7 +53,7 @@ class FindViableNodesServiceTest extends IntegrationTestCase
try {
$this->getService()->setLocations(['a']);
$this->assertTrue(false, 'This expectation should not be called.');
$this->fail('This expectation should not be called.');
} catch (Exception $exception) {
$this->assertInstanceOf(InvalidArgumentException::class, $exception);
$this->assertSame('An array of location IDs should be provided when calling setLocations.', $exception->getMessage());
@ -61,7 +61,7 @@ class FindViableNodesServiceTest extends IntegrationTestCase
try {
$this->getService()->setLocations(['1.2', '1', 2]);
$this->assertTrue(false, 'This expectation should not be called.');
$this->fail('This expectation should not be called.');
} catch (Exception $exception) {
$this->assertInstanceOf(InvalidArgumentException::class, $exception);
$this->assertSame('An array of location IDs should be provided when calling setLocations.', $exception->getMessage());
@ -96,7 +96,7 @@ class FindViableNodesServiceTest extends IntegrationTestCase
]),
];
// Expect that all of the nodes are returned as we're under all of their limits
// Expect that all the nodes are returned as we're under all of their limits
// and there is no location filter being provided.
$response = $this->getService()->setDisk(512)->setMemory(512)->handle();
$this->assertInstanceOf(Collection::class, $response);
@ -182,10 +182,7 @@ class FindViableNodesServiceTest extends IntegrationTestCase
$this->assertSame($nodes[1]->id, $response[0]->id);
}
/**
* @return \Pterodactyl\Services\Deployment\FindViableNodesService
*/
private function getService()
private function getService(): FindViableNodesService
{
return $this->app->make(FindViableNodesService::class);
}

View file

@ -58,10 +58,9 @@ class ProcessScheduleServiceTest extends IntegrationTestCase
/**
* Test that a job is dispatched as expected using the initial delay.
*
* @param bool $now
* @dataProvider dispatchNowDataProvider
*/
public function testJobCanBeDispatchedWithExpectedInitialDelay($now)
public function testJobCanBeDispatchedWithExpectedInitialDelay(bool $now)
{
Bus::fake();
@ -156,10 +155,7 @@ class ProcessScheduleServiceTest extends IntegrationTestCase
return [[true], [false]];
}
/**
* @return \Pterodactyl\Services\Schedules\ProcessScheduleService
*/
private function getService()
private function getService(): ProcessScheduleService
{
return $this->app->make(ProcessScheduleService::class);
}

View file

@ -3,6 +3,7 @@
namespace Pterodactyl\Tests\Integration\Services\Servers;
use Mockery;
use Mockery\MockInterface;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
use Pterodactyl\Models\Server;
@ -16,8 +17,7 @@ use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
class BuildModificationServiceTest extends IntegrationTestCase
{
/** @var \Mockery\MockInterface */
private $daemonServerRepository;
private MockInterface $daemonServerRepository;
/**
* Setup tests.
@ -183,7 +183,7 @@ class BuildModificationServiceTest extends IntegrationTestCase
/**
* Test that allocations in both the add and remove arrays are only added, and not removed.
* This scenario wouldn't really happen in the UI, but it is possible to perform via the API
* This scenario wouldn't really happen in the UI, but it is possible to perform via the API,
* so we want to make sure that the logic being used doesn't break if the allocation exists
* in both arrays.
*
@ -229,7 +229,7 @@ class BuildModificationServiceTest extends IntegrationTestCase
/**
* Test that any changes we made to the server or allocations are rolled back if there is an
* exception while performing any action. This is different than the connection exception
* exception while performing any action. This is different from the connection exception
* test which should properly ignore connection issues. We want any other type of exception
* to properly be thrown back to the caller.
*/
@ -248,10 +248,7 @@ class BuildModificationServiceTest extends IntegrationTestCase
$this->assertDatabaseHas('allocations', ['id' => $allocation->id, 'server_id' => null]);
}
/**
* @return \Pterodactyl\Services\Servers\BuildModificationService
*/
private function getService()
private function getService(): BuildModificationService
{
return $this->app->make(BuildModificationService::class);
}

View file

@ -3,6 +3,7 @@
namespace Pterodactyl\Tests\Integration\Services\Servers;
use Mockery;
use Mockery\MockInterface;
use Pterodactyl\Models\Egg;
use GuzzleHttp\Psr7\Request;
use Pterodactyl\Models\Node;
@ -24,8 +25,7 @@ class ServerCreationServiceTest extends IntegrationTestCase
{
use WithFaker;
/** @var \Mockery\MockInterface */
protected $daemonServerRepository;
protected MockInterface $daemonServerRepository;
protected Egg $bungeecord;
@ -208,10 +208,7 @@ class ServerCreationServiceTest extends IntegrationTestCase
$this->assertDatabaseMissing('servers', ['owner_id' => $user->id]);
}
/**
* @return \Pterodactyl\Services\Servers\ServerCreationService
*/
private function getService()
private function getService(): ServerCreationService
{
return $this->app->make(ServerCreationService::class);
}

View file

@ -4,9 +4,9 @@ namespace Pterodactyl\Tests\Integration\Services\Servers;
use Mockery;
use Exception;
use Mockery\MockInterface;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
use Pterodactyl\Models\Server;
use Pterodactyl\Models\Database;
use Pterodactyl\Models\DatabaseHost;
use GuzzleHttp\Exception\BadResponseException;
@ -18,13 +18,11 @@ use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
class ServerDeletionServiceTest extends IntegrationTestCase
{
/** @var \Mockery\MockInterface */
private $daemonServerRepository;
private MockInterface $daemonServerRepository;
/** @var \Mockery\MockInterface */
private $databaseManagementService;
private MockInterface $databaseManagementService;
private static $defaultLogger;
private static ?string $defaultLogger;
/**
* Stub out services that we don't want to test in here.
@ -102,7 +100,7 @@ class ServerDeletionServiceTest extends IntegrationTestCase
new DaemonConnectionException(new BadResponseException('Bad request', new Request('GET', '/test'), new Response(500)))
);
$this->getService()->withForce(true)->handle($server);
$this->getService()->withForce()->handle($server);
$this->assertDatabaseMissing('servers', ['id' => $server->id]);
}
@ -157,10 +155,7 @@ class ServerDeletionServiceTest extends IntegrationTestCase
$this->assertDatabaseMissing('databases', ['id' => $db->id]);
}
/**
* @return \Pterodactyl\Services\Servers\ServerDeletionService
*/
private function getService()
private function getService(): ServerDeletionService
{
return $this->app->make(ServerDeletionService::class);
}

View file

@ -33,7 +33,7 @@ class StartupModificationServiceTest extends IntegrationTestCase
],
]);
$this->assertTrue(false, 'This assertion should not be called.');
$this->fail('This assertion should not be called.');
} catch (Exception $exception) {
$this->assertInstanceOf(ValidationException::class, $exception);
@ -161,10 +161,7 @@ class StartupModificationServiceTest extends IntegrationTestCase
->handle($server, ['egg_id' => 123456789]);
}
/**
* @return \Pterodactyl\Services\Servers\StartupModificationService
*/
private function getService()
private function getService(): StartupModificationService
{
return $this->app->make(StartupModificationService::class);
}

View file

@ -3,6 +3,7 @@
namespace Pterodactyl\Tests\Integration\Services\Servers;
use Mockery;
use Mockery\MockInterface;
use InvalidArgumentException;
use Pterodactyl\Models\Server;
use Pterodactyl\Services\Servers\SuspensionService;
@ -11,8 +12,7 @@ use Pterodactyl\Repositories\Wings\DaemonServerRepository;
class SuspensionServiceTest extends IntegrationTestCase
{
/** @var \Mockery\MockInterface */
private $repository;
private MockInterface $repository;
/**
* Setup test instance.
@ -31,7 +31,7 @@ class SuspensionServiceTest extends IntegrationTestCase
$this->repository->expects('setServer->sync')->twice()->andReturnSelf();
$this->getService()->toggle($server, SuspensionService::ACTION_SUSPEND);
$this->getService()->toggle($server);
$this->assertTrue($server->refresh()->isSuspended());
@ -50,7 +50,7 @@ class SuspensionServiceTest extends IntegrationTestCase
$this->assertFalse($server->isSuspended());
$server->update(['status' => Server::STATUS_SUSPENDED]);
$this->getService()->toggle($server, SuspensionService::ACTION_SUSPEND);
$this->getService()->toggle($server);
$server->refresh();
$this->assertTrue($server->isSuspended());
@ -66,10 +66,7 @@ class SuspensionServiceTest extends IntegrationTestCase
$this->getService()->toggle($server, 'foo');
}
/**
* @return \Pterodactyl\Services\Servers\SuspensionService
*/
private function getService()
private function getService(): SuspensionService
{
return $this->app->make(SuspensionService::class);
}

View file

@ -25,7 +25,7 @@ class VariableValidatorServiceTest extends IntegrationTestCase
}
/**
* Test that enviornment variables for a server are validated as expected.
* Test that environment variables for a server are validated as expected.
*/
public function testEnvironmentVariablesCanBeValidated()
{
@ -36,7 +36,7 @@ class VariableValidatorServiceTest extends IntegrationTestCase
'BUNGEE_VERSION' => '1.2.3',
]);
$this->assertTrue(false, 'This statement should not be reached.');
$this->fail('This statement should not be reached.');
} catch (ValidationException $exception) {
$errors = $exception->errors();
@ -96,7 +96,7 @@ class VariableValidatorServiceTest extends IntegrationTestCase
'SERVER_JARFILE' => 'server.jar',
]);
$this->assertTrue(false, 'This statement should not be reached.');
$this->fail('This statement should not be reached.');
} catch (ValidationException $exception) {
$this->assertCount(1, $exception->errors());
$this->assertArrayHasKey('environment.BUNGEE_VERSION', $exception->errors());
@ -135,10 +135,7 @@ class VariableValidatorServiceTest extends IntegrationTestCase
$this->assertSame('', $response->get(0)->value);
}
/**
* @return \Pterodactyl\Services\Servers\VariableValidatorService
*/
private function getService()
private function getService(): VariableValidatorService
{
return $this->app->make(VariableValidatorService::class);
}

View file

@ -12,14 +12,10 @@ class TestResponse extends IlluminateTestResponse
{
/**
* Overrides the default assert status logic to dump out the error to the
* test output if it is caused by a 500 level error and we were not specifically
* test output if it is caused by a 500 level error, and we were not specifically
* look for that status response.
*
* @param int $status
*
* @return \Pterodactyl\Tests\Integration\TestResponse
*/
public function assertStatus($status)
public function assertStatus($status): TestResponse
{
$actual = $this->getStatusCode();
@ -41,10 +37,7 @@ class TestResponse extends IlluminateTestResponse
return $this;
}
/**
* @return $this
*/
public function assertForbidden()
public function assertForbidden(): self
{
return self::assertStatus(Response::HTTP_FORBIDDEN);
}

View file

@ -10,7 +10,7 @@ trait IntegrationJsonRequestAssertions
/**
* Make assertions about a 404 response on the API.
*/
public function assertNotFoundJson(TestResponse $response)
public function assertNotFoundJson(TestResponse $response): void
{
$response->assertStatus(Response::HTTP_NOT_FOUND);
$response->assertJsonStructure(['errors' => [['code', 'status', 'detail']]]);
@ -29,7 +29,7 @@ trait IntegrationJsonRequestAssertions
/**
* Make assertions about a 403 error returned by the API.
*/
public function assertAccessDeniedJson(TestResponse $response)
public function assertAccessDeniedJson(TestResponse $response): void
{
$response->assertStatus(Response::HTTP_FORBIDDEN);
$response->assertJsonStructure(['errors' => [['code', 'status', 'detail']]]);

View file

@ -3,6 +3,7 @@
namespace Pterodactyl\Tests\Traits\Http;
use Mockery as m;
use Mockery\Mock;
use Illuminate\Http\Request;
use Pterodactyl\Models\User;
use InvalidArgumentException;
@ -10,20 +11,14 @@ use Symfony\Component\HttpFoundation\ParameterBag;
trait RequestMockHelpers
{
/**
* @var string
*/
private $requestMockClass = Request::class;
private string $requestMockClass = Request::class;
/**
* @var \Illuminate\Http\Request|\Mockery\Mock
*/
protected $request;
protected Request|Mock $request;
/**
* Set the class to mock for requests.
*/
public function setRequestMockClass(string $class)
public function setRequestMockClass(string $class): void
{
$this->requestMockClass = $class;
@ -33,7 +28,7 @@ trait RequestMockHelpers
/**
* Configure the user model that the request mock should return with.
*/
public function setRequestUserModel(User $user = null)
public function setRequestUserModel(User $user = null): void
{
$this->request->shouldReceive('user')->andReturn($user);
}
@ -43,6 +38,7 @@ trait RequestMockHelpers
*/
public function generateRequestUserModel(array $args = []): User
{
/** @var \Pterodactyl\Models\User $user */
$user = User::factory()->make($args);
$this->setRequestUserModel($user);
@ -51,10 +47,8 @@ trait RequestMockHelpers
/**
* Set a request attribute on the mock object.
*
* @param mixed $value
*/
public function setRequestAttribute(string $attribute, $value)
public function setRequestAttribute(string $attribute, mixed $value): void
{
$this->request->attributes->set($attribute, $value);
}
@ -62,7 +56,7 @@ trait RequestMockHelpers
/**
* Set the request route name.
*/
public function setRequestRouteName(string $name)
public function setRequestRouteName(string $name): void
{
$this->request->shouldReceive('route->getName')->andReturn($name);
}
@ -70,7 +64,7 @@ trait RequestMockHelpers
/**
* Set the active request object to be an instance of a mocked request.
*/
protected function buildRequestMock()
protected function buildRequestMock(): void
{
$this->request = m::mock($this->requestMockClass);
if (!$this->request instanceof Request) {

View file

@ -18,11 +18,9 @@ trait CreatesTestModels
* is passed in that normally requires this function to create a model no model will be
* created and that attribute's value will be used.
*
* The returned server model will have all of the relationships loaded onto it.
*
* @return \Pterodactyl\Models\Server
* The returned server model will have all the relationships loaded onto it.
*/
public function createServerModel(array $attributes = [])
public function createServerModel(array $attributes = []): Server
{
if (isset($attributes['user_id'])) {
$attributes['owner_id'] = $attributes['user_id'];
@ -126,11 +124,14 @@ trait CreatesTestModels
}
/**
* Most every test just assumes it is using Bungeecord this is the critical
* Almost every test just assumes it is using BungeeCord this is the critical
* egg model for all tests unless specified otherwise.
*/
private function getBungeecordEgg()
private function getBungeecordEgg(): Egg
{
return Egg::query()->where('author', 'support@pterodactyl.io')->where('name', 'Bungeecord')->firstOrFail();
/** @var \Pterodactyl\Models\Egg $egg */
$egg = Egg::query()->where('author', 'support@pterodactyl.io')->where('name', 'Bungeecord')->firstOrFail();
return $egg;
}
}

View file

@ -7,21 +7,17 @@ use Mockery;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\MySqlConnection;
use Illuminate\Database\ConnectionResolver;
use Illuminate\Database\ConnectionResolverInterface;
trait MocksPdoConnection
{
/**
* @var \Illuminate\Database\ConnectionResolverInterface|null
*/
private static $initialResolver;
private static ?ConnectionResolverInterface $initialResolver;
/**
* Generates a mock PDO connection and injects it into the models so that any actual
* DB call can be properly intercepted.
*
* @return \Mockery\MockInterface
*/
protected function mockPdoConnection()
protected function mockPdoConnection(): Mockery\MockInterface
{
self::$initialResolver = Model::getConnectionResolver();
@ -39,7 +35,7 @@ trait MocksPdoConnection
/**
* Resets the mock state.
*/
protected function tearDownPdoMock()
protected function tearDownPdoMock(): void
{
if (!self::$initialResolver) {
return;

View file

@ -3,28 +3,21 @@
namespace Pterodactyl\Tests\Traits;
use Mockery;
use Mockery\Mock;
use Mockery\MockInterface;
use GuzzleHttp\Exception\RequestException;
trait MocksRequestException
{
/**
* @var \GuzzleHttp\Exception\RequestException|\Mockery\Mock
*/
private $exception;
private RequestException|Mock $exception;
/**
* @var mixed
*/
private $exceptionResponse;
private mixed $exceptionResponse;
/**
* Configure the exception mock to work with the Panel's default exception
* handler actions.
*
* @param null $response
*/
protected function configureExceptionMock(string $abstract = RequestException::class, $response = null)
protected function configureExceptionMock(string $abstract = RequestException::class, $response = null): void
{
$this->getExceptionMock($abstract)->shouldReceive('getResponse')->andReturn(value($response));
}

View file

@ -1,11 +1,4 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Tests\Traits;
@ -17,15 +10,13 @@ trait MocksUuids
{
/**
* The known UUID string.
*
* @var string
*/
protected $knownUuid = 'ffb5c3a6-ab17-43ab-97f0-8ff37ccd7f5f';
protected string $knownUuid = 'ffb5c3a6-ab17-43ab-97f0-8ff37ccd7f5f';
/**
* Setup a factory mock to produce the same UUID whenever called.
*/
public function setKnownUuidFactory()
public function setKnownUuidFactory(): void
{
$uuid = Uuid::fromString($this->getKnownUuid());
$factoryMock = m::mock(UuidFactory::class . '[uuid4]', [

View file

@ -18,10 +18,8 @@ class IsDigitTest extends TestCase
/**
* Provide data to test against the helper function.
*
* @return array
*/
public function helperDataProvider()
public function helperDataProvider(): array
{
return [
[true, false],

View file

@ -21,7 +21,7 @@ class AuthenticateUserTest extends MiddlewareTestCase
}
/**
* Test that a non-admin user results an an exception.
* Test that a non-admin user results in an exception.
*/
public function testNonAdminUser()
{

View file

@ -3,6 +3,7 @@
namespace Pterodactyl\Tests\Unit\Http\Middleware\Api\Daemon;
use Mockery as m;
use Mockery\MockInterface;
use Pterodactyl\Models\Node;
use Illuminate\Contracts\Encryption\Encrypter;
use Pterodactyl\Repositories\Eloquent\NodeRepository;
@ -15,15 +16,9 @@ use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
class DaemonAuthenticateTest extends MiddlewareTestCase
{
/**
* @var \Mockery\MockInterface
*/
private $repository;
private MockInterface $encrypter;
/**
* @var \Mockery\MockInterface
*/
private $encrypter;
private MockInterface $repository;
/**
* Setup tests.

View file

@ -3,16 +3,14 @@
namespace Pterodactyl\Tests\Unit\Http\Middleware;
use Mockery as m;
use Mockery\MockInterface;
use Pterodactyl\Models\User;
use Illuminate\Foundation\Application;
use Pterodactyl\Http\Middleware\LanguageMiddleware;
class LanguageMiddlewareTest extends MiddlewareTestCase
{
/**
* @var \Illuminate\Foundation\Application|\Mockery\Mock
*/
private $appMock;
private MockInterface $appMock;
/**
* Setup tests.

View file

@ -3,6 +3,7 @@
namespace Pterodactyl\Tests\Unit\Http\Middleware;
use Mockery as m;
use Mockery\MockInterface;
use Pterodactyl\Models\Node;
use Illuminate\Http\Response;
use Pterodactyl\Models\Server;
@ -11,10 +12,7 @@ use Pterodactyl\Http\Middleware\MaintenanceMiddleware;
class MaintenanceMiddlewareTest extends MiddlewareTestCase
{
/**
* @var \Illuminate\Contracts\Routing\ResponseFactory|\Mockery\Mock
*/
private $response;
private MockInterface $response;
/**
* Setup tests.

View file

@ -3,16 +3,14 @@
namespace Pterodactyl\Tests\Unit\Http\Middleware;
use Mockery as m;
use Mockery\MockInterface;
use Illuminate\Auth\AuthManager;
use Illuminate\Http\RedirectResponse;
use Pterodactyl\Http\Middleware\RedirectIfAuthenticated;
class RedirectIfAuthenticatedTest extends MiddlewareTestCase
{
/**
* @var \Illuminate\Auth\AuthManager|\Mockery\Mock
*/
private $authManager;
private MockInterface $authManager;
/**
* Setup tests.