aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/tests
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2024-10-10 12:40:31 +0200
committerCôme Chilliet <come.chilliet@nextcloud.com>2024-10-15 10:40:25 +0200
commit1580c8612b01bfa780d1a7372080a27d182fb7dd (patch)
treeb2776d0cd254ac9d6e54828978ce18b702f550d5 /apps/files/tests
parent4ff9b3e0ce53227e2be47c4c2dcb1fdc3e540b5f (diff)
downloadnextcloud-server-1580c8612b01bfa780d1a7372080a27d182fb7dd.tar.gz
nextcloud-server-1580c8612b01bfa780d1a7372080a27d182fb7dd.zip
chore(apps): Apply new rector configuration to autouse classes
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps/files/tests')
-rw-r--r--apps/files/tests/Command/DeleteOrphanedFilesTest.php5
-rw-r--r--apps/files/tests/Controller/ApiControllerTest.php8
-rw-r--r--apps/files/tests/Controller/ViewControllerTest.php10
-rw-r--r--apps/files/tests/HelperTest.php15
-rw-r--r--apps/files/tests/Service/TagServiceTest.php5
5 files changed, 27 insertions, 16 deletions
diff --git a/apps/files/tests/Command/DeleteOrphanedFilesTest.php b/apps/files/tests/Command/DeleteOrphanedFilesTest.php
index 6e9fbead34e..e480f7b632e 100644
--- a/apps/files/tests/Command/DeleteOrphanedFilesTest.php
+++ b/apps/files/tests/Command/DeleteOrphanedFilesTest.php
@@ -12,6 +12,7 @@ use OCA\Files\Command\DeleteOrphanedFiles;
use OCP\Files\IRootFolder;
use OCP\Files\StorageNotAvailableException;
use OCP\IDBConnection;
+use OCP\Server;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase;
@@ -32,7 +33,7 @@ class DeleteOrphanedFilesTest extends TestCase {
protected function setUp(): void {
parent::setUp();
- $this->connection = \OCP\Server::get(IDBConnection::class);
+ $this->connection = Server::get(IDBConnection::class);
$this->user1 = $this->getUniqueID('user1_');
@@ -81,7 +82,7 @@ class DeleteOrphanedFilesTest extends TestCase {
->disableOriginalConstructor()
->getMock();
- $rootFolder = \OCP\Server::get(IRootFolder::class);
+ $rootFolder = Server::get(IRootFolder::class);
// scan home storage so that mounts are properly setup
$rootFolder->getUserFolder($this->user1)->getStorage()->getScanner()->scan('');
diff --git a/apps/files/tests/Controller/ApiControllerTest.php b/apps/files/tests/Controller/ApiControllerTest.php
index ad2a6a15b2b..e7f8b962a45 100644
--- a/apps/files/tests/Controller/ApiControllerTest.php
+++ b/apps/files/tests/Controller/ApiControllerTest.php
@@ -12,6 +12,8 @@ use OCA\Files\Service\UserConfig;
use OCA\Files\Service\ViewConfig;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
+use OCP\AppFramework\Http\FileDisplayResponse;
+use OCP\AppFramework\Http\Response;
use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
@@ -211,7 +213,7 @@ class ApiControllerTest extends TestCase {
$ret = $this->apiController->getThumbnail(10, 10, 'known.jpg');
$this->assertEquals(Http::STATUS_OK, $ret->getStatus());
- $this->assertInstanceOf(Http\FileDisplayResponse::class, $ret);
+ $this->assertInstanceOf(FileDisplayResponse::class, $ret);
}
public function testShowHiddenFiles(): void {
@@ -221,7 +223,7 @@ class ApiControllerTest extends TestCase {
->method('setUserValue')
->with($this->user->getUID(), 'files', 'show_hidden', '0');
- $expected = new Http\Response();
+ $expected = new Response();
$actual = $this->apiController->showHiddenFiles($show);
$this->assertEquals($expected, $actual);
@@ -234,7 +236,7 @@ class ApiControllerTest extends TestCase {
->method('setUserValue')
->with($this->user->getUID(), 'files', 'crop_image_previews', '1');
- $expected = new Http\Response();
+ $expected = new Response();
$actual = $this->apiController->cropImagePreviews($crop);
$this->assertEquals($expected, $actual);
diff --git a/apps/files/tests/Controller/ViewControllerTest.php b/apps/files/tests/Controller/ViewControllerTest.php
index a6eba1f9eaf..0c0647cc415 100644
--- a/apps/files/tests/Controller/ViewControllerTest.php
+++ b/apps/files/tests/Controller/ViewControllerTest.php
@@ -12,7 +12,9 @@ use OCA\Files\Controller\ViewController;
use OCA\Files\Service\UserConfig;
use OCA\Files\Service\ViewConfig;
use OCP\App\IAppManager;
-use OCP\AppFramework\Http;
+use OCP\AppFramework\Http\ContentSecurityPolicy;
+use OCP\AppFramework\Http\RedirectResponse;
+use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Services\IInitialState;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\File;
@@ -133,11 +135,11 @@ class ViewControllerTest extends TestCase {
->method('getAppValue')
->willReturnArgument(2);
- $expected = new Http\TemplateResponse(
+ $expected = new TemplateResponse(
'files',
'index',
);
- $policy = new Http\ContentSecurityPolicy();
+ $policy = new ContentSecurityPolicy();
$policy->addAllowedWorkerSrcDomain('\'self\'');
$policy->addAllowedFrameDomain('\'self\'');
$expected->setContentSecurityPolicy($policy);
@@ -193,7 +195,7 @@ class ViewControllerTest extends TestCase {
->with('files.view.indexViewFileid', ['view' => 'trashbin', 'dir' => '/test.d1462861890/sub', 'fileid' => '123'])
->willReturn('/apps/files/trashbin/123?dir=/test.d1462861890/sub');
- $expected = new Http\RedirectResponse('/apps/files/trashbin/123?dir=/test.d1462861890/sub');
+ $expected = new RedirectResponse('/apps/files/trashbin/123?dir=/test.d1462861890/sub');
$this->assertEquals($expected, $this->viewController->index('', '', '123'));
}
}
diff --git a/apps/files/tests/HelperTest.php b/apps/files/tests/HelperTest.php
index fdcef8f7125..27b1de1322f 100644
--- a/apps/files/tests/HelperTest.php
+++ b/apps/files/tests/HelperTest.php
@@ -1,5 +1,10 @@
<?php
+use OC\Files\FileInfo;
+use OCA\Files\Helper;
+use OCP\ITagManager;
+use OCP\ITags;
+
/**
* SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -7,7 +12,7 @@
*/
class HelperTest extends \Test\TestCase {
private function makeFileInfo($name, $size, $mtime, $isDir = false) {
- return new \OC\Files\FileInfo(
+ return new FileInfo(
'/' . $name,
null,
'/',
@@ -79,7 +84,7 @@ class HelperTest extends \Test\TestCase {
$this->markTestSkipped('Skip mtime sorting on 32bit');
}
$files = self::getTestFileList();
- $files = \OCA\Files\Helper::sortFiles($files, $sort, $sortDescending);
+ $files = Helper::sortFiles($files, $sort, $sortDescending);
$fileNames = [];
foreach ($files as $fileInfo) {
$fileNames[] = $fileInfo->getName();
@@ -91,8 +96,8 @@ class HelperTest extends \Test\TestCase {
}
public function testPopulateTags(): void {
- $tagManager = $this->createMock(\OCP\ITagManager::class);
- $tagger = $this->createMock(\OCP\ITags::class);
+ $tagManager = $this->createMock(ITagManager::class);
+ $tagger = $this->createMock(ITags::class);
$tagManager->method('load')
->with('files')
@@ -113,7 +118,7 @@ class HelperTest extends \Test\TestCase {
->with([10, 22, 42])
->willReturn($tags);
- $result = \OCA\Files\Helper::populateTags($data, 'id', $tagManager);
+ $result = Helper::populateTags($data, 'id', $tagManager);
$this->assertSame([
['id' => 10, 'tags' => ['tag3']],
diff --git a/apps/files/tests/Service/TagServiceTest.php b/apps/files/tests/Service/TagServiceTest.php
index 7922c45a639..0e3ac66ef38 100644
--- a/apps/files/tests/Service/TagServiceTest.php
+++ b/apps/files/tests/Service/TagServiceTest.php
@@ -10,6 +10,7 @@ namespace OCA\Files\Tests\Service;
use OCA\Files\Service\TagService;
use OCP\Activity\IManager;
use OCP\EventDispatcher\IEventDispatcher;
+use OCP\Files\NotFoundException;
use OCP\ITags;
use OCP\IUser;
use OCP\IUserSession;
@@ -43,7 +44,7 @@ class TagServiceTest extends \Test\TestCase {
private $dispatcher;
/**
- * @var \OCA\Files\Service\TagService|\PHPUnit\Framework\MockObject\MockObject
+ * @var TagService|\PHPUnit\Framework\MockObject\MockObject
*/
private $tagService;
@@ -134,7 +135,7 @@ class TagServiceTest extends \Test\TestCase {
$caught = false;
try {
$this->tagService->updateFileTags('subdir/unexist.txt', [$tag1]);
- } catch (\OCP\Files\NotFoundException $e) {
+ } catch (NotFoundException $e) {
$caught = true;
}
$this->assertTrue($caught);