aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/tests/BackgroundJob/ScanFilesTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/tests/BackgroundJob/ScanFilesTest.php')
-rw-r--r--apps/files/tests/BackgroundJob/ScanFilesTest.php50
1 files changed, 18 insertions, 32 deletions
diff --git a/apps/files/tests/BackgroundJob/ScanFilesTest.php b/apps/files/tests/BackgroundJob/ScanFilesTest.php
index cf0120da09d..00d9ed823f9 100644
--- a/apps/files/tests/BackgroundJob/ScanFilesTest.php
+++ b/apps/files/tests/BackgroundJob/ScanFilesTest.php
@@ -1,25 +1,10 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Lukas Reschke <lukas@statuscode.ch>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @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\Tests\BackgroundJob;
@@ -28,8 +13,11 @@ use OC\Files\Storage\Temporary;
use OCA\Files\BackgroundJob\ScanFiles;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\EventDispatcher\IEventDispatcher;
+use OCP\Files\Config\IUserMountCache;
use OCP\IConfig;
+use OCP\IDBConnection;
use OCP\IUser;
+use OCP\Server;
use Psr\Log\LoggerInterface;
use Test\TestCase;
use Test\Traits\MountProviderTrait;
@@ -45,10 +33,8 @@ class ScanFilesTest extends TestCase {
use UserTrait;
use MountProviderTrait;
- /** @var ScanFiles */
- private $scanFiles;
- /** @var \OCP\Files\Config\IUserMountCache */
- private $mountCache;
+ private ScanFiles $scanFiles;
+ private IUserMountCache $mountCache;
protected function setUp(): void {
parent::setUp();
@@ -56,10 +42,10 @@ class ScanFilesTest extends TestCase {
$config = $this->createMock(IConfig::class);
$dispatcher = $this->createMock(IEventDispatcher::class);
$logger = $this->createMock(LoggerInterface::class);
- $connection = \OC::$server->getDatabaseConnection();
- $this->mountCache = \OC::$server->getUserMountCache();
+ $connection = Server::get(IDBConnection::class);
+ $this->mountCache = Server::get(IUserMountCache::class);
- $this->scanFiles = $this->getMockBuilder('\OCA\Files\BackgroundJob\ScanFiles')
+ $this->scanFiles = $this->getMockBuilder(ScanFiles::class)
->setConstructorArgs([
$config,
$dispatcher,
@@ -67,12 +53,12 @@ class ScanFilesTest extends TestCase {
$connection,
$this->createMock(ITimeFactory::class)
])
- ->setMethods(['runScanner'])
+ ->onlyMethods(['runScanner'])
->getMock();
}
- private function runJob() {
- $this->invokePrivate($this->scanFiles, 'run', [[]]);
+ private function runJob(): void {
+ self::invokePrivate($this->scanFiles, 'run', [[]]);
}
private function getUser(string $userId): IUser {
@@ -95,7 +81,7 @@ class ScanFilesTest extends TestCase {
return $storage;
}
- public function testAllScanned() {
+ public function testAllScanned(): void {
$this->setupStorage('foouser', '/foousers/files/foo');
$this->scanFiles->expects($this->never())
@@ -103,7 +89,7 @@ class ScanFilesTest extends TestCase {
$this->runJob();
}
- public function testUnscanned() {
+ public function testUnscanned(): void {
$storage = $this->setupStorage('foouser', '/foousers/files/foo');
$storage->getCache()->put('foo', ['size' => -1]);