From cae600722ed04e69c376aa0a1ef1955c93d18ddf Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Mon, 24 Nov 2014 21:51:45 +0100 Subject: Add getTagsForObjects in ITags Returns the list of tags that are set on the given object ids. --- tests/lib/tags.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'tests/lib') diff --git a/tests/lib/tags.php b/tests/lib/tags.php index ab714bde3df..e7bb4db29e6 100644 --- a/tests/lib/tags.php +++ b/tests/lib/tags.php @@ -132,6 +132,36 @@ class Test_Tags extends \Test\TestCase { $this->assertFalse($tagger->isEmpty()); } + public function testGetTagsForObjects() { + $defaultTags = array('Friends', 'Family', 'Work', 'Other'); + $tagger = $this->tagMgr->load($this->objectType, $defaultTags); + + $tagger->tagAs(1, 'Friends'); + $tagger->tagAs(1, 'Other'); + $tagger->tagAs(2, 'Family'); + + $tags = $tagger->getTagsForObjects(array(1)); + $this->assertEquals(1, count($tags)); + $tags = current($tags); + sort($tags); + $this->assertSame(array('Friends', 'Other'), $tags); + + $tags = $tagger->getTagsForObjects(array(1, 2)); + $this->assertEquals(2, count($tags)); + $tags1 = $tags[1]; + sort($tags1); + $this->assertSame(array('Friends', 'Other'), $tags1); + $this->assertSame(array('Family'), $tags[2]); + $this->assertEquals( + array(), + $tagger->getTagsForObjects(array(4)) + ); + $this->assertEquals( + array(), + $tagger->getTagsForObjects(array(4, 5)) + ); + } + public function testdeleteTags() { $defaultTags = array('Friends', 'Family', 'Work', 'Other'); $tagger = $this->tagMgr->load($this->objectType, $defaultTags); -- cgit v1.2.3