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.php26
1 files changed, 14 insertions, 12 deletions
diff --git a/apps/files/tests/BackgroundJob/ScanFilesTest.php b/apps/files/tests/BackgroundJob/ScanFilesTest.php
index e4ba8348d64..00d9ed823f9 100644
--- a/apps/files/tests/BackgroundJob/ScanFilesTest.php
+++ b/apps/files/tests/BackgroundJob/ScanFilesTest.php
@@ -1,5 +1,6 @@
<?php
+declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -12,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;
@@ -29,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();
@@ -40,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,
@@ -51,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 {
@@ -79,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())
@@ -87,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]);