aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/SystemTag/SystemTagObjectMapperTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/SystemTag/SystemTagObjectMapperTest.php')
-rw-r--r--tests/lib/SystemTag/SystemTagObjectMapperTest.php54
1 files changed, 27 insertions, 27 deletions
diff --git a/tests/lib/SystemTag/SystemTagObjectMapperTest.php b/tests/lib/SystemTag/SystemTagObjectMapperTest.php
index 2c838e0a6b3..a43bda3b659 100644
--- a/tests/lib/SystemTag/SystemTagObjectMapperTest.php
+++ b/tests/lib/SystemTag/SystemTagObjectMapperTest.php
@@ -1,11 +1,9 @@
<?php
/**
- * Copyright (c) 2015 Vincent Petry <pvince81@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\SystemTag;
@@ -15,6 +13,7 @@ use OC\SystemTag\SystemTagManager;
use OC\SystemTag\SystemTagObjectMapper;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IDBConnection;
+use OCP\Server;
use OCP\SystemTag\ISystemTag;
use OCP\SystemTag\ISystemTagManager;
use OCP\SystemTag\ISystemTagObjectMapper;
@@ -66,7 +65,7 @@ class SystemTagObjectMapperTest extends TestCase {
protected function setUp(): void {
parent::setUp();
- $this->connection = \OC::$server->getDatabaseConnection();
+ $this->connection = Server::get(IDBConnection::class);
$this->pruneTagsTables();
$this->tagManager = $this->createMock(ISystemTagManager::class);
@@ -115,7 +114,7 @@ class SystemTagObjectMapperTest extends TestCase {
$query->delete(SystemTagManager::TAG_TABLE)->execute();
}
- public function testGetTagIdsForObjects() {
+ public function testGetTagIdsForObjects(): void {
$tagIdMapping = $this->tagMapper->getTagIdsForObjects(
['1', '2', '3', '4'],
'testtype'
@@ -129,7 +128,7 @@ class SystemTagObjectMapperTest extends TestCase {
], $tagIdMapping);
}
- public function testGetTagIdsForNoObjects() {
+ public function testGetTagIdsForNoObjects(): void {
$tagIdMapping = $this->tagMapper->getTagIdsForObjects(
[],
'testtype'
@@ -138,7 +137,7 @@ class SystemTagObjectMapperTest extends TestCase {
$this->assertEquals([], $tagIdMapping);
}
- public function testGetTagIdsForALotOfObjects() {
+ public function testGetTagIdsForALotOfObjects(): void {
$ids = range(1, 10500);
$tagIdMapping = $this->tagMapper->getTagIdsForObjects(
$ids,
@@ -149,11 +148,12 @@ class SystemTagObjectMapperTest extends TestCase {
$this->assertEquals([$this->tag1->getId(), $this->tag2->getId()], $tagIdMapping[1]);
}
- public function testGetObjectsForTags() {
+ public function testGetObjectsForTags(): void {
$objectIds = $this->tagMapper->getObjectIdsForTags(
[$this->tag1->getId(), $this->tag2->getId(), $this->tag3->getId()],
'testtype'
);
+ sort($objectIds);
$this->assertEquals([
'1',
@@ -161,7 +161,7 @@ class SystemTagObjectMapperTest extends TestCase {
], $objectIds);
}
- public function testGetObjectsForTagsLimit() {
+ public function testGetObjectsForTagsLimit(): void {
$objectIds = $this->tagMapper->getObjectIdsForTags(
[$this->tag1->getId()],
'testtype',
@@ -174,7 +174,7 @@ class SystemTagObjectMapperTest extends TestCase {
}
- public function testGetObjectsForTagsLimitWithMultipleTags() {
+ public function testGetObjectsForTagsLimitWithMultipleTags(): void {
$this->expectException(\InvalidArgumentException::class);
$this->tagMapper->getObjectIdsForTags(
@@ -184,7 +184,7 @@ class SystemTagObjectMapperTest extends TestCase {
);
}
- public function testGetObjectsForTagsLimitOffset() {
+ public function testGetObjectsForTagsLimitOffset(): void {
$objectIds = $this->tagMapper->getObjectIdsForTags(
[$this->tag1->getId()],
'testtype',
@@ -198,8 +198,8 @@ class SystemTagObjectMapperTest extends TestCase {
}
- public function testGetObjectsForNonExistingTag() {
- $this->expectException(\OCP\SystemTag\TagNotFoundException::class);
+ public function testGetObjectsForNonExistingTag(): void {
+ $this->expectException(TagNotFoundException::class);
$this->tagMapper->getObjectIdsForTags(
[100],
@@ -207,7 +207,7 @@ class SystemTagObjectMapperTest extends TestCase {
);
}
- public function testAssignUnassignTags() {
+ public function testAssignUnassignTags(): void {
$this->tagMapper->unassignTags('1', 'testtype', [$this->tag1->getId()]);
$tagIdMapping = $this->tagMapper->getTagIdsForObjects('1', 'testtype');
@@ -225,7 +225,7 @@ class SystemTagObjectMapperTest extends TestCase {
], $tagIdMapping);
}
- public function testReAssignUnassignTags() {
+ public function testReAssignUnassignTags(): void {
// reassign tag1
$this->tagMapper->assignTags('1', 'testtype', [$this->tag1->getId()]);
@@ -236,13 +236,13 @@ class SystemTagObjectMapperTest extends TestCase {
}
- public function testAssignNonExistingTags() {
- $this->expectException(\OCP\SystemTag\TagNotFoundException::class);
+ public function testAssignNonExistingTags(): void {
+ $this->expectException(TagNotFoundException::class);
$this->tagMapper->assignTags('1', 'testtype', [100]);
}
- public function testAssignNonExistingTagInArray() {
+ public function testAssignNonExistingTagInArray(): void {
$caught = false;
try {
$this->tagMapper->assignTags('1', 'testtype', [100, $this->tag3->getId()]);
@@ -263,13 +263,13 @@ class SystemTagObjectMapperTest extends TestCase {
}
- public function testUnassignNonExistingTags() {
- $this->expectException(\OCP\SystemTag\TagNotFoundException::class);
+ public function testUnassignNonExistingTags(): void {
+ $this->expectException(TagNotFoundException::class);
$this->tagMapper->unassignTags('1', 'testtype', [100]);
}
- public function testUnassignNonExistingTagsInArray() {
+ public function testUnassignNonExistingTagsInArray(): void {
$caught = false;
try {
$this->tagMapper->unassignTags('1', 'testtype', [100, $this->tag1->getId()]);
@@ -289,7 +289,7 @@ class SystemTagObjectMapperTest extends TestCase {
], $tagIdMapping, 'None of the tags got unassigned');
}
- public function testHaveTagAllMatches() {
+ public function testHaveTagAllMatches(): void {
$this->assertTrue(
$this->tagMapper->haveTag(
['1'],
@@ -341,7 +341,7 @@ class SystemTagObjectMapperTest extends TestCase {
);
}
- public function testHaveTagAtLeastOneMatch() {
+ public function testHaveTagAtLeastOneMatch(): void {
$this->assertTrue(
$this->tagMapper->haveTag(
['1'],
@@ -394,8 +394,8 @@ class SystemTagObjectMapperTest extends TestCase {
}
- public function testHaveTagNonExisting() {
- $this->expectException(\OCP\SystemTag\TagNotFoundException::class);
+ public function testHaveTagNonExisting(): void {
+ $this->expectException(TagNotFoundException::class);
$this->tagMapper->haveTag(
['1'],