diff options
Diffstat (limited to 'apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php')
-rw-r--r-- | apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php | 83 |
1 files changed, 35 insertions, 48 deletions
diff --git a/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php b/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php index e08f3bd4d7d..2a2f4596fda 100644 --- a/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php +++ b/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors * SPDX-FileCopyrightText: 2016 ownCloud, Inc. @@ -6,6 +7,7 @@ */ namespace OCA\Files_External\Tests\Service; +use OC\User\User; use OCA\Files_External\Lib\StorageConfig; use OCA\Files_External\NotFoundException; use OCA\Files_External\Service\StoragesService; @@ -14,6 +16,8 @@ use OCP\EventDispatcher\IEventDispatcher; use OCP\IGroupManager; use OCP\IUser; use OCP\IUserSession; +use OCP\Server; +use PHPUnit\Framework\MockObject\MockObject; use Test\Traits\UserTrait; /** @@ -22,20 +26,9 @@ use Test\Traits\UserTrait; class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest { use UserTrait; - /** @var \OCP\IGroupManager|\PHPUnit\Framework\MockObject\MockObject groupManager */ - protected $groupManager; - - /** - * @var StoragesService - */ - protected $globalStoragesService; - - /** - * @var UserGlobalStoragesService - */ - protected $service; - - protected $user; + protected IGroupManager&MockObject $groupManager; + protected StoragesService $globalStoragesService; + protected User $user; public const USER_ID = 'test_user'; public const GROUP_ID = 'test_group'; @@ -46,8 +39,8 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest { $this->globalStoragesService = $this->service; - $this->user = new \OC\User\User(self::USER_ID, null, \OC::$server->get(IEventDispatcher::class)); - /** @var \OCP\IUserSession|\PHPUnit\Framework\MockObject\MockObject $userSession */ + $this->user = new User(self::USER_ID, null, Server::get(IEventDispatcher::class)); + /** @var IUserSession&MockObject $userSession */ $userSession = $this->createMock(IUserSession::class); $userSession ->expects($this->any()) @@ -85,7 +78,7 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest { ); } - public function applicableStorageProvider() { + public static function applicableStorageProvider(): array { return [ [[], [], true], @@ -105,10 +98,8 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest { ]; } - /** - * @dataProvider applicableStorageProvider - */ - public function testGetStorageWithApplicable($applicableUsers, $applicableGroups, $isVisible) { + #[\PHPUnit\Framework\Attributes\DataProvider('applicableStorageProvider')] + public function testGetStorageWithApplicable($applicableUsers, $applicableGroups, $isVisible): void { $backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\SMB'); $authMechanism = $this->backendService->getAuthMechanism('identifier:\Auth\Mechanism'); @@ -139,7 +130,7 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest { } - public function testAddStorage($storageParams = null) { + public function testAddStorage($storageParams = null): void { $this->expectException(\DomainException::class); $backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\SMB'); @@ -155,7 +146,7 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest { } - public function testUpdateStorage($storageParams = null) { + public function testUpdateStorage($storageParams = null): void { $this->expectException(\DomainException::class); $backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\SMB'); @@ -175,16 +166,14 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest { } - public function testNonExistingStorage() { + public function testNonExistingStorage(): void { $this->expectException(\DomainException::class); $this->ActualNonExistingStorageTest(); } - /** - * @dataProvider deleteStorageDataProvider - */ - public function testDeleteStorage($backendOptions, $rustyStorageId) { + #[\PHPUnit\Framework\Attributes\DataProvider('deleteStorageDataProvider')] + public function testDeleteStorage($backendOptions, $rustyStorageId): void { $this->expectException(\DomainException::class); $backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\SMB'); @@ -203,13 +192,13 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest { } - public function testDeleteUnexistingStorage() { + public function testDeleteUnexistingStorage(): void { $this->expectException(\DomainException::class); $this->actualDeletedUnexistingStorageTest(); } - public function getUniqueStoragesProvider() { + public static function getUniqueStoragesProvider(): array { return [ // 'all' vs group [100, [], [], 100, [], [self::GROUP_ID], 2], @@ -237,14 +226,12 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest { ]; } - /** - * @dataProvider getUniqueStoragesProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('getUniqueStoragesProvider')] public function testGetUniqueStorages( $priority1, $applicableUsers1, $applicableGroups1, $priority2, $applicableUsers2, $applicableGroups2, - $expectedPrecedence - ) { + $expectedPrecedence, + ): void { $backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\SMB'); $backend->method('isVisibleFor') ->willReturn(true); @@ -284,67 +271,67 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest { } } - public function testGetStoragesBackendNotVisible() { + public function testGetStoragesBackendNotVisible(): void { // we don't test this here $this->addToAssertionCount(1); } - public function testGetStoragesAuthMechanismNotVisible() { + public function testGetStoragesAuthMechanismNotVisible(): void { // we don't test this here $this->addToAssertionCount(1); } - public function testHooksAddStorage($a = null, $b = null, $c = null) { + public function testHooksAddStorage($a = null, $b = null, $c = null): void { // we don't test this here $this->addToAssertionCount(1); } - public function testHooksUpdateStorage($a = null, $b = null, $c = null, $d = null, $e = null) { + public function testHooksUpdateStorage($a = null, $b = null, $c = null, $d = null, $e = null): void { // we don't test this here $this->addToAssertionCount(1); } - public function testHooksRenameMountPoint() { + public function testHooksRenameMountPoint(): void { // we don't test this here $this->addToAssertionCount(1); } - public function testHooksDeleteStorage($a = null, $b = null, $c = null) { + public function testHooksDeleteStorage($a = null, $b = null, $c = null): void { // we don't test this here $this->addToAssertionCount(1); } - public function testLegacyConfigConversionApplicableAll() { + public function testLegacyConfigConversionApplicableAll(): void { // we don't test this here $this->addToAssertionCount(1); } - public function testLegacyConfigConversionApplicableUserAndGroup() { + public function testLegacyConfigConversionApplicableUserAndGroup(): void { // we don't test this here $this->addToAssertionCount(1); } - public function testReadLegacyConfigAndGenerateConfigId() { + public function testReadLegacyConfigAndGenerateConfigId(): void { // we don't test this here $this->addToAssertionCount(1); } - public function testReadLegacyConfigNoAuthMechanism() { + public function testReadLegacyConfigNoAuthMechanism(): void { // we don't test this here $this->addToAssertionCount(1); } - public function testReadLegacyConfigClass() { + public function testReadLegacyConfigClass(): void { // we don't test this here $this->addToAssertionCount(1); } - public function testReadEmptyMountPoint() { + public function testReadEmptyMountPoint(): void { // we don't test this here $this->addToAssertionCount(1); } - public function testUpdateStorageMountPoint() { + public function testUpdateStorageMountPoint(): void { // we don't test this here $this->addToAssertionCount(1); } |