From 30f84b3ca3242f00926f30c08ece4405be8b61fc Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Thu, 24 Mar 2011 19:07:50 +0100 Subject: fix privacy protection issue when fetching tags of several users --- tests/Bookmark2TagTest.php | 69 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 20 deletions(-) (limited to 'tests') diff --git a/tests/Bookmark2TagTest.php b/tests/Bookmark2TagTest.php index ad64bf6..e2020dc 100644 --- a/tests/Bookmark2TagTest.php +++ b/tests/Bookmark2TagTest.php @@ -37,6 +37,26 @@ class Bookmark2TagTest extends TestBase protected $tts; + /** + * Create a bookmark. Like addBookmark(), just with other paramter order + * to make some tests in that class easier to write. + * + * @param integer $user User ID the bookmark shall belong + * @param array $tags Array of tags to attach. If "null" is given, + * it will automatically be "unittest" + * @param string $date strtotime-compatible string + * @param string $title Bookmark title + * + * @return integer ID of bookmark + */ + protected function addTagBookmark($user, $tags, $date = null, $title = null) + { + return $this->addBookmark( + $user, null, 0, $tags, $title, $date + ); + } + + /** * Used to run this test class standalone @@ -207,25 +227,6 @@ class Bookmark2TagTest extends TestBase } - /** - * Create a bookmark - * - * @param integer $user User ID the bookmark shall belong - * @param array $tags Array of tags to attach. If "null" is given, - * it will automatically be "unittest" - * @param string $date strtotime-compatible string - * @param string $title Bookmark title - * - * @return integer ID of bookmark - */ - protected function addTagBookmark($user, $tags, $date = null, $title = null) - { - return $this->addBookmark( - $user, null, 0, $tags, $title, $date - ); - } - - /** * Fetch the most popular tags in descending order @@ -398,10 +399,12 @@ class Bookmark2TagTest extends TestBase $this->assertContains(array('tag' => 'thr', 'bCount' => '1'), $arTags); } + + /** * @covers SemanticScuttle_Service_Bookmark2Tag::getPopularTags */ - public function testGetPopularTagsPublicOnly() + public function testGetPopularTagsPublicOnlyNoUser() { $user1 = $this->addUser(); $this->addBookmark($user1, null, 0, array('one')); @@ -416,7 +419,13 @@ class Bookmark2TagTest extends TestBase ), $arTags ); + } + /** + * @covers SemanticScuttle_Service_Bookmark2Tag::getPopularTags + */ + public function testGetPopularTagsPublicOnlySingleUser() + { $user1 = $this->addUser(); $this->addBookmark($user1, null, 0, array('one')); $this->addBookmark($user1, null, 1, array('one', 'two')); @@ -432,6 +441,26 @@ class Bookmark2TagTest extends TestBase ); } + /** + * @covers SemanticScuttle_Service_Bookmark2Tag::getPopularTags + */ + public function testGetPopularTagsPublicOnlySeveralUsers() + { + $user1 = $this->addUser(); + $user2 = $this->addUser(); + $this->addBookmark($user1, null, 0, array('one')); + $this->addBookmark($user1, null, 1, array('one', 'two')); + $this->addBookmark($user1, null, 2, array('thr')); + $this->addBookmark($user2, null, 0, array('fou')); + $this->addBookmark($user2, null, 1, array('fiv')); + $this->addBookmark($user2, null, 2, array('six')); + + $arTags = $this->b2ts->getPopularTags(array($user1, $user2)); + $this->assertEquals(2, count($arTags)); + $this->assertContains(array('tag' => 'one', 'bCount' => '1'), $arTags); + $this->assertContains(array('tag' => 'fou', 'bCount' => '1'), $arTags); + } + /** * @covers SemanticScuttle_Service_Bookmark2Tag::getPopularTags */ -- cgit v1.2.3-54-g00ecf