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.php46
1 files changed, 24 insertions, 22 deletions
diff --git a/tests/lib/SystemTag/SystemTagObjectMapperTest.php b/tests/lib/SystemTag/SystemTagObjectMapperTest.php
index c9aff9f5183..a43bda3b659 100644
--- a/tests/lib/SystemTag/SystemTagObjectMapperTest.php
+++ b/tests/lib/SystemTag/SystemTagObjectMapperTest.php
@@ -13,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;
@@ -64,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);
@@ -113,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'
@@ -127,7 +128,7 @@ class SystemTagObjectMapperTest extends TestCase {
], $tagIdMapping);
}
- public function testGetTagIdsForNoObjects() {
+ public function testGetTagIdsForNoObjects(): void {
$tagIdMapping = $this->tagMapper->getTagIdsForObjects(
[],
'testtype'
@@ -136,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,
@@ -147,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',
@@ -159,7 +161,7 @@ class SystemTagObjectMapperTest extends TestCase {
], $objectIds);
}
- public function testGetObjectsForTagsLimit() {
+ public function testGetObjectsForTagsLimit(): void {
$objectIds = $this->tagMapper->getObjectIdsForTags(
[$this->tag1->getId()],
'testtype',
@@ -172,7 +174,7 @@ class SystemTagObjectMapperTest extends TestCase {
}
- public function testGetObjectsForTagsLimitWithMultipleTags() {
+ public function testGetObjectsForTagsLimitWithMultipleTags(): void {
$this->expectException(\InvalidArgumentException::class);
$this->tagMapper->getObjectIdsForTags(
@@ -182,7 +184,7 @@ class SystemTagObjectMapperTest extends TestCase {
);
}
- public function testGetObjectsForTagsLimitOffset() {
+ public function testGetObjectsForTagsLimitOffset(): void {
$objectIds = $this->tagMapper->getObjectIdsForTags(
[$this->tag1->getId()],
'testtype',
@@ -196,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],
@@ -205,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');
@@ -223,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()]);
@@ -234,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()]);
@@ -261,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()]);
@@ -287,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'],
@@ -339,7 +341,7 @@ class SystemTagObjectMapperTest extends TestCase {
);
}
- public function testHaveTagAtLeastOneMatch() {
+ public function testHaveTagAtLeastOneMatch(): void {
$this->assertTrue(
$this->tagMapper->haveTag(
['1'],
@@ -392,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'],