Save the query when we get tags for no objects

This commit is contained in:
Joas Schilling 2016-03-21 14:13:38 +01:00 committed by Roeland Jago Douma
parent 9fc371e436
commit dcca20a48a
2 changed files with 12 additions and 1 deletions

View File

@ -64,6 +64,8 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper {
public function getTagIdsForObjects($objIds, $objectType) {
if (!is_array($objIds)) {
$objIds = [$objIds];
} else if (empty($objIds)) {
return [];
}
$query = $this->connection->getQueryBuilder();

View File

@ -119,7 +119,7 @@ class SystemTagObjectMapperTest extends TestCase {
$query->delete(SystemTagManager::TAG_TABLE)->execute();
}
public function testGetTagsForObjects() {
public function testGetTagIdsForObjects() {
$tagIdMapping = $this->tagMapper->getTagIdsForObjects(
['1', '2', '3', '4'],
'testtype'
@ -133,6 +133,15 @@ class SystemTagObjectMapperTest extends TestCase {
], $tagIdMapping);
}
public function testGetTagIdsForNoObjects() {
$tagIdMapping = $this->tagMapper->getTagIdsForObjects(
[],
'testtype'
);
$this->assertEquals([], $tagIdMapping);
}
public function testGetObjectsForTags() {
$objectIds = $this->tagMapper->getObjectIdsForTags(
[$this->tag1->getId(), $this->tag2->getId(), $this->tag3->getId()],