diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2024-10-10 12:40:31 +0200 |
---|---|---|
committer | Côme Chilliet <come.chilliet@nextcloud.com> | 2024-10-15 10:40:25 +0200 |
commit | 1580c8612b01bfa780d1a7372080a27d182fb7dd (patch) | |
tree | b2776d0cd254ac9d6e54828978ce18b702f550d5 /apps/provisioning_api/tests | |
parent | 4ff9b3e0ce53227e2be47c4c2dcb1fdc3e540b5f (diff) | |
download | nextcloud-server-1580c8612b01bfa780d1a7372080a27d182fb7dd.tar.gz nextcloud-server-1580c8612b01bfa780d1a7372080a27d182fb7dd.zip |
chore(apps): Apply new rector configuration to autouse classes
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps/provisioning_api/tests')
4 files changed, 63 insertions, 59 deletions
diff --git a/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php b/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php index f878b6b73d0..41739b6283f 100644 --- a/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php +++ b/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php @@ -17,6 +17,7 @@ use OCP\IL10N; use OCP\IRequest; use OCP\IUser; use OCP\IUserSession; +use OCP\Server; use OCP\Settings\IManager; use PHPUnit\Framework\MockObject\MockObject; use Test\TestCase; @@ -45,7 +46,7 @@ class AppConfigControllerTest extends TestCase { $this->l10n = $this->createMock(IL10N::class); $this->settingManager = $this->createMock(IManager::class); $this->groupManager = $this->createMock(IGroupManager::class); - $this->appManager = \OCP\Server::get(IAppManager::class); + $this->appManager = Server::get(IAppManager::class); } /** diff --git a/apps/provisioning_api/tests/Controller/AppsControllerTest.php b/apps/provisioning_api/tests/Controller/AppsControllerTest.php index 9c815a52178..51980ce7ed2 100644 --- a/apps/provisioning_api/tests/Controller/AppsControllerTest.php +++ b/apps/provisioning_api/tests/Controller/AppsControllerTest.php @@ -8,7 +8,9 @@ namespace OCA\Provisioning_API\Tests\Controller; use OCA\Provisioning_API\Controller\AppsController; +use OCA\Provisioning_API\Tests\TestCase; use OCP\App\IAppManager; +use OCP\AppFramework\OCS\OCSException; use OCP\IRequest; use OCP\IUserSession; @@ -19,7 +21,7 @@ use OCP\IUserSession; * * @package OCA\Provisioning_API\Tests */ -class AppsControllerTest extends \OCA\Provisioning_API\Tests\TestCase { +class AppsControllerTest extends TestCase { /** @var IAppManager */ private $appManager; /** @var AppsController */ @@ -57,7 +59,7 @@ class AppsControllerTest extends \OCA\Provisioning_API\Tests\TestCase { public function testGetAppInfoOnBadAppID(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionCode(998); $this->api->getAppInfo('not_provisioning_api'); @@ -94,7 +96,7 @@ class AppsControllerTest extends \OCA\Provisioning_API\Tests\TestCase { public function testGetAppsInvalidFilter(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionCode(101); $this->api->getApps('foo'); diff --git a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php index 5ddf5d7eff8..dc5e96b3ef0 100644 --- a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php +++ b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php @@ -11,6 +11,7 @@ use OC\Group\Manager; use OC\User\NoUserException; use OCA\Provisioning_API\Controller\GroupsController; use OCP\Accounts\IAccountManager; +use OCP\AppFramework\OCS\OCSException; use OCP\Group\ISubAdmin; use OCP\IConfig; use OCP\IRequest; @@ -255,7 +256,7 @@ class GroupsControllerTest extends \Test\TestCase { public function testGetGroupAsIrrelevantSubadmin(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionCode(403); $group = $this->createGroup('group'); @@ -300,7 +301,7 @@ class GroupsControllerTest extends \Test\TestCase { public function testGetGroupNonExisting(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionMessage('The requested group could not be found'); $this->expectExceptionCode(404); @@ -311,7 +312,7 @@ class GroupsControllerTest extends \Test\TestCase { public function testGetSubAdminsOfGroupsNotExists(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionMessage('Group does not exist'); $this->expectExceptionCode(101); @@ -358,7 +359,7 @@ class GroupsControllerTest extends \Test\TestCase { public function testAddGroupEmptyGroup(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionMessage('Invalid group name'); $this->expectExceptionCode(101); @@ -367,7 +368,7 @@ class GroupsControllerTest extends \Test\TestCase { public function testAddGroupExistingGroup(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionCode(102); $this->groupManager @@ -412,7 +413,7 @@ class GroupsControllerTest extends \Test\TestCase { public function testDeleteGroupNonExisting(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionCode(101); $this->api->deleteGroup('NonExistingGroup'); @@ -420,7 +421,7 @@ class GroupsControllerTest extends \Test\TestCase { public function testDeleteAdminGroup(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionCode(102); $this->groupManager diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php index 2ccb1196fbb..2d339205fae 100644 --- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php +++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php @@ -221,7 +221,7 @@ class UsersControllerTest extends TestCase { public function testAddUserAlreadyExisting(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionCode(102); $this->userManager @@ -255,7 +255,7 @@ class UsersControllerTest extends TestCase { public function testAddUserNonExistingGroup(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionMessage('Group NonExistingGroup does not exist'); $this->expectExceptionCode(104); @@ -291,7 +291,7 @@ class UsersControllerTest extends TestCase { public function testAddUserExistingGroupNonExistingGroup(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionMessage('Group NonExistingGroup does not exist'); $this->expectExceptionCode(104); @@ -533,7 +533,7 @@ class UsersControllerTest extends TestCase { public function testAddUserFailedToGenerateUserID(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionMessage('Could not create non-existing user ID'); $this->expectExceptionCode(111); @@ -576,7 +576,7 @@ class UsersControllerTest extends TestCase { public function testAddUserEmailRequired(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionMessage('Required email address was not provided'); $this->expectExceptionCode(110); @@ -683,7 +683,7 @@ class UsersControllerTest extends TestCase { public function testAddUserUnsuccessful(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionMessage('Bad request'); $this->expectExceptionCode(101); @@ -730,7 +730,7 @@ class UsersControllerTest extends TestCase { public function testAddUserAsSubAdminNoGroup(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionMessage('No group specified (required for sub-admins)'); $this->expectExceptionCode(106); @@ -763,7 +763,7 @@ class UsersControllerTest extends TestCase { public function testAddUserAsSubAdminValidGroupNotSubAdmin(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionMessage('Insufficient privileges for group ExistingGroup'); $this->expectExceptionCode(105); @@ -906,7 +906,7 @@ class UsersControllerTest extends TestCase { public function testGetUserTargetDoesNotExist(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionMessage('User does not exist'); $this->expectExceptionCode(404); @@ -1218,7 +1218,7 @@ class UsersControllerTest extends TestCase { public function testGetUserDataAsSubAdminAndUserIsNotAccessible(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionCode(998); $loggedInUser = $this->getMockBuilder(IUser::class) @@ -1681,7 +1681,7 @@ class UsersControllerTest extends TestCase { } public function testEditUserRegularUserSelfEditChangeEmailInvalid(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionCode(101); $loggedInUser = $this->getMockBuilder(IUser::class) @@ -1915,7 +1915,7 @@ class UsersControllerTest extends TestCase { public function testEditUserRegularUserSelfEditChangeQuota(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionCode(113); $loggedInUser = $this->getMockBuilder(IUser::class) @@ -2001,7 +2001,7 @@ class UsersControllerTest extends TestCase { public function testEditUserAdminUserSelfEditChangeInvalidQuota(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionMessage('Invalid quota value: ABC'); $this->expectExceptionCode(101); @@ -2152,7 +2152,7 @@ class UsersControllerTest extends TestCase { * @dataProvider dataEditUserSelfEditChangeLanguageButForced */ public function testEditUserSelfEditChangeLanguageButForced($forced): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->config->expects($this->any()) ->method('getSystemValue') @@ -2248,7 +2248,7 @@ class UsersControllerTest extends TestCase { * @dataProvider dataEditUserSelfEditChangeLanguageButForced */ public function testEditUserAdminEditChangeLanguageInvalidLanguage(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->l10nFactory->expects($this->once()) @@ -2352,7 +2352,7 @@ class UsersControllerTest extends TestCase { public function testEditUserSubadminUserInaccessible(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionCode(998); $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); @@ -2392,7 +2392,7 @@ class UsersControllerTest extends TestCase { public function testDeleteUserNotExistingUser(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionCode(998); $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); @@ -2415,7 +2415,7 @@ class UsersControllerTest extends TestCase { public function testDeleteUserSelf(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionCode(101); $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); @@ -2476,7 +2476,7 @@ class UsersControllerTest extends TestCase { public function testDeleteUnsuccessfulUserAsAdmin(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionCode(101); $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); @@ -2557,7 +2557,7 @@ class UsersControllerTest extends TestCase { public function testDeleteUnsuccessfulUserAsSubadmin(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionCode(101); $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); @@ -2605,7 +2605,7 @@ class UsersControllerTest extends TestCase { public function testDeleteUserAsSubAdminAndUserIsNotAccessible(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionCode(998); $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); @@ -2649,7 +2649,7 @@ class UsersControllerTest extends TestCase { public function testGetUsersGroupsTargetUserNotExisting(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionCode(998); $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); @@ -2786,7 +2786,7 @@ class UsersControllerTest extends TestCase { public function testGetUsersGroupsForSubAdminUserAndUserIsInaccessible(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionCode(998); $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); @@ -2835,7 +2835,7 @@ class UsersControllerTest extends TestCase { public function testAddToGroupWithTargetGroupNotExisting(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionCode(102); $this->groupManager->expects($this->once()) @@ -2848,7 +2848,7 @@ class UsersControllerTest extends TestCase { public function testAddToGroupWithNoGroupSpecified(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionCode(101); $this->api->addToGroup('TargetUser'); @@ -2856,7 +2856,7 @@ class UsersControllerTest extends TestCase { public function testAddToGroupWithTargetUserNotExisting(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionCode(103); $targetGroup = $this->createMock(IGroup::class); @@ -2870,7 +2870,7 @@ class UsersControllerTest extends TestCase { public function testAddToGroupNoSubadmin(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionCode(104); $targetUser = $this->createMock(IUser::class); @@ -3004,7 +3004,7 @@ class UsersControllerTest extends TestCase { public function testRemoveFromGroupWithNoTargetGroup(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionCode(101); $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); @@ -3018,7 +3018,7 @@ class UsersControllerTest extends TestCase { public function testRemoveFromGroupWithEmptyTargetGroup(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionCode(101); $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); @@ -3032,7 +3032,7 @@ class UsersControllerTest extends TestCase { public function testRemoveFromGroupWithNotExistingTargetGroup(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionCode(102); $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); @@ -3051,7 +3051,7 @@ class UsersControllerTest extends TestCase { public function testRemoveFromGroupWithNotExistingTargetUser(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionCode(103); $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); @@ -3076,7 +3076,7 @@ class UsersControllerTest extends TestCase { public function testRemoveFromGroupWithoutPermission(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionCode(104); $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); @@ -3117,7 +3117,7 @@ class UsersControllerTest extends TestCase { public function testRemoveFromGroupAsAdminFromAdmin(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionMessage('Cannot remove yourself from the admin group'); $this->expectExceptionCode(105); @@ -3167,7 +3167,7 @@ class UsersControllerTest extends TestCase { public function testRemoveFromGroupAsSubAdminFromSubAdmin(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionMessage('Cannot remove yourself from this group as you are a sub-admin'); $this->expectExceptionCode(105); @@ -3222,7 +3222,7 @@ class UsersControllerTest extends TestCase { public function testRemoveFromGroupAsSubAdminFromLastSubAdminGroup(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionMessage('Not viable to remove user from the last group you are sub-admin of'); $this->expectExceptionCode(105); @@ -3325,7 +3325,7 @@ class UsersControllerTest extends TestCase { public function testAddSubAdminWithNotExistingTargetUser(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionMessage('User does not exist'); $this->expectExceptionCode(101); @@ -3340,7 +3340,7 @@ class UsersControllerTest extends TestCase { public function testAddSubAdminWithNotExistingTargetGroup(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionMessage('Group does not exist'); $this->expectExceptionCode(102); @@ -3362,7 +3362,7 @@ class UsersControllerTest extends TestCase { public function testAddSubAdminToAdminGroup(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionMessage('Cannot create sub-admins for admin group'); $this->expectExceptionCode(103); @@ -3448,7 +3448,7 @@ class UsersControllerTest extends TestCase { public function testRemoveSubAdminNotExistingTargetUser(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionMessage('User does not exist'); $this->expectExceptionCode(101); @@ -3463,7 +3463,7 @@ class UsersControllerTest extends TestCase { public function testRemoveSubAdminNotExistingTargetGroup(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionMessage('Group does not exist'); $this->expectExceptionCode(101); @@ -3485,7 +3485,7 @@ class UsersControllerTest extends TestCase { public function testRemoveSubAdminFromNotASubadmin(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionMessage('User is not a sub-admin of this group'); $this->expectExceptionCode(102); @@ -3550,7 +3550,7 @@ class UsersControllerTest extends TestCase { public function testGetUserSubAdminGroupsNotExistingTargetUser(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionMessage('User does not exist'); $this->expectExceptionCode(404); @@ -3723,7 +3723,7 @@ class UsersControllerTest extends TestCase { public function testGetCurrentUserNotLoggedIn(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->userSession->expects($this->once())->method('getUser') @@ -3800,7 +3800,7 @@ class UsersControllerTest extends TestCase { public function testResendWelcomeMessageWithNotExistingTargetUser(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionCode(998); $this->userManager @@ -3814,7 +3814,7 @@ class UsersControllerTest extends TestCase { public function testResendWelcomeMessageAsSubAdminAndUserIsNotAccessible(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionCode(998); $loggedInUser = $this->getMockBuilder(IUser::class) @@ -3859,7 +3859,7 @@ class UsersControllerTest extends TestCase { public function testResendWelcomeMessageNoEmail(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionMessage('Email address not available'); $this->expectExceptionCode(101); @@ -3904,7 +3904,7 @@ class UsersControllerTest extends TestCase { public function testResendWelcomeMessageNullEmail(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionMessage('Email address not available'); $this->expectExceptionCode(101); @@ -4051,7 +4051,7 @@ class UsersControllerTest extends TestCase { public function testResendWelcomeMessageFailed(): void { - $this->expectException(\OCP\AppFramework\OCS\OCSException::class); + $this->expectException(OCSException::class); $this->expectExceptionMessage('Sending email failed'); $this->expectExceptionCode(102); |