diff options
Diffstat (limited to 'apps/provisioning_api/tests')
5 files changed, 27 insertions, 61 deletions
diff --git a/apps/provisioning_api/tests/CapabilitiesTest.php b/apps/provisioning_api/tests/CapabilitiesTest.php index 67a0335829c..86d2bb8c4fa 100644 --- a/apps/provisioning_api/tests/CapabilitiesTest.php +++ b/apps/provisioning_api/tests/CapabilitiesTest.php @@ -48,16 +48,14 @@ class CapabilitiesTest extends TestCase { ]; } - /** - * @dataProvider getCapabilitiesProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('getCapabilitiesProvider')] public function testGetCapabilities(bool $federationAppEnabled, bool $federatedFileSharingAppEnabled, bool $lookupServerEnabled, bool $expectedFederatedScopeEnabled, bool $expectedPublishedScopeEnabled): void { $this->appManager->expects($this->any()) ->method('isEnabledForUser') - ->will($this->returnValueMap([ + ->willReturnMap([ ['federation', null, $federationAppEnabled], ['federatedfilesharing', null, $federatedFileSharingAppEnabled], - ])); + ]); $federatedShareProvider = $this->createMock(FederatedShareProvider::class); $this->overwriteService(FederatedShareProvider::class, $federatedShareProvider); diff --git a/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php b/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php index 3d2c1645d25..1b09838cbc3 100644 --- a/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php +++ b/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php @@ -103,9 +103,7 @@ class AppConfigControllerTest extends TestCase { ]; } - /** - * @dataProvider dataGetKeys - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGetKeys')] public function testGetKeys(string $app, ?array $keys, ?\Throwable $throws, int $status): void { $api = $this->getInstance(['verifyAppId']); if ($throws instanceof \Exception) { @@ -144,9 +142,7 @@ class AppConfigControllerTest extends TestCase { ]; } - /** - * @dataProvider dataGetValue - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGetValue')] public function testGetValue(string $app, string $key, string $default, ?string $return, ?\Throwable $throws, int $status): void { $api = $this->getInstance(['verifyAppId']); if ($throws instanceof \Exception) { @@ -190,9 +186,7 @@ class AppConfigControllerTest extends TestCase { ]; } - /** - * @dataProvider dataSetValue - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataSetValue')] public function testSetValue(string $app, string $key, string $value, ?\Throwable $appThrows, ?\Throwable $keyThrows, int $status, int|\Throwable $type = IAppConfig::VALUE_MIXED): void { $adminUser = $this->createMock(IUser::class); $adminUser->expects($this->once()) @@ -290,9 +284,7 @@ class AppConfigControllerTest extends TestCase { ]; } - /** - * @dataProvider dataDeleteValue - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataDeleteValue')] public function testDeleteValue(string $app, string $key, ?\Throwable $appThrows, ?\Throwable $keyThrows, int $status): void { $api = $this->getInstance(['verifyAppId', 'verifyConfigKey']); if ($appThrows instanceof \Exception) { @@ -356,9 +348,7 @@ class AppConfigControllerTest extends TestCase { ]; } - /** - * @dataProvider dataVerifyAppIdThrows - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataVerifyAppIdThrows')] public function testVerifyAppIdThrows(string $app): void { $this->expectException(\InvalidArgumentException::class); @@ -375,9 +365,7 @@ class AppConfigControllerTest extends TestCase { ]; } - /** - * @dataProvider dataVerifyConfigKey - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataVerifyConfigKey')] public function testVerifyConfigKey(string $app, string $key, string $value): void { $api = $this->getInstance(); $this->invokePrivate($api, 'verifyConfigKey', [$app, $key, $value]); @@ -398,9 +386,7 @@ class AppConfigControllerTest extends TestCase { ]; } - /** - * @dataProvider dataVerifyConfigKeyThrows - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataVerifyConfigKeyThrows')] public function testVerifyConfigKeyThrows(string $app, string $key, string $value): void { $this->expectException(\InvalidArgumentException::class); diff --git a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php index e4f8b3af183..85e5d733b1f 100644 --- a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php +++ b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php @@ -77,7 +77,7 @@ class GroupsControllerTest extends \Test\TestCase { } private function createGroup(string $gid): IGroup&MockObject { - $group = $this->createMock(\OCP\IGroup::class); + $group = $this->createMock(IGroup::class); $group ->method('getGID') ->willReturn($gid); @@ -161,9 +161,7 @@ class GroupsControllerTest extends \Test\TestCase { ]; } - /** - * @dataProvider dataGetGroups - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGetGroups')] public function testGetGroups(?string $search, int $limit, int $offset): void { $groups = [$this->createGroup('group1'), $this->createGroup('group2')]; @@ -180,12 +178,12 @@ class GroupsControllerTest extends \Test\TestCase { } /** - * @dataProvider dataGetGroups * * @param string|null $search * @param int|null $limit * @param int|null $offset */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGetGroups')] public function testGetGroupsDetails($search, $limit, $offset): void { $groups = [$this->createGroup('group1'), $this->createGroup('group2')]; diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php index 3f8c1566b5d..cf35a4fb324 100644 --- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php +++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php @@ -199,8 +199,7 @@ class UsersControllerTest extends TestCase { ->willReturn($subAdminManager); $this->groupManager ->expects($this->any()) - ->method('displayNamesInGroup') - ->will($this->onConsecutiveCalls(['AnotherUserInTheFirstGroup' => []], ['UserInTheSecondGroup' => []])); + ->method('displayNamesInGroup')->willReturnOnConsecutiveCalls(['AnotherUserInTheFirstGroup' => []], ['UserInTheSecondGroup' => []]); $expected = [ 'users' => [ @@ -790,7 +789,7 @@ class UsersControllerTest extends TestCase { $this->logger ->expects($this->exactly(2)) ->method('info') - ->willReturnCallback(function () use (&$calls) { + ->willReturnCallback(function () use (&$calls): void { $expected = array_shift($calls); $this->assertEquals($expected, func_get_args()); }); @@ -814,7 +813,7 @@ class UsersControllerTest extends TestCase { ->expects($this->once()) ->method('createUser') ->with('NewUser', 'PasswordOfTheNewUser') - ->will($this->throwException($exception)); + ->willThrowException($exception); $this->logger ->expects($this->once()) ->method('error') @@ -994,7 +993,7 @@ class UsersControllerTest extends TestCase { $this->logger ->expects($this->exactly(3)) ->method('info') - ->willReturnCallback(function () use (&$calls) { + ->willReturnCallback(function () use (&$calls): void { $expected = array_shift($calls); $this->assertEquals($expected, func_get_args()); }); @@ -1534,9 +1533,7 @@ class UsersControllerTest extends TestCase { ]; } - /** - * @dataProvider dataSearchByPhoneNumbers - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataSearchByPhoneNumbers')] public function testSearchByPhoneNumbers(string $location, array $search, int $status, ?array $searchUsers, ?array $userMatches, array $expected): void { $knownTo = 'knownTo'; $user = $this->createMock(IUser::class); @@ -1862,9 +1859,7 @@ class UsersControllerTest extends TestCase { ]; } - /** - * @dataProvider selfEditChangePropertyProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('selfEditChangePropertyProvider')] public function testEditUserRegularUserSelfEditChangeProperty($propertyName, $oldValue, $newValue): void { $loggedInUser = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() @@ -1940,9 +1935,7 @@ class UsersControllerTest extends TestCase { ]; } - /** - * @dataProvider selfEditChangePropertyProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('selfEditChangePropertyProvider')] public function testEditUserRegularUserSelfEditChangePropertyScope($propertyName, $oldScope, $newScope): void { $loggedInUser = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() @@ -2277,9 +2270,7 @@ class UsersControllerTest extends TestCase { ]; } - /** - * @dataProvider dataEditUserSelfEditChangeLanguageButForced - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataEditUserSelfEditChangeLanguageButForced')] public function testEditUserSelfEditChangeLanguageButForced($forced): void { $this->expectException(OCSException::class); @@ -2373,9 +2364,7 @@ class UsersControllerTest extends TestCase { $this->assertEquals([], $this->api->editUser('UserToEdit', 'language', 'de')->getData()); } - /** - * @dataProvider dataEditUserSelfEditChangeLanguageButForced - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataEditUserSelfEditChangeLanguageButForced')] public function testEditUserAdminEditChangeLanguageInvalidLanguage(): void { $this->expectException(OCSException::class); @@ -4363,9 +4352,7 @@ class UsersControllerTest extends TestCase { ]; } - /** - * @dataProvider dataGetEditableFields - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGetEditableFields')] public function testGetEditableFields(bool $allowedToChangeDisplayName, bool $allowedToChangeEmail, string $userBackend, array $expected): void { $this->config->method('getSystemValue')->willReturnCallback(fn (string $key, mixed $default) => match ($key) { 'allow_user_to_change_display_name' => $allowedToChangeDisplayName, @@ -4400,7 +4387,7 @@ class UsersControllerTest extends TestCase { $account = $this->createMock(IAccount::class); $account->method('getProperty') - ->will($this->returnValueMap($mockedProperties)); + ->willReturnMap($mockedProperties); $this->accountManager->expects($this->any())->method('getAccount') ->with($targetUser) diff --git a/apps/provisioning_api/tests/Middleware/ProvisioningApiMiddlewareTest.php b/apps/provisioning_api/tests/Middleware/ProvisioningApiMiddlewareTest.php index d40aab90d66..c027e518a3d 100644 --- a/apps/provisioning_api/tests/Middleware/ProvisioningApiMiddlewareTest.php +++ b/apps/provisioning_api/tests/Middleware/ProvisioningApiMiddlewareTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later @@ -43,9 +44,7 @@ class ProvisioningApiMiddlewareTest extends TestCase { ]; } - /** - * @dataProvider dataAnnotation - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataAnnotation')] public function testBeforeController(bool $subadminRequired, bool $isAdmin, bool $isSubAdmin, bool $hasSettingAuthorizationAnnotation, bool $shouldThrowException): void { $middleware = new ProvisioningApiMiddleware( $this->reflector, @@ -82,9 +81,7 @@ class ProvisioningApiMiddlewareTest extends TestCase { ]; } - /** - * @dataProvider dataAfterException - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataAfterException')] public function testAfterException(\Exception $exception, bool $forwared): void { $middleware = new ProvisioningApiMiddleware( $this->reflector, |