aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_trashbin/tests
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2025-06-30 16:56:59 +0200
committerRobin Appelman <robin@icewind.nl>2025-07-01 22:45:52 +0200
commitaa15f9d16d5b46d04763c7deedb129990e819364 (patch)
tree758e0aebcac34a545f9a21806120a9fcb96f4cb6 /apps/files_trashbin/tests
parent1620a0c0510a42b1da0a66488838f1ce3ba1210d (diff)
downloadnextcloud-server-rector-phpunit10.tar.gz
nextcloud-server-rector-phpunit10.zip
chore: run rectorrector-phpunit10
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps/files_trashbin/tests')
-rw-r--r--apps/files_trashbin/tests/Command/CleanUpTest.php8
-rw-r--r--apps/files_trashbin/tests/ExpirationTest.php8
-rw-r--r--apps/files_trashbin/tests/Sabre/TrashbinPluginTest.php4
-rw-r--r--apps/files_trashbin/tests/StorageTest.php14
-rw-r--r--apps/files_trashbin/tests/TrashbinTest.php18
5 files changed, 21 insertions, 31 deletions
diff --git a/apps/files_trashbin/tests/Command/CleanUpTest.php b/apps/files_trashbin/tests/Command/CleanUpTest.php
index 3dce8f0c92e..41ed0e1e960 100644
--- a/apps/files_trashbin/tests/Command/CleanUpTest.php
+++ b/apps/files_trashbin/tests/Command/CleanUpTest.php
@@ -69,9 +69,7 @@ class CleanUpTest extends TestCase {
$this->assertCount(10, $result);
}
- /**
- * @dataProvider dataTestRemoveDeletedFiles
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestRemoveDeletedFiles')]
public function testRemoveDeletedFiles(bool $nodeExists): void {
$this->initTable();
$this->rootFolder
@@ -129,7 +127,7 @@ class CleanUpTest extends TestCase {
*/
public function testExecuteDeleteListOfUsers(): void {
$userIds = ['user1', 'user2', 'user3'];
- $instance = $this->getMockBuilder(\OCA\Files_Trashbin\Command\CleanUp::class)
+ $instance = $this->getMockBuilder(CleanUp::class)
->onlyMethods(['removeDeletedFiles'])
->setConstructorArgs([$this->rootFolder, $this->userManager, $this->dbConnection])
->getMock();
@@ -159,7 +157,7 @@ class CleanUpTest extends TestCase {
public function testExecuteAllUsers(): void {
$userIds = [];
$backendUsers = ['user1', 'user2'];
- $instance = $this->getMockBuilder(\OCA\Files_Trashbin\Command\CleanUp::class)
+ $instance = $this->getMockBuilder(CleanUp::class)
->onlyMethods(['removeDeletedFiles'])
->setConstructorArgs([$this->rootFolder, $this->userManager, $this->dbConnection])
->getMock();
diff --git a/apps/files_trashbin/tests/ExpirationTest.php b/apps/files_trashbin/tests/ExpirationTest.php
index aab07de8162..3348edc4016 100644
--- a/apps/files_trashbin/tests/ExpirationTest.php
+++ b/apps/files_trashbin/tests/ExpirationTest.php
@@ -82,9 +82,7 @@ class ExpirationTest extends \Test\TestCase {
];
}
- /**
- * @dataProvider expirationData
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('expirationData')]
public function testExpiration(string $retentionObligation, int $timeNow, int $timestamp, bool $quotaExceeded, bool $expectedResult): void {
$mockedConfig = $this->getMockedConfig($retentionObligation);
$mockedTimeFactory = $this->getMockedTimeFactory($timeNow);
@@ -110,9 +108,7 @@ class ExpirationTest extends \Test\TestCase {
}
- /**
- * @dataProvider timestampTestData
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('timestampTestData')]
public function testGetMaxAgeAsTimestamp(string $configValue, bool|int $expectedMaxAgeTimestamp): void {
$mockedConfig = $this->getMockedConfig($configValue);
$mockedTimeFactory = $this->getMockedTimeFactory(
diff --git a/apps/files_trashbin/tests/Sabre/TrashbinPluginTest.php b/apps/files_trashbin/tests/Sabre/TrashbinPluginTest.php
index 6c566afc738..87aca2753ef 100644
--- a/apps/files_trashbin/tests/Sabre/TrashbinPluginTest.php
+++ b/apps/files_trashbin/tests/Sabre/TrashbinPluginTest.php
@@ -29,9 +29,7 @@ class TrashbinPluginTest extends TestCase {
$this->server = new Server($tree);
}
- /**
- * @dataProvider quotaProvider
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('quotaProvider')]
public function testQuota(int $quota, int $fileSize, bool $expectedResult): void {
$fileInfo = $this->createMock(ITrashItem::class);
$fileInfo->method('getSize')
diff --git a/apps/files_trashbin/tests/StorageTest.php b/apps/files_trashbin/tests/StorageTest.php
index 2b2508a358b..c58ddec97dd 100644
--- a/apps/files_trashbin/tests/StorageTest.php
+++ b/apps/files_trashbin/tests/StorageTest.php
@@ -311,7 +311,7 @@ class StorageTest extends \Test\TestCase {
$recipientUser = $this->getUniqueId('recipient_');
Server::get(IUserManager::class)->createUser($recipientUser, $recipientUser);
- $node = \OCP\Server::get(IRootFolder::class)->getUserFolder($this->user)->get('share');
+ $node = Server::get(IRootFolder::class)->getUserFolder($this->user)->get('share');
$share = Server::get(\OCP\Share\IManager::class)->newShare();
$share->setNode($node)
->setShareType(IShare::TYPE_USER)
@@ -362,7 +362,7 @@ class StorageTest extends \Test\TestCase {
$recipientUser = $this->getUniqueId('recipient_');
Server::get(IUserManager::class)->createUser($recipientUser, $recipientUser);
- $node = \OCP\Server::get(IRootFolder::class)->getUserFolder($this->user)->get('share');
+ $node = Server::get(IRootFolder::class)->getUserFolder($this->user)->get('share');
$share = Server::get(\OCP\Share\IManager::class)->newShare();
$share->setNode($node)
->setShareType(IShare::TYPE_USER)
@@ -496,7 +496,7 @@ class StorageTest extends \Test\TestCase {
/**
* @var Temporary&MockObject $storage
*/
- $storage = $this->getMockBuilder(\OC\Files\Storage\Temporary::class)
+ $storage = $this->getMockBuilder(Temporary::class)
->setConstructorArgs([[]])
->onlyMethods(['rename', 'unlink', 'moveFromStorage'])
->getMock();
@@ -533,7 +533,7 @@ class StorageTest extends \Test\TestCase {
/**
* @var Temporary&MockObject $storage
*/
- $storage = $this->getMockBuilder(\OC\Files\Storage\Temporary::class)
+ $storage = $this->getMockBuilder(Temporary::class)
->setConstructorArgs([[]])
->onlyMethods(['rename', 'unlink', 'rmdir'])
->getMock();
@@ -560,14 +560,12 @@ class StorageTest extends \Test\TestCase {
$this->assertCount(0, $results);
}
- /**
- * @dataProvider dataTestShouldMoveToTrash
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestShouldMoveToTrash')]
public function testShouldMoveToTrash(string $mountPoint, string $path, bool $userExists, bool $appDisablesTrash, bool $expected): void {
$fileID = 1;
$cache = $this->createMock(ICache::class);
$cache->expects($this->any())->method('getId')->willReturn($fileID);
- $tmpStorage = $this->createMock(\OC\Files\Storage\Temporary::class);
+ $tmpStorage = $this->createMock(Temporary::class);
$tmpStorage->expects($this->any())->method('getCache')->willReturn($cache);
$userManager = $this->getMockBuilder(IUserManager::class)
->disableOriginalConstructor()->getMock();
diff --git a/apps/files_trashbin/tests/TrashbinTest.php b/apps/files_trashbin/tests/TrashbinTest.php
index d8486ccbdc2..6104a242104 100644
--- a/apps/files_trashbin/tests/TrashbinTest.php
+++ b/apps/files_trashbin/tests/TrashbinTest.php
@@ -354,7 +354,7 @@ class TrashbinTest extends \Test\TestCase {
* Test restoring a file
*/
public function testRestoreFileInRoot(): void {
- $userFolder = \OCP\Server::get(IRootFolder::class)->getUserFolder(self::TEST_TRASHBIN_USER1);
+ $userFolder = Server::get(IRootFolder::class)->getUserFolder(self::TEST_TRASHBIN_USER1);
$file = $userFolder->newFile('file1.txt');
$file->putContent('foo');
@@ -386,7 +386,7 @@ class TrashbinTest extends \Test\TestCase {
* Test restoring a file in subfolder
*/
public function testRestoreFileInSubfolder(): void {
- $userFolder = \OCP\Server::get(IRootFolder::class)->getUserFolder(self::TEST_TRASHBIN_USER1);
+ $userFolder = Server::get(IRootFolder::class)->getUserFolder(self::TEST_TRASHBIN_USER1);
$folder = $userFolder->newFolder('folder');
$file = $folder->newFile('file1.txt');
$file->putContent('foo');
@@ -419,7 +419,7 @@ class TrashbinTest extends \Test\TestCase {
* Test restoring a folder
*/
public function testRestoreFolder(): void {
- $userFolder = \OCP\Server::get(IRootFolder::class)->getUserFolder(self::TEST_TRASHBIN_USER1);
+ $userFolder = Server::get(IRootFolder::class)->getUserFolder(self::TEST_TRASHBIN_USER1);
$folder = $userFolder->newFolder('folder');
$file = $folder->newFile('file1.txt');
$file->putContent('foo');
@@ -452,7 +452,7 @@ class TrashbinTest extends \Test\TestCase {
* Test restoring a file from inside a trashed folder
*/
public function testRestoreFileFromTrashedSubfolder(): void {
- $userFolder = \OCP\Server::get(IRootFolder::class)->getUserFolder(self::TEST_TRASHBIN_USER1);
+ $userFolder = Server::get(IRootFolder::class)->getUserFolder(self::TEST_TRASHBIN_USER1);
$folder = $userFolder->newFolder('folder');
$file = $folder->newFile('file1.txt');
$file->putContent('foo');
@@ -486,7 +486,7 @@ class TrashbinTest extends \Test\TestCase {
* The file should then land in the root.
*/
public function testRestoreFileWithMissingSourceFolder(): void {
- $userFolder = \OCP\Server::get(IRootFolder::class)->getUserFolder(self::TEST_TRASHBIN_USER1);
+ $userFolder = Server::get(IRootFolder::class)->getUserFolder(self::TEST_TRASHBIN_USER1);
$folder = $userFolder->newFolder('folder');
$file = $folder->newFile('file1.txt');
$file->putContent('foo');
@@ -523,7 +523,7 @@ class TrashbinTest extends \Test\TestCase {
* with the same name in the root folder
*/
public function testRestoreFileDoesNotOverwriteExistingInRoot(): void {
- $userFolder = \OCP\Server::get(IRootFolder::class)->getUserFolder(self::TEST_TRASHBIN_USER1);
+ $userFolder = Server::get(IRootFolder::class)->getUserFolder(self::TEST_TRASHBIN_USER1);
$file = $userFolder->newFile('file1.txt');
$file->putContent('foo');
@@ -563,7 +563,7 @@ class TrashbinTest extends \Test\TestCase {
* with the same name in the source folder
*/
public function testRestoreFileDoesNotOverwriteExistingInSubfolder(): void {
- $userFolder = \OCP\Server::get(IRootFolder::class)->getUserFolder(self::TEST_TRASHBIN_USER1);
+ $userFolder = Server::get(IRootFolder::class)->getUserFolder(self::TEST_TRASHBIN_USER1);
$folder = $userFolder->newFolder('folder');
$file = $folder->newFile('file1.txt');
$file->putContent('foo');
@@ -617,7 +617,7 @@ class TrashbinTest extends \Test\TestCase {
* the file to root instead
*/
public function testRestoreFileIntoReadOnlySourceFolder(): void {
- $userFolder = \OCP\Server::get(IRootFolder::class)->getUserFolder(self::TEST_TRASHBIN_USER1);
+ $userFolder = Server::get(IRootFolder::class)->getUserFolder(self::TEST_TRASHBIN_USER1);
$folder = $userFolder->newFolder('folder');
$file = $folder->newFile('file1.txt');
$file->putContent('foo');
@@ -673,7 +673,7 @@ class TrashbinTest extends \Test\TestCase {
Filesystem::tearDown();
\OC_User::setUserId($user);
\OC_Util::setupFS($user);
- \OCP\Server::get(IRootFolder::class)->getUserFolder($user);
+ Server::get(IRootFolder::class)->getUserFolder($user);
}
}