diff options
Diffstat (limited to 'tests/lib/Repair')
-rw-r--r-- | tests/lib/Repair/CleanTagsTest.php | 9 | ||||
-rw-r--r-- | tests/lib/Repair/ClearFrontendCachesTest.php | 6 | ||||
-rw-r--r-- | tests/lib/Repair/ClearGeneratedAvatarCacheTest.php | 5 | ||||
-rw-r--r-- | tests/lib/Repair/NC29/SanitizeAccountPropertiesJobTest.php | 4 | ||||
-rw-r--r-- | tests/lib/Repair/OldGroupMembershipSharesTest.php | 4 | ||||
-rw-r--r-- | tests/lib/Repair/Owncloud/CleanPreviewsBackgroundJobTest.php | 20 | ||||
-rw-r--r-- | tests/lib/Repair/Owncloud/CleanPreviewsTest.php | 7 | ||||
-rw-r--r-- | tests/lib/Repair/Owncloud/UpdateLanguageCodesTest.php | 6 | ||||
-rw-r--r-- | tests/lib/Repair/RepairCollationTest.php | 6 | ||||
-rw-r--r-- | tests/lib/Repair/RepairInvalidSharesTest.php | 18 | ||||
-rw-r--r-- | tests/lib/Repair/RepairMimeTypesTest.php | 8 |
11 files changed, 54 insertions, 39 deletions
diff --git a/tests/lib/Repair/CleanTagsTest.php b/tests/lib/Repair/CleanTagsTest.php index adb14b16fc4..04afabb87d9 100644 --- a/tests/lib/Repair/CleanTagsTest.php +++ b/tests/lib/Repair/CleanTagsTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors * SPDX-FileCopyrightText: 2016 ownCloud, Inc. @@ -7,10 +8,12 @@ namespace Test\Repair; +use OC\Repair\CleanTags; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; use OCP\IUserManager; use OCP\Migration\IOutput; +use OCP\Server; use PHPUnit\Framework\MockObject\MockObject; /** @@ -23,7 +26,7 @@ use PHPUnit\Framework\MockObject\MockObject; class CleanTagsTest extends \Test\TestCase { private ?int $createdFile = null; - private \OC\Repair\CleanTags $repair; + private CleanTags $repair; private IDBConnection $connection; private IUserManager&MockObject $userManager; @@ -40,8 +43,8 @@ class CleanTagsTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); - $this->connection = \OCP\Server::get(IDBConnection::class); - $this->repair = new \OC\Repair\CleanTags($this->connection, $this->userManager); + $this->connection = Server::get(IDBConnection::class); + $this->repair = new CleanTags($this->connection, $this->userManager); $this->cleanUpTables(); } diff --git a/tests/lib/Repair/ClearFrontendCachesTest.php b/tests/lib/Repair/ClearFrontendCachesTest.php index 2e4681c6e5d..3e5927565fe 100644 --- a/tests/lib/Repair/ClearFrontendCachesTest.php +++ b/tests/lib/Repair/ClearFrontendCachesTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later @@ -6,6 +7,7 @@ namespace Test\Repair; +use OC\Repair\ClearFrontendCaches; use OC\Template\JSCombiner; use OCP\ICache; use OCP\ICacheFactory; @@ -18,7 +20,7 @@ class ClearFrontendCachesTest extends \Test\TestCase { private JSCombiner&MockObject $jsCombiner; private IOutput&MockObject $outputMock; - protected \OC\Repair\ClearFrontendCaches $repair; + protected ClearFrontendCaches $repair; protected function setUp(): void { parent::setUp(); @@ -28,7 +30,7 @@ class ClearFrontendCachesTest extends \Test\TestCase { $this->cacheFactory = $this->createMock(ICacheFactory::class); $this->jsCombiner = $this->createMock(JSCombiner::class); - $this->repair = new \OC\Repair\ClearFrontendCaches($this->cacheFactory, $this->jsCombiner); + $this->repair = new ClearFrontendCaches($this->cacheFactory, $this->jsCombiner); } diff --git a/tests/lib/Repair/ClearGeneratedAvatarCacheTest.php b/tests/lib/Repair/ClearGeneratedAvatarCacheTest.php index 810fa1fe4e8..43203d489e6 100644 --- a/tests/lib/Repair/ClearGeneratedAvatarCacheTest.php +++ b/tests/lib/Repair/ClearGeneratedAvatarCacheTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later @@ -30,7 +31,7 @@ class ClearGeneratedAvatarCacheTest extends \Test\TestCase { $this->repair = new ClearGeneratedAvatarCache($this->config, $this->avatarManager, $this->jobList); } - public function shouldRunDataProvider() { + public static function shouldRunDataProvider(): array { return [ ['11.0.0.0', true], ['15.0.0.3', true], @@ -44,11 +45,11 @@ class ClearGeneratedAvatarCacheTest extends \Test\TestCase { } /** - * @dataProvider shouldRunDataProvider * * @param string $from * @param boolean $expected */ + #[\PHPUnit\Framework\Attributes\DataProvider('shouldRunDataProvider')] public function testShouldRun($from, $expected): void { $this->config->expects($this->any()) ->method('getSystemValueString') diff --git a/tests/lib/Repair/NC29/SanitizeAccountPropertiesJobTest.php b/tests/lib/Repair/NC29/SanitizeAccountPropertiesJobTest.php index e0f4eb3cbc1..2a4f6e9ecf1 100644 --- a/tests/lib/Repair/NC29/SanitizeAccountPropertiesJobTest.php +++ b/tests/lib/Repair/NC29/SanitizeAccountPropertiesJobTest.php @@ -24,7 +24,7 @@ class SanitizeAccountPropertiesJobTest extends TestCase { private IUserManager&MockObject $userManager; private IAccountManager&MockObject $accountManager; private LoggerInterface&MockObject $logger; - + private SanitizeAccountPropertiesJob $job; protected function setUp(): void { @@ -104,7 +104,7 @@ class SanitizeAccountPropertiesJobTest extends TestCase { $valid = false; $this->accountManager->expects(self::exactly(3)) ->method('updateAccount') - ->willReturnCallback(function (IAccount $account) use (&$account1, &$valid) { + ->willReturnCallback(function (IAccount $account) use (&$account1, &$valid): void { if (!$valid && $account === $account1) { $valid = true; throw new InvalidArgumentException(IAccountManager::PROPERTY_PHONE); diff --git a/tests/lib/Repair/OldGroupMembershipSharesTest.php b/tests/lib/Repair/OldGroupMembershipSharesTest.php index 594a8bf0b66..099290b18ed 100644 --- a/tests/lib/Repair/OldGroupMembershipSharesTest.php +++ b/tests/lib/Repair/OldGroupMembershipSharesTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors * SPDX-FileCopyrightText: 2016 ownCloud, Inc. @@ -11,6 +12,7 @@ use OC\Repair\OldGroupMembershipShares; use OCP\IDBConnection; use OCP\IGroupManager; use OCP\Migration\IOutput; +use OCP\Server; use OCP\Share\IShare; use PHPUnit\Framework\MockObject\MockObject; @@ -32,7 +34,7 @@ class OldGroupMembershipSharesTest extends \Test\TestCase { $this->groupManager = $this->getMockBuilder(IGroupManager::class) ->disableOriginalConstructor() ->getMock(); - $this->connection = \OCP\Server::get(IDBConnection::class); + $this->connection = Server::get(IDBConnection::class); $this->deleteAllShares(); } diff --git a/tests/lib/Repair/Owncloud/CleanPreviewsBackgroundJobTest.php b/tests/lib/Repair/Owncloud/CleanPreviewsBackgroundJobTest.php index 3c5583c49da..fc88ee5d226 100644 --- a/tests/lib/Repair/Owncloud/CleanPreviewsBackgroundJobTest.php +++ b/tests/lib/Repair/Owncloud/CleanPreviewsBackgroundJobTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later @@ -71,8 +72,7 @@ class CleanPreviewsBackgroundJobTest extends TestCase { $thumbnailFolder->expects($this->never()) ->method('delete'); - $this->timeFactory->method('getTime') - ->will($this->onConsecutiveCalls(100, 200)); + $this->timeFactory->method('getTime')->willReturnOnConsecutiveCalls(100, 200); $this->jobList->expects($this->once()) ->method('add') @@ -84,7 +84,7 @@ class CleanPreviewsBackgroundJobTest extends TestCase { $loggerCalls = []; $this->logger->expects($this->exactly(2)) ->method('info') - ->willReturnCallback(function () use (&$loggerCalls) { + ->willReturnCallback(function () use (&$loggerCalls): void { $loggerCalls[] = func_get_args(); }); @@ -118,8 +118,7 @@ class CleanPreviewsBackgroundJobTest extends TestCase { $thumbnailFolder->method('getDirectoryListing') ->willReturn([$previewFolder1]); - $this->timeFactory->method('getTime') - ->will($this->onConsecutiveCalls(100, 101)); + $this->timeFactory->method('getTime')->willReturnOnConsecutiveCalls(100, 101); $this->jobList->expects($this->never()) ->method('add'); @@ -127,7 +126,7 @@ class CleanPreviewsBackgroundJobTest extends TestCase { $loggerCalls = []; $this->logger->expects($this->exactly(2)) ->method('info') - ->willReturnCallback(function () use (&$loggerCalls) { + ->willReturnCallback(function () use (&$loggerCalls): void { $loggerCalls[] = func_get_args(); }); @@ -150,7 +149,7 @@ class CleanPreviewsBackgroundJobTest extends TestCase { $loggerCalls = []; $this->logger->expects($this->exactly(2)) ->method('info') - ->willReturnCallback(function () use (&$loggerCalls) { + ->willReturnCallback(function () use (&$loggerCalls): void { $loggerCalls[] = func_get_args(); }); @@ -178,7 +177,7 @@ class CleanPreviewsBackgroundJobTest extends TestCase { $loggerCalls = []; $this->logger->expects($this->exactly(2)) ->method('info') - ->willReturnCallback(function () use (&$loggerCalls) { + ->willReturnCallback(function () use (&$loggerCalls): void { $loggerCalls[] = func_get_args(); }); @@ -213,8 +212,7 @@ class CleanPreviewsBackgroundJobTest extends TestCase { $thumbnailFolder->method('getDirectoryListing') ->willReturn([$previewFolder1]); - $this->timeFactory->method('getTime') - ->will($this->onConsecutiveCalls(100, 101)); + $this->timeFactory->method('getTime')->willReturnOnConsecutiveCalls(100, 101); $this->jobList->expects($this->never()) ->method('add'); @@ -226,7 +224,7 @@ class CleanPreviewsBackgroundJobTest extends TestCase { $loggerCalls = []; $this->logger->expects($this->exactly(2)) ->method('info') - ->willReturnCallback(function () use (&$loggerCalls) { + ->willReturnCallback(function () use (&$loggerCalls): void { $loggerCalls[] = func_get_args(); }); diff --git a/tests/lib/Repair/Owncloud/CleanPreviewsTest.php b/tests/lib/Repair/Owncloud/CleanPreviewsTest.php index 3a1936076a0..e5a4441a4fa 100644 --- a/tests/lib/Repair/Owncloud/CleanPreviewsTest.php +++ b/tests/lib/Repair/Owncloud/CleanPreviewsTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later @@ -52,15 +53,15 @@ class CleanPreviewsTest extends TestCase { $this->userManager->expects($this->once()) ->method('callForSeenUsers') - ->will($this->returnCallback(function (\Closure $function) use (&$user1, $user2) { + ->willReturnCallback(function (\Closure $function) use (&$user1, $user2): void { $function($user1); $function($user2); - })); + }); $jobListCalls = []; $this->jobList->expects($this->exactly(2)) ->method('add') - ->willReturnCallback(function () use (&$jobListCalls) { + ->willReturnCallback(function () use (&$jobListCalls): void { $jobListCalls[] = func_get_args(); }); diff --git a/tests/lib/Repair/Owncloud/UpdateLanguageCodesTest.php b/tests/lib/Repair/Owncloud/UpdateLanguageCodesTest.php index a7907308d93..a3eb163b0d6 100644 --- a/tests/lib/Repair/Owncloud/UpdateLanguageCodesTest.php +++ b/tests/lib/Repair/Owncloud/UpdateLanguageCodesTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later @@ -11,6 +12,7 @@ use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IConfig; use OCP\IDBConnection; use OCP\Migration\IOutput; +use OCP\Server; use PHPUnit\Framework\MockObject\MockObject; use Test\TestCase; @@ -29,7 +31,7 @@ class UpdateLanguageCodesTest extends TestCase { protected function setUp(): void { parent::setUp(); - $this->connection = \OCP\Server::get(IDBConnection::class); + $this->connection = Server::get(IDBConnection::class); $this->config = $this->createMock(IConfig::class); } @@ -91,7 +93,7 @@ class UpdateLanguageCodesTest extends TestCase { $outputMock = $this->createMock(IOutput::class); $outputMock->expects($this->exactly(7)) ->method('info') - ->willReturnCallback(function () use (&$outputMessages) { + ->willReturnCallback(function () use (&$outputMessages): void { $outputMessages[] = func_get_args(); }); diff --git a/tests/lib/Repair/RepairCollationTest.php b/tests/lib/Repair/RepairCollationTest.php index 3f007fa6310..3c51325562d 100644 --- a/tests/lib/Repair/RepairCollationTest.php +++ b/tests/lib/Repair/RepairCollationTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors * SPDX-FileCopyrightText: 2016 ownCloud, Inc. @@ -12,6 +13,7 @@ use OC\Repair\Collation; use OCP\IConfig; use OCP\IDBConnection; use OCP\Migration\IOutput; +use OCP\Server; use PHPUnit\Framework\MockObject\MockObject; use Psr\Log\LoggerInterface; use Test\TestCase; @@ -45,8 +47,8 @@ class RepairCollationTest extends TestCase { protected function setUp(): void { parent::setUp(); - $this->connection = \OCP\Server::get(ConnectionAdapter::class); - $this->config = \OCP\Server::get(IConfig::class); + $this->connection = Server::get(ConnectionAdapter::class); + $this->config = Server::get(IConfig::class); if ($this->connection->getDatabaseProvider() !== IDBConnection::PLATFORM_MYSQL) { $this->markTestSkipped('Test only relevant on MySql'); } diff --git a/tests/lib/Repair/RepairInvalidSharesTest.php b/tests/lib/Repair/RepairInvalidSharesTest.php index dfcdce3801a..72103976da5 100644 --- a/tests/lib/Repair/RepairInvalidSharesTest.php +++ b/tests/lib/Repair/RepairInvalidSharesTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors * SPDX-FileCopyrightText: 2016 ownCloud, Inc. @@ -8,9 +9,11 @@ namespace Test\Repair; use OC\Repair\RepairInvalidShares; +use OCP\Constants; use OCP\IConfig; use OCP\IDBConnection; use OCP\Migration\IOutput; +use OCP\Server; use OCP\Share\IShare; use Test\TestCase; @@ -37,7 +40,7 @@ class RepairInvalidSharesTest extends TestCase { ->with('version') ->willReturn('12.0.0.0'); - $this->connection = \OCP\Server::get(IDBConnection::class); + $this->connection = Server::get(IDBConnection::class); $this->deleteAllShares(); $this->repair = new RepairInvalidShares($config, $this->connection); @@ -122,7 +125,7 @@ class RepairInvalidSharesTest extends TestCase { $result->closeCursor(); } - public function fileSharePermissionsProvider() { + public static function fileSharePermissionsProvider(): array { return [ // unchanged for folder [ @@ -133,23 +136,22 @@ class RepairInvalidSharesTest extends TestCase { // unchanged for read-write + share [ 'file', - \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE, - \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE, + Constants::PERMISSION_READ | Constants::PERMISSION_UPDATE | Constants::PERMISSION_SHARE, + Constants::PERMISSION_READ | Constants::PERMISSION_UPDATE | Constants::PERMISSION_SHARE, ], // fixed for all perms [ 'file', - \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE | \OCP\Constants::PERMISSION_SHARE, - \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE, + Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE | Constants::PERMISSION_DELETE | Constants::PERMISSION_SHARE, + Constants::PERMISSION_READ | Constants::PERMISSION_UPDATE | Constants::PERMISSION_SHARE, ], ]; } /** * Test adjusting file share permissions - * - * @dataProvider fileSharePermissionsProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('fileSharePermissionsProvider')] public function testFileSharePermissions($itemType, $testPerms, $expectedPerms): void { $qb = $this->connection->getQueryBuilder(); $qb->insert('share') diff --git a/tests/lib/Repair/RepairMimeTypesTest.php b/tests/lib/Repair/RepairMimeTypesTest.php index 4f044c054d3..0261b56ebe9 100644 --- a/tests/lib/Repair/RepairMimeTypesTest.php +++ b/tests/lib/Repair/RepairMimeTypesTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors * SPDX-FileCopyrightText: 2016 ownCloud, Inc. @@ -14,6 +15,7 @@ use OCP\IAppConfig; use OCP\IConfig; use OCP\IDBConnection; use OCP\Migration\IOutput; +use OCP\Server; /** * Tests for the converting of legacy storages to home storages. @@ -32,8 +34,8 @@ class RepairMimeTypesTest extends \Test\TestCase { protected function setUp(): void { parent::setUp(); - $this->mimetypeLoader = \OCP\Server::get(IMimeTypeLoader::class); - $this->db = \OCP\Server::get(IDBConnection::class); + $this->mimetypeLoader = Server::get(IMimeTypeLoader::class); + $this->db = Server::get(IDBConnection::class); $config = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor() @@ -55,7 +57,7 @@ class RepairMimeTypesTest extends \Test\TestCase { $this->repair = new RepairMimeTypes( $config, $appConfig, - \OCP\Server::get(IDBConnection::class), + Server::get(IDBConnection::class), ); } |