|
|
|
|
@ -102,10 +102,10 @@ class SystemTagObjectMapperTest extends TestCase {
|
|
|
|
|
return $result;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
$this->tagMapper->assignTags(1, 'testtype', $this->tag1->getId());
|
|
|
|
|
$this->tagMapper->assignTags(1, 'testtype', $this->tag2->getId());
|
|
|
|
|
$this->tagMapper->assignTags(2, 'testtype', $this->tag1->getId());
|
|
|
|
|
$this->tagMapper->assignTags(3, 'anothertype', $this->tag1->getId());
|
|
|
|
|
$this->tagMapper->assignTags('1', 'testtype', $this->tag1->getId());
|
|
|
|
|
$this->tagMapper->assignTags('1', 'testtype', $this->tag2->getId());
|
|
|
|
|
$this->tagMapper->assignTags('2', 'testtype', $this->tag1->getId());
|
|
|
|
|
$this->tagMapper->assignTags('3', 'anothertype', $this->tag1->getId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function tearDown() {
|
|
|
|
|
@ -121,15 +121,15 @@ class SystemTagObjectMapperTest extends TestCase {
|
|
|
|
|
|
|
|
|
|
public function testGetTagsForObjects() {
|
|
|
|
|
$tagIdMapping = $this->tagMapper->getTagIdsForObjects(
|
|
|
|
|
[1, 2, 3, 4],
|
|
|
|
|
['1', '2', '3', '4'],
|
|
|
|
|
'testtype'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$this->assertEquals([
|
|
|
|
|
1 => [$this->tag1->getId(), $this->tag2->getId()],
|
|
|
|
|
2 => [$this->tag1->getId()],
|
|
|
|
|
3 => [],
|
|
|
|
|
4 => [],
|
|
|
|
|
'1' => [$this->tag1->getId(), $this->tag2->getId()],
|
|
|
|
|
'2' => [$this->tag1->getId()],
|
|
|
|
|
'3' => [],
|
|
|
|
|
'4' => [],
|
|
|
|
|
], $tagIdMapping);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -140,8 +140,8 @@ class SystemTagObjectMapperTest extends TestCase {
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$this->assertEquals([
|
|
|
|
|
1,
|
|
|
|
|
2,
|
|
|
|
|
'1',
|
|
|
|
|
'2',
|
|
|
|
|
], $objectIds);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -192,29 +192,29 @@ class SystemTagObjectMapperTest extends TestCase {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testAssignUnassignTags() {
|
|
|
|
|
$this->tagMapper->unassignTags(1, 'testtype', [$this->tag1->getId()]);
|
|
|
|
|
$this->tagMapper->unassignTags('1', 'testtype', [$this->tag1->getId()]);
|
|
|
|
|
|
|
|
|
|
$tagIdMapping = $this->tagMapper->getTagIdsForObjects(1, 'testtype');
|
|
|
|
|
$tagIdMapping = $this->tagMapper->getTagIdsForObjects('1', 'testtype');
|
|
|
|
|
$this->assertEquals([
|
|
|
|
|
1 => [$this->tag2->getId()],
|
|
|
|
|
], $tagIdMapping);
|
|
|
|
|
|
|
|
|
|
$this->tagMapper->assignTags(1, 'testtype', [$this->tag1->getId()]);
|
|
|
|
|
$this->tagMapper->assignTags(1, 'testtype', $this->tag3->getId());
|
|
|
|
|
$this->tagMapper->assignTags('1', 'testtype', [$this->tag1->getId()]);
|
|
|
|
|
$this->tagMapper->assignTags('1', 'testtype', $this->tag3->getId());
|
|
|
|
|
|
|
|
|
|
$tagIdMapping = $this->tagMapper->getTagIdsForObjects(1, 'testtype');
|
|
|
|
|
$tagIdMapping = $this->tagMapper->getTagIdsForObjects('1', 'testtype');
|
|
|
|
|
|
|
|
|
|
$this->assertEquals([
|
|
|
|
|
1 => [$this->tag1->getId(), $this->tag2->getId(), $this->tag3->getId()],
|
|
|
|
|
'1' => [$this->tag1->getId(), $this->tag2->getId(), $this->tag3->getId()],
|
|
|
|
|
], $tagIdMapping);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testReAssignUnassignTags() {
|
|
|
|
|
// reassign tag1
|
|
|
|
|
$this->tagMapper->assignTags(1, 'testtype', [$this->tag1->getId()]);
|
|
|
|
|
$this->tagMapper->assignTags('1', 'testtype', [$this->tag1->getId()]);
|
|
|
|
|
|
|
|
|
|
// tag 3 was never assigned
|
|
|
|
|
$this->tagMapper->unassignTags(1, 'testtype', [$this->tag3->getId()]);
|
|
|
|
|
$this->tagMapper->unassignTags('1', 'testtype', [$this->tag3->getId()]);
|
|
|
|
|
|
|
|
|
|
$this->assertTrue(true, 'No error when reassigning/unassigning');
|
|
|
|
|
}
|
|
|
|
|
@ -223,13 +223,13 @@ class SystemTagObjectMapperTest extends TestCase {
|
|
|
|
|
* @expectedException \OCP\SystemTag\TagNotFoundException
|
|
|
|
|
*/
|
|
|
|
|
public function testAssignNonExistingTags() {
|
|
|
|
|
$this->tagMapper->assignTags(1, 'testtype', [100]);
|
|
|
|
|
$this->tagMapper->assignTags('1', 'testtype', [100]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testAssignNonExistingTagInArray() {
|
|
|
|
|
$caught = false;
|
|
|
|
|
try {
|
|
|
|
|
$this->tagMapper->assignTags(1, 'testtype', [100, $this->tag3->getId()]);
|
|
|
|
|
$this->tagMapper->assignTags('1', 'testtype', [100, $this->tag3->getId()]);
|
|
|
|
|
} catch (TagNotFoundException $e) {
|
|
|
|
|
$caught = true;
|
|
|
|
|
}
|
|
|
|
|
@ -237,12 +237,12 @@ class SystemTagObjectMapperTest extends TestCase {
|
|
|
|
|
$this->assertTrue($caught, 'Exception thrown');
|
|
|
|
|
|
|
|
|
|
$tagIdMapping = $this->tagMapper->getTagIdsForObjects(
|
|
|
|
|
[1],
|
|
|
|
|
['1'],
|
|
|
|
|
'testtype'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$this->assertEquals([
|
|
|
|
|
1 => [$this->tag1->getId(), $this->tag2->getId()],
|
|
|
|
|
'1' => [$this->tag1->getId(), $this->tag2->getId()],
|
|
|
|
|
], $tagIdMapping, 'None of the tags got assigned');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -250,13 +250,13 @@ class SystemTagObjectMapperTest extends TestCase {
|
|
|
|
|
* @expectedException \OCP\SystemTag\TagNotFoundException
|
|
|
|
|
*/
|
|
|
|
|
public function testUnassignNonExistingTags() {
|
|
|
|
|
$this->tagMapper->unassignTags(1, 'testtype', [100]);
|
|
|
|
|
$this->tagMapper->unassignTags('1', 'testtype', [100]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testUnassignNonExistingTagsInArray() {
|
|
|
|
|
$caught = false;
|
|
|
|
|
try {
|
|
|
|
|
$this->tagMapper->unassignTags(1, 'testtype', [100, $this->tag1->getId()]);
|
|
|
|
|
$this->tagMapper->unassignTags('1', 'testtype', [100, $this->tag1->getId()]);
|
|
|
|
|
} catch (TagNotFoundException $e) {
|
|
|
|
|
$caught = true;
|
|
|
|
|
}
|
|
|
|
|
@ -269,14 +269,14 @@ class SystemTagObjectMapperTest extends TestCase {
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$this->assertEquals([
|
|
|
|
|
1 => [$this->tag1->getId(), $this->tag2->getId()],
|
|
|
|
|
'1' => [$this->tag1->getId(), $this->tag2->getId()],
|
|
|
|
|
], $tagIdMapping, 'None of the tags got unassigned');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testHaveTagAllMatches() {
|
|
|
|
|
$this->assertTrue(
|
|
|
|
|
$this->tagMapper->haveTag(
|
|
|
|
|
[1],
|
|
|
|
|
['1'],
|
|
|
|
|
'testtype',
|
|
|
|
|
$this->tag1->getId(),
|
|
|
|
|
true
|
|
|
|
|
@ -286,7 +286,7 @@ class SystemTagObjectMapperTest extends TestCase {
|
|
|
|
|
|
|
|
|
|
$this->assertTrue(
|
|
|
|
|
$this->tagMapper->haveTag(
|
|
|
|
|
[1, 2],
|
|
|
|
|
['1', '2'],
|
|
|
|
|
'testtype',
|
|
|
|
|
$this->tag1->getId(),
|
|
|
|
|
true
|
|
|
|
|
@ -296,7 +296,7 @@ class SystemTagObjectMapperTest extends TestCase {
|
|
|
|
|
|
|
|
|
|
$this->assertFalse(
|
|
|
|
|
$this->tagMapper->haveTag(
|
|
|
|
|
[1, 2],
|
|
|
|
|
['1', '2'],
|
|
|
|
|
'testtype',
|
|
|
|
|
$this->tag2->getId(),
|
|
|
|
|
true
|
|
|
|
|
@ -306,7 +306,7 @@ class SystemTagObjectMapperTest extends TestCase {
|
|
|
|
|
|
|
|
|
|
$this->assertFalse(
|
|
|
|
|
$this->tagMapper->haveTag(
|
|
|
|
|
[2],
|
|
|
|
|
['2'],
|
|
|
|
|
'testtype',
|
|
|
|
|
$this->tag2->getId(),
|
|
|
|
|
true
|
|
|
|
|
@ -316,7 +316,7 @@ class SystemTagObjectMapperTest extends TestCase {
|
|
|
|
|
|
|
|
|
|
$this->assertFalse(
|
|
|
|
|
$this->tagMapper->haveTag(
|
|
|
|
|
[3],
|
|
|
|
|
['3'],
|
|
|
|
|
'testtype',
|
|
|
|
|
$this->tag2->getId(),
|
|
|
|
|
true
|
|
|
|
|
@ -328,7 +328,7 @@ class SystemTagObjectMapperTest extends TestCase {
|
|
|
|
|
public function testHaveTagAtLeastOneMatch() {
|
|
|
|
|
$this->assertTrue(
|
|
|
|
|
$this->tagMapper->haveTag(
|
|
|
|
|
[1],
|
|
|
|
|
['1'],
|
|
|
|
|
'testtype',
|
|
|
|
|
$this->tag1->getId(),
|
|
|
|
|
false
|
|
|
|
|
@ -338,7 +338,7 @@ class SystemTagObjectMapperTest extends TestCase {
|
|
|
|
|
|
|
|
|
|
$this->assertTrue(
|
|
|
|
|
$this->tagMapper->haveTag(
|
|
|
|
|
[1, 2],
|
|
|
|
|
['1', '2'],
|
|
|
|
|
'testtype',
|
|
|
|
|
$this->tag1->getId(),
|
|
|
|
|
false
|
|
|
|
|
@ -348,7 +348,7 @@ class SystemTagObjectMapperTest extends TestCase {
|
|
|
|
|
|
|
|
|
|
$this->assertTrue(
|
|
|
|
|
$this->tagMapper->haveTag(
|
|
|
|
|
[1, 2],
|
|
|
|
|
['1', '2'],
|
|
|
|
|
'testtype',
|
|
|
|
|
$this->tag2->getId(),
|
|
|
|
|
false
|
|
|
|
|
@ -358,7 +358,7 @@ class SystemTagObjectMapperTest extends TestCase {
|
|
|
|
|
|
|
|
|
|
$this->assertFalse(
|
|
|
|
|
$this->tagMapper->haveTag(
|
|
|
|
|
[2],
|
|
|
|
|
['2'],
|
|
|
|
|
'testtype',
|
|
|
|
|
$this->tag2->getId(),
|
|
|
|
|
false
|
|
|
|
|
@ -368,7 +368,7 @@ class SystemTagObjectMapperTest extends TestCase {
|
|
|
|
|
|
|
|
|
|
$this->assertFalse(
|
|
|
|
|
$this->tagMapper->haveTag(
|
|
|
|
|
[3],
|
|
|
|
|
['3'],
|
|
|
|
|
'testtype',
|
|
|
|
|
$this->tag2->getId(),
|
|
|
|
|
false
|
|
|
|
|
@ -382,7 +382,7 @@ class SystemTagObjectMapperTest extends TestCase {
|
|
|
|
|
*/
|
|
|
|
|
public function testHaveTagNonExisting() {
|
|
|
|
|
$this->tagMapper->haveTag(
|
|
|
|
|
[1],
|
|
|
|
|
['1'],
|
|
|
|
|
'testtype',
|
|
|
|
|
100
|
|
|
|
|
);
|
|
|
|
|
|