aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/tests/BackgroundJob
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/tests/BackgroundJob')
-rw-r--r--apps/files/tests/BackgroundJob/DeleteOrphanedItemsJobTest.php49
-rw-r--r--apps/files/tests/BackgroundJob/ScanFilesTest.php15
2 files changed, 32 insertions, 32 deletions
diff --git a/apps/files/tests/BackgroundJob/DeleteOrphanedItemsJobTest.php b/apps/files/tests/BackgroundJob/DeleteOrphanedItemsJobTest.php
index e31b1574815..3f811fca407 100644
--- a/apps/files/tests/BackgroundJob/DeleteOrphanedItemsJobTest.php
+++ b/apps/files/tests/BackgroundJob/DeleteOrphanedItemsJobTest.php
@@ -1,5 +1,6 @@
<?php
+declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -33,16 +34,16 @@ class DeleteOrphanedItemsJobTest extends \Test\TestCase {
$this->logger = Server::get(LoggerInterface::class);
}
- protected function cleanMapping($table) {
+ protected function cleanMapping(string $table): void {
$query = $this->connection->getQueryBuilder();
- $query->delete($table)->execute();
+ $query->delete($table)->executeStatement();
}
- protected function getMappings($table) {
+ protected function getMappings(string $table): array {
$query = $this->connection->getQueryBuilder();
$query->select('*')
->from($table);
- $result = $query->execute();
+ $result = $query->executeQuery();
$mapping = $result->fetchAll();
$result->closeCursor();
@@ -61,7 +62,7 @@ class DeleteOrphanedItemsJobTest extends \Test\TestCase {
'storage' => $query->createNamedParameter(1337, IQueryBuilder::PARAM_INT),
'path' => $query->createNamedParameter('apps/files/tests/deleteorphanedtagsjobtest.php'),
'path_hash' => $query->createNamedParameter(md5('apps/files/tests/deleteorphanedtagsjobtest.php')),
- ])->execute();
+ ])->executeStatement();
$fileId = $query->getLastInsertId();
// Existing file
@@ -71,7 +72,7 @@ class DeleteOrphanedItemsJobTest extends \Test\TestCase {
'objectid' => $query->createNamedParameter($fileId, IQueryBuilder::PARAM_INT),
'objecttype' => $query->createNamedParameter('files'),
'systemtagid' => $query->createNamedParameter(1337, IQueryBuilder::PARAM_INT),
- ])->execute();
+ ])->executeStatement();
// Non-existing file
$query = $this->connection->getQueryBuilder();
@@ -80,13 +81,13 @@ class DeleteOrphanedItemsJobTest extends \Test\TestCase {
'objectid' => $query->createNamedParameter($fileId + 1, IQueryBuilder::PARAM_INT),
'objecttype' => $query->createNamedParameter('files'),
'systemtagid' => $query->createNamedParameter(1337, IQueryBuilder::PARAM_INT),
- ])->execute();
+ ])->executeStatement();
$mapping = $this->getMappings('systemtag_object_mapping');
$this->assertCount(2, $mapping);
$job = new DeleteOrphanedItems($this->timeFactory, $this->connection, $this->logger);
- $this->invokePrivate($job, 'cleanSystemTags');
+ self::invokePrivate($job, 'cleanSystemTags');
$mapping = $this->getMappings('systemtag_object_mapping');
$this->assertCount(1, $mapping);
@@ -94,7 +95,7 @@ class DeleteOrphanedItemsJobTest extends \Test\TestCase {
$query = $this->connection->getQueryBuilder();
$query->delete('filecache')
->where($query->expr()->eq('fileid', $query->createNamedParameter($fileId, IQueryBuilder::PARAM_INT)))
- ->execute();
+ ->executeStatement();
$this->cleanMapping('systemtag_object_mapping');
}
@@ -110,7 +111,7 @@ class DeleteOrphanedItemsJobTest extends \Test\TestCase {
'storage' => $query->createNamedParameter(1337, IQueryBuilder::PARAM_INT),
'path' => $query->createNamedParameter('apps/files/tests/deleteorphanedtagsjobtest.php'),
'path_hash' => $query->createNamedParameter(md5('apps/files/tests/deleteorphanedtagsjobtest.php')),
- ])->execute();
+ ])->executeStatement();
$fileId = $query->getLastInsertId();
// Existing file
@@ -120,7 +121,7 @@ class DeleteOrphanedItemsJobTest extends \Test\TestCase {
'objid' => $query->createNamedParameter($fileId, IQueryBuilder::PARAM_INT),
'type' => $query->createNamedParameter('files'),
'categoryid' => $query->createNamedParameter(1337, IQueryBuilder::PARAM_INT),
- ])->execute();
+ ])->executeStatement();
// Non-existing file
$query = $this->connection->getQueryBuilder();
@@ -129,13 +130,13 @@ class DeleteOrphanedItemsJobTest extends \Test\TestCase {
'objid' => $query->createNamedParameter($fileId + 1, IQueryBuilder::PARAM_INT),
'type' => $query->createNamedParameter('files'),
'categoryid' => $query->createNamedParameter(1337, IQueryBuilder::PARAM_INT),
- ])->execute();
+ ])->executeStatement();
$mapping = $this->getMappings('vcategory_to_object');
$this->assertCount(2, $mapping);
$job = new DeleteOrphanedItems($this->timeFactory, $this->connection, $this->logger);
- $this->invokePrivate($job, 'cleanUserTags');
+ self::invokePrivate($job, 'cleanUserTags');
$mapping = $this->getMappings('vcategory_to_object');
$this->assertCount(1, $mapping);
@@ -143,7 +144,7 @@ class DeleteOrphanedItemsJobTest extends \Test\TestCase {
$query = $this->connection->getQueryBuilder();
$query->delete('filecache')
->where($query->expr()->eq('fileid', $query->createNamedParameter($fileId, IQueryBuilder::PARAM_INT)))
- ->execute();
+ ->executeStatement();
$this->cleanMapping('vcategory_to_object');
}
@@ -159,7 +160,7 @@ class DeleteOrphanedItemsJobTest extends \Test\TestCase {
'storage' => $query->createNamedParameter(1337, IQueryBuilder::PARAM_INT),
'path' => $query->createNamedParameter('apps/files/tests/deleteorphanedtagsjobtest.php'),
'path_hash' => $query->createNamedParameter(md5('apps/files/tests/deleteorphanedtagsjobtest.php')),
- ])->execute();
+ ])->executeStatement();
$fileId = $query->getLastInsertId();
// Existing file
@@ -170,7 +171,7 @@ class DeleteOrphanedItemsJobTest extends \Test\TestCase {
'object_type' => $query->createNamedParameter('files'),
'actor_id' => $query->createNamedParameter('Alice', IQueryBuilder::PARAM_INT),
'actor_type' => $query->createNamedParameter('users'),
- ])->execute();
+ ])->executeStatement();
// Non-existing file
$query = $this->connection->getQueryBuilder();
@@ -180,13 +181,13 @@ class DeleteOrphanedItemsJobTest extends \Test\TestCase {
'object_type' => $query->createNamedParameter('files'),
'actor_id' => $query->createNamedParameter('Alice', IQueryBuilder::PARAM_INT),
'actor_type' => $query->createNamedParameter('users'),
- ])->execute();
+ ])->executeStatement();
$mapping = $this->getMappings('comments');
$this->assertCount(2, $mapping);
$job = new DeleteOrphanedItems($this->timeFactory, $this->connection, $this->logger);
- $this->invokePrivate($job, 'cleanComments');
+ self::invokePrivate($job, 'cleanComments');
$mapping = $this->getMappings('comments');
$this->assertCount(1, $mapping);
@@ -194,7 +195,7 @@ class DeleteOrphanedItemsJobTest extends \Test\TestCase {
$query = $this->connection->getQueryBuilder();
$query->delete('filecache')
->where($query->expr()->eq('fileid', $query->createNamedParameter($fileId, IQueryBuilder::PARAM_INT)))
- ->execute();
+ ->executeStatement();
$this->cleanMapping('comments');
}
@@ -210,7 +211,7 @@ class DeleteOrphanedItemsJobTest extends \Test\TestCase {
'storage' => $query->createNamedParameter(1337, IQueryBuilder::PARAM_INT),
'path' => $query->createNamedParameter('apps/files/tests/deleteorphanedtagsjobtest.php'),
'path_hash' => $query->createNamedParameter(md5('apps/files/tests/deleteorphanedtagsjobtest.php')),
- ])->execute();
+ ])->executeStatement();
$fileId = $query->getLastInsertId();
// Existing file
@@ -220,7 +221,7 @@ class DeleteOrphanedItemsJobTest extends \Test\TestCase {
'object_id' => $query->createNamedParameter($fileId, IQueryBuilder::PARAM_INT),
'object_type' => $query->createNamedParameter('files'),
'user_id' => $query->createNamedParameter('Alice', IQueryBuilder::PARAM_INT),
- ])->execute();
+ ])->executeStatement();
// Non-existing file
$query = $this->connection->getQueryBuilder();
@@ -229,13 +230,13 @@ class DeleteOrphanedItemsJobTest extends \Test\TestCase {
'object_id' => $query->createNamedParameter($fileId + 1, IQueryBuilder::PARAM_INT),
'object_type' => $query->createNamedParameter('files'),
'user_id' => $query->createNamedParameter('Alice', IQueryBuilder::PARAM_INT),
- ])->execute();
+ ])->executeStatement();
$mapping = $this->getMappings('comments_read_markers');
$this->assertCount(2, $mapping);
$job = new DeleteOrphanedItems($this->timeFactory, $this->connection, $this->logger);
- $this->invokePrivate($job, 'cleanCommentMarkers');
+ self::invokePrivate($job, 'cleanCommentMarkers');
$mapping = $this->getMappings('comments_read_markers');
$this->assertCount(1, $mapping);
@@ -243,7 +244,7 @@ class DeleteOrphanedItemsJobTest extends \Test\TestCase {
$query = $this->connection->getQueryBuilder();
$query->delete('filecache')
->where($query->expr()->eq('fileid', $query->createNamedParameter($fileId, IQueryBuilder::PARAM_INT)))
- ->execute();
+ ->executeStatement();
$this->cleanMapping('comments_read_markers');
}
}
diff --git a/apps/files/tests/BackgroundJob/ScanFilesTest.php b/apps/files/tests/BackgroundJob/ScanFilesTest.php
index ce602805aa2..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.
@@ -32,10 +33,8 @@ class ScanFilesTest extends TestCase {
use UserTrait;
use MountProviderTrait;
- /** @var ScanFiles */
- private $scanFiles;
- /** @var IUserMountCache */
- private $mountCache;
+ private ScanFiles $scanFiles;
+ private IUserMountCache $mountCache;
protected function setUp(): void {
parent::setUp();
@@ -46,7 +45,7 @@ class ScanFilesTest extends TestCase {
$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,
@@ -54,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 {