From 7df927c18e312d5ec28578fcdc8ed389e07aa835 Mon Sep 17 00:00:00 2001 From: Matthew Penner Date: Mon, 21 Oct 2024 17:49:40 -0600 Subject: [PATCH] fix: tests Signed-off-by: Matthew Penner --- .github/workflows/ci.yaml | 1 - .../Application/Users/UserControllerTest.php | 3 +- .../Api/Client/ApiKeyControllerTest.php | 3 +- .../Api/Client/ClientControllerTest.php | 3 +- .../AllocationAuthorizationTest.php | 4 +- .../Allocation/CreateNewAllocationTest.php | 3 +- .../Allocation/DeleteAllocationTest.php | 3 +- .../Server/Backup/BackupAuthorizationTest.php | 4 +- .../Database/DatabaseAuthorizationTest.php | 4 +- .../NetworkAllocationControllerTest.php | 7 +-- .../Api/Client/Server/PowerControllerTest.php | 6 +- .../Schedule/CreateServerScheduleTest.php | 3 +- .../Schedule/DeleteServerScheduleTest.php | 3 +- .../Server/Schedule/ExecuteScheduleTest.php | 3 +- .../Schedule/GetServerSchedulesTest.php | 3 +- .../Schedule/ScheduleAuthorizationTest.php | 3 +- .../Schedule/UpdateServerScheduleTest.php | 3 +- .../CreateServerScheduleTaskTest.php | 3 +- .../Client/Server/SettingsControllerTest.php | 6 +- .../Startup/GetStartupAndVariablesTest.php | 3 +- .../Startup/UpdateStartupVariableTest.php | 6 +- .../Subuser/CreateServerSubuserTest.php | 3 +- .../Subuser/SubuserAuthorizationTest.php | 3 +- .../SftpAuthenticationControllerTest.php | 10 +--- .../Controllers/Admin/UserControllerTest.php | 59 ------------------- .../Jobs/Schedule/RunTaskJobTest.php | 8 +-- .../DatabaseManagementServiceTest.php | 3 +- .../DeployServerDatabaseServiceTest.php | 3 +- .../Schedules/ProcessScheduleServiceTest.php | 3 +- .../Helpers/EnvironmentWriterTraitTest.php | 4 +- tests/Unit/Helpers/IsDigitTest.php | 3 +- .../Api/Daemon/DaemonAuthenticateTest.php | 3 +- tests/Unit/Rules/UsernameTest.php | 6 +- tests/Unit/Services/Acl/Api/AdminAclTest.php | 3 +- 34 files changed, 40 insertions(+), 148 deletions(-) delete mode 100644 tests/Integration/Http/Controllers/Admin/UserControllerTest.php diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b9eb3e6bf8..e0375787c3 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -34,7 +34,6 @@ jobs: MYSQL_DATABASE: testing ports: - 3306 - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 steps: - name: Code Checkout uses: actions/checkout@v4 diff --git a/tests/Integration/Api/Application/Users/UserControllerTest.php b/tests/Integration/Api/Application/Users/UserControllerTest.php index 04709e55f2..a2512094b4 100644 --- a/tests/Integration/Api/Application/Users/UserControllerTest.php +++ b/tests/Integration/Api/Application/Users/UserControllerTest.php @@ -279,9 +279,8 @@ public function testDeleteUser() /** * Test that an API key without write permissions cannot create, update, or * delete a user model. - * - * @dataProvider userWriteEndpointsDataProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('userWriteEndpointsDataProvider')] public function testApiKeyWithoutWritePermissions(string $method, string $url) { $this->createNewDefaultApiKey($this->getApiUser(), ['r_users' => AdminAcl::READ]); diff --git a/tests/Integration/Api/Client/ApiKeyControllerTest.php b/tests/Integration/Api/Client/ApiKeyControllerTest.php index 39b2055eba..fe662caf8f 100644 --- a/tests/Integration/Api/Client/ApiKeyControllerTest.php +++ b/tests/Integration/Api/Client/ApiKeyControllerTest.php @@ -44,9 +44,8 @@ public function testApiKeysAreReturned() * Test that an API key can be created for the client account. This also checks that the * API key secret is returned as metadata in the response since it will not be returned * after that point. - * - * @dataProvider validIPAddressDataProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('validIPAddressDataProvider')] public function testApiKeyCanBeCreatedForAccount(array $data) { /** @var \Pterodactyl\Models\User $user */ diff --git a/tests/Integration/Api/Client/ClientControllerTest.php b/tests/Integration/Api/Client/ClientControllerTest.php index 3a080e23e4..dd6e98dc9f 100644 --- a/tests/Integration/Api/Client/ClientControllerTest.php +++ b/tests/Integration/Api/Client/ClientControllerTest.php @@ -285,9 +285,8 @@ public function testAllServersAreReturnedToAdmin() /** * 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. - * - * @dataProvider filterTypeDataProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('filterTypeDataProvider')] public function testNoServersAreReturnedIfAdminFilterIsPassedByRegularUser(string $type) { /** @var \Pterodactyl\Models\User[] $users */ diff --git a/tests/Integration/Api/Client/Server/Allocation/AllocationAuthorizationTest.php b/tests/Integration/Api/Client/Server/Allocation/AllocationAuthorizationTest.php index 9c5eebd107..c5d6ac127c 100644 --- a/tests/Integration/Api/Client/Server/Allocation/AllocationAuthorizationTest.php +++ b/tests/Integration/Api/Client/Server/Allocation/AllocationAuthorizationTest.php @@ -8,9 +8,7 @@ class AllocationAuthorizationTest extends ClientApiIntegrationTestCase { - /** - * @dataProvider methodDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('methodDataProvider')] public function testAccessToAServersAllocationsIsRestrictedProperly(string $method, string $endpoint) { // The API $user is the owner of $server1. diff --git a/tests/Integration/Api/Client/Server/Allocation/CreateNewAllocationTest.php b/tests/Integration/Api/Client/Server/Allocation/CreateNewAllocationTest.php index 8022fb1e44..61d93a62aa 100644 --- a/tests/Integration/Api/Client/Server/Allocation/CreateNewAllocationTest.php +++ b/tests/Integration/Api/Client/Server/Allocation/CreateNewAllocationTest.php @@ -23,9 +23,8 @@ public function setUp(): void /** * Tests that a new allocation can be properly assigned to a server. - * - * @dataProvider permissionDataProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('permissionDataProvider')] public function testNewAllocationCanBeAssignedToServer(array $permission) { /** @var \Pterodactyl\Models\Server $server */ diff --git a/tests/Integration/Api/Client/Server/Allocation/DeleteAllocationTest.php b/tests/Integration/Api/Client/Server/Allocation/DeleteAllocationTest.php index 7d4737b757..d50e10190b 100644 --- a/tests/Integration/Api/Client/Server/Allocation/DeleteAllocationTest.php +++ b/tests/Integration/Api/Client/Server/Allocation/DeleteAllocationTest.php @@ -12,9 +12,8 @@ class DeleteAllocationTest extends ClientApiIntegrationTestCase /** * Test that an allocation is deleted from the server and the notes are properly reset * to an empty value on assignment. - * - * @dataProvider permissionDataProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('permissionDataProvider')] public function testAllocationCanBeDeletedFromServer(array $permission) { /** @var \Pterodactyl\Models\Server $server */ diff --git a/tests/Integration/Api/Client/Server/Backup/BackupAuthorizationTest.php b/tests/Integration/Api/Client/Server/Backup/BackupAuthorizationTest.php index 20d9e13a76..33fde157c6 100644 --- a/tests/Integration/Api/Client/Server/Backup/BackupAuthorizationTest.php +++ b/tests/Integration/Api/Client/Server/Backup/BackupAuthorizationTest.php @@ -10,9 +10,7 @@ class BackupAuthorizationTest extends ClientApiIntegrationTestCase { - /** - * @dataProvider methodDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('methodDataProvider')] public function testAccessToAServersBackupIsRestrictedProperly(string $method, string $endpoint) { // The API $user is the owner of $server1. diff --git a/tests/Integration/Api/Client/Server/Database/DatabaseAuthorizationTest.php b/tests/Integration/Api/Client/Server/Database/DatabaseAuthorizationTest.php index 2ea709ce51..c31aed6e29 100644 --- a/tests/Integration/Api/Client/Server/Database/DatabaseAuthorizationTest.php +++ b/tests/Integration/Api/Client/Server/Database/DatabaseAuthorizationTest.php @@ -12,9 +12,7 @@ class DatabaseAuthorizationTest extends ClientApiIntegrationTestCase { - /** - * @dataProvider methodDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('methodDataProvider')] public function testAccessToAServersDatabasesIsRestrictedProperly(string $method, string $endpoint) { // The API $user is the owner of $server1. diff --git a/tests/Integration/Api/Client/Server/NetworkAllocationControllerTest.php b/tests/Integration/Api/Client/Server/NetworkAllocationControllerTest.php index b19be99ccf..0fc9a865b3 100644 --- a/tests/Integration/Api/Client/Server/NetworkAllocationControllerTest.php +++ b/tests/Integration/Api/Client/Server/NetworkAllocationControllerTest.php @@ -48,9 +48,8 @@ public function testServerAllocationsAreNotReturnedWithoutPermission() /** * Tests that notes on an allocation can be set correctly. - * - * @dataProvider updatePermissionsDataProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('updatePermissionsDataProvider')] public function testAllocationNotesCanBeUpdated(array $permissions) { [$user, $server] = $this->generateTestAccount($permissions); @@ -96,9 +95,7 @@ public function testAllocationNotesCannotBeUpdatedByInvalidUsers() $this->actingAs($user)->postJson($this->link($server->allocation))->assertForbidden(); } - /** - * @dataProvider updatePermissionsDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('updatePermissionsDataProvider')] public function testPrimaryAllocationCanBeModified(array $permissions) { [$user, $server] = $this->generateTestAccount($permissions); diff --git a/tests/Integration/Api/Client/Server/PowerControllerTest.php b/tests/Integration/Api/Client/Server/PowerControllerTest.php index f31244948e..54daa0e604 100644 --- a/tests/Integration/Api/Client/Server/PowerControllerTest.php +++ b/tests/Integration/Api/Client/Server/PowerControllerTest.php @@ -15,9 +15,8 @@ class PowerControllerTest extends ClientApiIntegrationTestCase * the command to the server. * * @param string[] $permissions - * - * @dataProvider invalidPermissionDataProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('invalidPermissionDataProvider')] public function testSubuserWithoutPermissionsReceivesError(string $action, array $permissions) { [$user, $server] = $this->generateTestAccount($permissions); @@ -45,9 +44,8 @@ public function testInvalidPowerSignalResultsInError() /** * Test that sending a valid power actions works. - * - * @dataProvider validPowerActionDataProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('validPowerActionDataProvider')] public function testActionCanBeSentToServer(string $action, string $permission) { $service = \Mockery::mock(DaemonPowerRepository::class); diff --git a/tests/Integration/Api/Client/Server/Schedule/CreateServerScheduleTest.php b/tests/Integration/Api/Client/Server/Schedule/CreateServerScheduleTest.php index f72ef09f57..868741e3a8 100644 --- a/tests/Integration/Api/Client/Server/Schedule/CreateServerScheduleTest.php +++ b/tests/Integration/Api/Client/Server/Schedule/CreateServerScheduleTest.php @@ -11,9 +11,8 @@ class CreateServerScheduleTest extends ClientApiIntegrationTestCase { /** * Test that a schedule can be created for the server. - * - * @dataProvider permissionsDataProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('permissionsDataProvider')] public function testScheduleCanBeCreatedForServer(array $permissions) { [$user, $server] = $this->generateTestAccount($permissions); diff --git a/tests/Integration/Api/Client/Server/Schedule/DeleteServerScheduleTest.php b/tests/Integration/Api/Client/Server/Schedule/DeleteServerScheduleTest.php index d444470256..c204ff4f54 100644 --- a/tests/Integration/Api/Client/Server/Schedule/DeleteServerScheduleTest.php +++ b/tests/Integration/Api/Client/Server/Schedule/DeleteServerScheduleTest.php @@ -12,9 +12,8 @@ class DeleteServerScheduleTest extends ClientApiIntegrationTestCase { /** * Test that a schedule can be deleted from the system. - * - * @dataProvider permissionsDataProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('permissionsDataProvider')] public function testScheduleCanBeDeleted(array $permissions) { [$user, $server] = $this->generateTestAccount($permissions); diff --git a/tests/Integration/Api/Client/Server/Schedule/ExecuteScheduleTest.php b/tests/Integration/Api/Client/Server/Schedule/ExecuteScheduleTest.php index 7ca3552995..cb21fd2d04 100644 --- a/tests/Integration/Api/Client/Server/Schedule/ExecuteScheduleTest.php +++ b/tests/Integration/Api/Client/Server/Schedule/ExecuteScheduleTest.php @@ -14,9 +14,8 @@ class ExecuteScheduleTest extends ClientApiIntegrationTestCase { /** * Test that a schedule can be executed and is updated in the database correctly. - * - * @dataProvider permissionsDataProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('permissionsDataProvider')] public function testScheduleIsExecutedRightAway(array $permissions) { [$user, $server] = $this->generateTestAccount($permissions); diff --git a/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php b/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php index 483c7ae42f..c88186c5b4 100644 --- a/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php +++ b/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php @@ -22,9 +22,8 @@ protected function tearDown(): void /** * Test that schedules for a server are returned. - * - * @dataProvider permissionsDataProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('permissionsDataProvider')] public function testServerSchedulesAreReturned(array $permissions, bool $individual) { [$user, $server] = $this->generateTestAccount($permissions); diff --git a/tests/Integration/Api/Client/Server/Schedule/ScheduleAuthorizationTest.php b/tests/Integration/Api/Client/Server/Schedule/ScheduleAuthorizationTest.php index bf5b8d729d..26a83de4c2 100644 --- a/tests/Integration/Api/Client/Server/Schedule/ScheduleAuthorizationTest.php +++ b/tests/Integration/Api/Client/Server/Schedule/ScheduleAuthorizationTest.php @@ -16,9 +16,8 @@ class ScheduleAuthorizationTest extends ClientApiIntegrationTestCase * * The comments within the test code itself are better at explaining exactly what is * being tested and protected against. - * - * @dataProvider methodDataProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('methodDataProvider')] public function testAccessToAServersSchedulesIsRestrictedProperly(string $method, string $endpoint) { // The API $user is the owner of $server1. diff --git a/tests/Integration/Api/Client/Server/Schedule/UpdateServerScheduleTest.php b/tests/Integration/Api/Client/Server/Schedule/UpdateServerScheduleTest.php index 23a054b34d..c5a70f320b 100644 --- a/tests/Integration/Api/Client/Server/Schedule/UpdateServerScheduleTest.php +++ b/tests/Integration/Api/Client/Server/Schedule/UpdateServerScheduleTest.php @@ -24,9 +24,8 @@ class UpdateServerScheduleTest extends ClientApiIntegrationTestCase /** * Test that a schedule can be updated. - * - * @dataProvider permissionsDataProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('permissionsDataProvider')] public function testScheduleCanBeUpdated(array $permissions) { [$user, $server] = $this->generateTestAccount($permissions); diff --git a/tests/Integration/Api/Client/Server/ScheduleTask/CreateServerScheduleTaskTest.php b/tests/Integration/Api/Client/Server/ScheduleTask/CreateServerScheduleTaskTest.php index 736344a689..05646495fe 100644 --- a/tests/Integration/Api/Client/Server/ScheduleTask/CreateServerScheduleTaskTest.php +++ b/tests/Integration/Api/Client/Server/ScheduleTask/CreateServerScheduleTaskTest.php @@ -12,9 +12,8 @@ class CreateServerScheduleTaskTest extends ClientApiIntegrationTestCase { /** * Test that a task can be created. - * - * @dataProvider permissionsDataProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('permissionsDataProvider')] public function testTaskCanBeCreated(array $permissions) { [$user, $server] = $this->generateTestAccount($permissions); diff --git a/tests/Integration/Api/Client/Server/SettingsControllerTest.php b/tests/Integration/Api/Client/Server/SettingsControllerTest.php index fcc7a5ce7e..d6b831f335 100644 --- a/tests/Integration/Api/Client/Server/SettingsControllerTest.php +++ b/tests/Integration/Api/Client/Server/SettingsControllerTest.php @@ -12,9 +12,8 @@ class SettingsControllerTest extends ClientApiIntegrationTestCase { /** * Test that the server's name can be changed. - * - * @dataProvider renamePermissionsDataProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('renamePermissionsDataProvider')] public function testServerNameCanBeChanged(array $permissions) { /** @var \Pterodactyl\Models\Server $server */ @@ -68,9 +67,8 @@ public function testSubuserCannotChangeServerNameWithoutPermission() /** * Test that a server can be reinstalled. Honestly this test doesn't do much of anything other * than make sure the endpoint works since. - * - * @dataProvider reinstallPermissionsDataProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('reinstallPermissionsDataProvider')] public function testServerCanBeReinstalled(array $permissions) { /** @var \Pterodactyl\Models\Server $server */ diff --git a/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php b/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php index 04150e07f6..493cc6a0a6 100644 --- a/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php +++ b/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php @@ -12,9 +12,8 @@ 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). - * - * @dataProvider permissionsDataProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('permissionsDataProvider')] public function testStartupVariablesAreReturnedForServer(array $permissions) { /** @var \Pterodactyl\Models\Server $server */ diff --git a/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php b/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php index fed4d1377b..cb67cb0952 100644 --- a/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php +++ b/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php @@ -12,9 +12,8 @@ class UpdateStartupVariableTest extends ClientApiIntegrationTestCase { /** * Test that a startup variable can be edited successfully for a server. - * - * @dataProvider permissionsDataProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('permissionsDataProvider')] public function testStartupVariableCanBeUpdated(array $permissions) { /** @var \Pterodactyl\Models\Server $server */ @@ -47,9 +46,8 @@ public function testStartupVariableCanBeUpdated(array $permissions) /** * Test that variables that are either not user_viewable, or not user_editable, cannot be * updated via this endpoint. - * - * @dataProvider permissionsDataProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('permissionsDataProvider')] public function testStartupVariableCannotBeUpdatedIfNotUserViewableOrEditable(array $permissions) { /** @var \Pterodactyl\Models\Server $server */ diff --git a/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php b/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php index c12ede61ae..512a7721bb 100644 --- a/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php +++ b/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php @@ -16,9 +16,8 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase /** * Test that a subuser can be created for a server. - * - * @dataProvider permissionsDataProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('permissionsDataProvider')] public function testSubuserCanBeCreated(array $permissions) { [$user, $server] = $this->generateTestAccount($permissions); diff --git a/tests/Integration/Api/Client/Server/Subuser/SubuserAuthorizationTest.php b/tests/Integration/Api/Client/Server/Subuser/SubuserAuthorizationTest.php index c7935aa341..7b24b0022f 100644 --- a/tests/Integration/Api/Client/Server/Subuser/SubuserAuthorizationTest.php +++ b/tests/Integration/Api/Client/Server/Subuser/SubuserAuthorizationTest.php @@ -11,9 +11,8 @@ class SubuserAuthorizationTest extends ClientApiIntegrationTestCase { /** * Test that mismatched subusers are not accessible to a server. - * - * @dataProvider methodDataProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('methodDataProvider')] public function testUserCannotAccessResourceBelongingToOtherServers(string $method) { // Generic subuser, the specific resource we're trying to access. diff --git a/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php b/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php index 7c4803baee..7e8f1f208e 100644 --- a/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php +++ b/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php @@ -94,9 +94,8 @@ public function testPasswordIsValidatedCorrectly() /** * Test that providing an invalid key and/or invalid username triggers the throttle on * the endpoint. - * - * @dataProvider authorizationTypeDataProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('authorizationTypeDataProvider')] public function testUserIsThrottledIfInvalidCredentialsAreProvided() { for ($i = 0; $i <= 10; ++$i) { @@ -128,9 +127,8 @@ public function testUserIsNotThrottledIfNoPublicKeyMatches() /** * Test that a request is rejected if the credentials are valid but the username indicates * a server on a different node. - * - * @dataProvider authorizationTypeDataProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('authorizationTypeDataProvider')] public function testRequestIsRejectedIfServerBelongsToDifferentNode(string $type) { $node2 = $this->createServerModel()->node; @@ -165,9 +163,7 @@ public function testRequestIsDeniedIfUserLacksSftpPermission() ->assertJsonPath('errors.0.detail', 'You do not have permission to access SFTP for this server.'); } - /** - * @dataProvider serverStateDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('serverStateDataProvider')] public function testInvalidServerStateReturnsConflictError(string $status) { $this->server->update(['status' => $status]); diff --git a/tests/Integration/Http/Controllers/Admin/UserControllerTest.php b/tests/Integration/Http/Controllers/Admin/UserControllerTest.php deleted file mode 100644 index 34cf9f938d..0000000000 --- a/tests/Integration/Http/Controllers/Admin/UserControllerTest.php +++ /dev/null @@ -1,59 +0,0 @@ -create(['username' => $unique . '_1']), - User::factory()->create(['username' => $unique . '_2']), - ]; - - $servers = [ - $this->createServerModel(['owner_id' => $users[0]->id]), - $this->createServerModel(['owner_id' => $users[0]->id]), - $this->createServerModel(['owner_id' => $users[0]->id]), - $this->createServerModel(['owner_id' => $users[1]->id]), - ]; - - Subuser::query()->forceCreate(['server_id' => $servers[0]->id, 'user_id' => $users[1]->id]); - Subuser::query()->forceCreate(['server_id' => $servers[1]->id, 'user_id' => $users[1]->id]); - - /** @var \Pterodactyl\Http\Controllers\Admin\UserController $controller */ - $controller = $this->app->make(UserController::class); - - $request = Request::create('/admin/users?filter[username]=' . $unique); - $this->app->instance(Request::class, $request); - - $data = $controller->index($request)->getData(); - $this->assertArrayHasKey('users', $data); - $this->assertInstanceOf(LengthAwarePaginator::class, $data['users']); - - /** @var \Pterodactyl\Models\User[] $response */ - $response = $data['users']->items(); - $this->assertCount(2, $response); - $this->assertInstanceOf(User::class, $response[0]); - $this->assertSame(3, (int) $response[0]->servers_count); - $this->assertSame(0, (int) $response[0]->subuser_of_count); - $this->assertSame(1, (int) $response[1]->servers_count); - $this->assertSame(2, (int) $response[1]->subuser_of_count); - } -} diff --git a/tests/Integration/Jobs/Schedule/RunTaskJobTest.php b/tests/Integration/Jobs/Schedule/RunTaskJobTest.php index c1c3244255..44ce77673f 100644 --- a/tests/Integration/Jobs/Schedule/RunTaskJobTest.php +++ b/tests/Integration/Jobs/Schedule/RunTaskJobTest.php @@ -64,9 +64,7 @@ public function testJobWithInvalidActionThrowsException() Bus::dispatchSync($job); } - /** - * @dataProvider isManualRunDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('isManualRunDataProvider')] public function testJobIsExecuted(bool $isManualRun) { $server = $this->createServerModel(); @@ -105,9 +103,7 @@ public function testJobIsExecuted(bool $isManualRun) $this->assertTrue(CarbonImmutable::now()->isSameAs(\DateTimeInterface::ATOM, $schedule->last_run_at)); } - /** - * @dataProvider isManualRunDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('isManualRunDataProvider')] public function testExceptionDuringRunIsHandledCorrectly(bool $continueOnFailure) { $server = $this->createServerModel(); diff --git a/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php b/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php index b68a3521ea..7ccfb83380 100644 --- a/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php +++ b/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php @@ -69,9 +69,8 @@ public function testDatabaseCannotBeCreatedIfServerHasReachedLimit() /** * Test that a missing or invalid database name format causes an exception to be thrown. - * - * @dataProvider invalidDataDataProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('invalidDataDataProvider')] public function testEmptyDatabaseNameOrInvalidNameTriggersAnException(array $data) { $server = $this->createServerModel(); diff --git a/tests/Integration/Services/Databases/DeployServerDatabaseServiceTest.php b/tests/Integration/Services/Databases/DeployServerDatabaseServiceTest.php index eb8f4dbaa5..f9afd85643 100644 --- a/tests/Integration/Services/Databases/DeployServerDatabaseServiceTest.php +++ b/tests/Integration/Services/Databases/DeployServerDatabaseServiceTest.php @@ -41,9 +41,8 @@ protected function tearDown(): void /** * Test that an error is thrown if either the database name or the remote host are empty. - * - * @dataProvider invalidDataProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('invalidDataProvider')] public function testErrorIsThrownIfDatabaseNameIsEmpty(array $data) { $server = $this->createServerModel(); diff --git a/tests/Integration/Services/Schedules/ProcessScheduleServiceTest.php b/tests/Integration/Services/Schedules/ProcessScheduleServiceTest.php index eaed38a16d..b6d842da8d 100644 --- a/tests/Integration/Services/Schedules/ProcessScheduleServiceTest.php +++ b/tests/Integration/Services/Schedules/ProcessScheduleServiceTest.php @@ -55,9 +55,8 @@ public function testErrorDuringScheduleDataUpdateDoesNotPersistChanges() /** * Test that a job is dispatched as expected using the initial delay. - * - * @dataProvider dispatchNowDataProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('dispatchNowDataProvider')] public function testJobCanBeDispatchedWithExpectedInitialDelay(bool $now) { Bus::fake(); diff --git a/tests/Unit/Helpers/EnvironmentWriterTraitTest.php b/tests/Unit/Helpers/EnvironmentWriterTraitTest.php index 0680da0dbb..588bb8e980 100644 --- a/tests/Unit/Helpers/EnvironmentWriterTraitTest.php +++ b/tests/Unit/Helpers/EnvironmentWriterTraitTest.php @@ -7,9 +7,7 @@ class EnvironmentWriterTraitTest extends TestCase { - /** - * @dataProvider variableDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('variableDataProvider')] public function testVariableIsEscapedProperly($input, $expected) { $output = (new FooClass())->escapeEnvironmentValue($input); diff --git a/tests/Unit/Helpers/IsDigitTest.php b/tests/Unit/Helpers/IsDigitTest.php index af19c732e9..273de64aee 100644 --- a/tests/Unit/Helpers/IsDigitTest.php +++ b/tests/Unit/Helpers/IsDigitTest.php @@ -8,9 +8,8 @@ class IsDigitTest extends TestCase { /** * Test the is_digit helper. - * - * @dataProvider helperDataProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('helperDataProvider')] public function testHelper($value, $response) { $this->assertSame($response, is_digit($value)); diff --git a/tests/Unit/Http/Middleware/Api/Daemon/DaemonAuthenticateTest.php b/tests/Unit/Http/Middleware/Api/Daemon/DaemonAuthenticateTest.php index 84562f6c93..4007935fe3 100644 --- a/tests/Unit/Http/Middleware/Api/Daemon/DaemonAuthenticateTest.php +++ b/tests/Unit/Http/Middleware/Api/Daemon/DaemonAuthenticateTest.php @@ -64,9 +64,8 @@ public function testResponseShouldFailIfNoTokenIsProvided() /** * Test that passing in an invalid node daemon secret will result in a bad request * exception being returned. - * - * @dataProvider badTokenDataProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('badTokenDataProvider')] public function testResponseShouldFailIfTokenFormatIsIncorrect(string $token) { $this->expectException(BadRequestHttpException::class); diff --git a/tests/Unit/Rules/UsernameTest.php b/tests/Unit/Rules/UsernameTest.php index 003e3e8ddf..f01589e959 100644 --- a/tests/Unit/Rules/UsernameTest.php +++ b/tests/Unit/Rules/UsernameTest.php @@ -17,9 +17,8 @@ public function testRuleIsStringable() /** * Test valid usernames. - * - * @dataProvider validUsernameDataProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('validUsernameDataProvider')] public function testValidUsernames(string $username) { $this->assertTrue((new Username())->passes('test', $username), 'Assert username is valid.'); @@ -27,9 +26,8 @@ public function testValidUsernames(string $username) /** * Test invalid usernames return false. - * - * @dataProvider invalidUsernameDataProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('invalidUsernameDataProvider')] public function testInvalidUsernames(string $username) { $this->assertFalse((new Username())->passes('test', $username), 'Assert username is not valid.'); diff --git a/tests/Unit/Services/Acl/Api/AdminAclTest.php b/tests/Unit/Services/Acl/Api/AdminAclTest.php index 3f89659a2d..b135bd92a0 100644 --- a/tests/Unit/Services/Acl/Api/AdminAclTest.php +++ b/tests/Unit/Services/Acl/Api/AdminAclTest.php @@ -10,9 +10,8 @@ class AdminAclTest extends TestCase { /** * Test that permissions return the expects values. - * - * @dataProvider permissionsDataProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('permissionsDataProvider')] public function testPermissions(int $permission, int $check, bool $outcome) { $this->assertSame($outcome, AdminAcl::can($permission, $check));