diff options
Diffstat (limited to 'apps/files_external/tests/Service/UserStoragesServiceTest.php')
-rw-r--r-- | apps/files_external/tests/Service/UserStoragesServiceTest.php | 76 |
1 files changed, 28 insertions, 48 deletions
diff --git a/apps/files_external/tests/Service/UserStoragesServiceTest.php b/apps/files_external/tests/Service/UserStoragesServiceTest.php index cda1dd0a27f..0a2f291f6e4 100644 --- a/apps/files_external/tests/Service/UserStoragesServiceTest.php +++ b/apps/files_external/tests/Service/UserStoragesServiceTest.php @@ -1,55 +1,37 @@ <?php + /** - * @copyright Copyright (c) 2016, ownCloud, Inc. - * - * @author Christoph Wurst <christoph@winzerhof-wurst.at> - * @author Joas Schilling <coding@schilljs.com> - * @author Morris Jobke <hey@morrisjobke.de> - * @author Robin Appelman <robin@icewind.nl> - * @author Robin McCorkell <robin@mccorkell.me.uk> - * @author Roeland Jago Douma <roeland@famdouma.nl> - * @author Vincent Petry <vincent@nextcloud.com> - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * + * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2016 ownCloud, Inc. + * SPDX-License-Identifier: AGPL-3.0-only */ namespace OCA\Files_External\Tests\Service; use OC\Files\Filesystem; - +use OC\User\User; use OCA\Files_External\Lib\StorageConfig; +use OCA\Files_External\MountConfig; +use OCA\Files_External\NotFoundException; use OCA\Files_External\Service\GlobalStoragesService; + use OCA\Files_External\Service\StoragesService; use OCA\Files_External\Service\UserStoragesService; +use OCP\IUserManager; use OCP\IUserSession; +use OCP\Server; +use PHPUnit\Framework\MockObject\MockObject; use Test\Traits\UserTrait; /** * @group DB */ -class UserStoragesServiceTest extends StoragesServiceTest { +class UserStoragesServiceTest extends StoragesServiceTestCase { use UserTrait; - private $user; - - private $userId; + protected User $user; - /** - * @var StoragesService - */ - protected $globalStoragesService; + protected string $userId; + protected StoragesService $globalStoragesService; protected function setUp(): void { parent::setUp(); @@ -58,9 +40,9 @@ class UserStoragesServiceTest extends StoragesServiceTest { $this->userId = $this->getUniqueID('user_'); $this->createUser($this->userId, $this->userId); - $this->user = \OC::$server->getUserManager()->get($this->userId); + $this->user = Server::get(IUserManager::class)->get($this->userId); - /** @var \OCP\IUserSession|\PHPUnit\Framework\MockObject\MockObject $userSession */ + /** @var IUserSession&MockObject $userSession */ $userSession = $this->createMock(IUserSession::class); $userSession ->expects($this->any()) @@ -86,7 +68,7 @@ class UserStoragesServiceTest extends StoragesServiceTest { ]); } - public function testAddStorage() { + public function testAddStorage(): void { $storage = $this->makeTestStorageData(); $newStorage = $this->service->addStorage($storage); @@ -106,7 +88,7 @@ class UserStoragesServiceTest extends StoragesServiceTest { current(self::$hookCalls), Filesystem::signal_create_mount, $storage->getMountPoint(), - \OCA\Files_External\MountConfig::MOUNT_TYPE_USER, + MountConfig::MOUNT_TYPE_USER, $this->userId ); @@ -114,7 +96,7 @@ class UserStoragesServiceTest extends StoragesServiceTest { $this->assertEquals($id + 1, $nextStorage->getId()); } - public function testUpdateStorage() { + public function testUpdateStorage(): void { $storage = $this->makeStorageConfig([ 'mountPoint' => 'mountpoint', 'backendIdentifier' => 'identifier:\OCA\Files_External\Lib\Backend\SMB', @@ -146,10 +128,8 @@ class UserStoragesServiceTest extends StoragesServiceTest { $this->assertEmpty(self::$hookCalls); } - /** - * @dataProvider deleteStorageDataProvider - */ - public function testDeleteStorage($backendOptions, $rustyStorageId) { + #[\PHPUnit\Framework\Attributes\DataProvider('deleteStorageDataProvider')] + public function testDeleteStorage($backendOptions, $rustyStorageId): void { parent::testDeleteStorage($backendOptions, $rustyStorageId); // hook called once for user (first one was during test creation) @@ -157,12 +137,12 @@ class UserStoragesServiceTest extends StoragesServiceTest { self::$hookCalls[1], Filesystem::signal_delete_mount, '/mountpoint', - \OCA\Files_External\MountConfig::MOUNT_TYPE_USER, + MountConfig::MOUNT_TYPE_USER, $this->userId ); } - public function testHooksRenameMountPoint() { + public function testHooksRenameMountPoint(): void { $storage = $this->makeTestStorageData(); $storage = $this->service->addStorage($storage); @@ -178,21 +158,21 @@ class UserStoragesServiceTest extends StoragesServiceTest { self::$hookCalls[0], Filesystem::signal_delete_mount, '/mountpoint', - \OCA\Files_External\MountConfig::MOUNT_TYPE_USER, + MountConfig::MOUNT_TYPE_USER, $this->userId ); $this->assertHookCall( self::$hookCalls[1], Filesystem::signal_create_mount, '/renamedMountpoint', - \OCA\Files_External\MountConfig::MOUNT_TYPE_USER, + MountConfig::MOUNT_TYPE_USER, $this->userId ); } - public function testGetAdminStorage() { - $this->expectException(\OCA\Files_External\NotFoundException::class); + public function testGetAdminStorage(): void { + $this->expectException(NotFoundException::class); $backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\SMB'); $authMechanism = $this->backendService->getAuthMechanism('identifier:\Auth\Mechanism'); |