aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2011-03-23 08:58:20 +0100
committerChristian Weiske <cweiske@cweiske.de>2011-03-23 08:58:20 +0100
commit9f46e9f3ff2454318f50ead7790e3bf46bb868f2 (patch)
treeeded4157bba571e1d42eee1a7ad13f77259a1871
parent821c17d9e378ecd702a219dfa8392d4d48df3cd0 (diff)
downloadsemanticscuttle-9f46e9f3ff2454318f50ead7790e3bf46bb868f2.tar.gz
semanticscuttle-9f46e9f3ff2454318f50ead7790e3bf46bb868f2.tar.bz2
getPopularTags is fully covered now
-rw-r--r--tests/Bookmark2TagTest.php124
1 files changed, 124 insertions, 0 deletions
diff --git a/tests/Bookmark2TagTest.php b/tests/Bookmark2TagTest.php
index 0fae2ea..8ee3fc1 100644
--- a/tests/Bookmark2TagTest.php
+++ b/tests/Bookmark2TagTest.php
@@ -228,6 +228,8 @@ class Bookmark2TagTest extends TestBase
/**
* Fetch the most popular tags in descending order
+ *
+ * @covers SemanticScuttle_Service_Bookmark2Tag::getPopularTags
*/
public function testGetPopularTagsOrder()
{
@@ -254,6 +256,9 @@ class Bookmark2TagTest extends TestBase
+ /**
+ * @covers SemanticScuttle_Service_Bookmark2Tag::getPopularTags
+ */
public function testGetPopularTagsLimit()
{
$user = $this->addUser();
@@ -289,6 +294,9 @@ class Bookmark2TagTest extends TestBase
+ /**
+ * @covers SemanticScuttle_Service_Bookmark2Tag::getPopularTags
+ */
public function testGetPopularTagsDays()
{
$user = $this->addUser();
@@ -323,6 +331,122 @@ class Bookmark2TagTest extends TestBase
$this->assertContains(array('tag' => 'two', 'bCount' => '2'), $arTags);
$this->assertContains(array('tag' => 'three', 'bCount' => '2'), $arTags);
}
+
+
+
+ /**
+ * @covers SemanticScuttle_Service_Bookmark2Tag::getPopularTags
+ */
+ public function testGetPopularTagsExcludesSystemTags()
+ {
+ $user = $this->addUser();
+ $this->addTagBookmark($user, array('one', 'system:test'));
+ $this->addTagBookmark($user, array('one', 'system:unittest'));
+ $this->addTagBookmark($user, array('one', 'sys:unittest'));
+
+ $arTags = $this->b2ts->getPopularTags();
+ $this->assertInternalType('array', $arTags);
+ $this->assertEquals(2, count($arTags));
+ $this->assertEquals(
+ array(
+ array('tag' => 'one', 'bCount' => '3'),
+ array('tag' => 'sys:unittest', 'bCount' => '1'),
+ ),
+ $arTags
+ );
+ }
+
+
+
+ /**
+ * @covers SemanticScuttle_Service_Bookmark2Tag::getPopularTags
+ */
+ public function testGetPopularTagsUserTags()
+ {
+ $user1 = $this->addUser();
+ $user2 = $this->addUser();
+ $user3 = $this->addUser();
+ $this->addTagBookmark($user1, array('one'));
+ $this->addTagBookmark($user2, array('one', 'two'));
+ $this->addTagBookmark($user2, array('two'));
+ $this->addTagBookmark($user3, array('one', 'three'));
+
+ $arTags = $this->b2ts->getPopularTags($user1);
+ $this->assertEquals(1, count($arTags));
+ $this->assertEquals(
+ array(
+ array('tag' => 'one', 'bCount' => '1'),
+ ),
+ $arTags
+ );
+
+ $arTags = $this->b2ts->getPopularTags($user2);
+ $this->assertEquals(2, count($arTags));
+ $this->assertEquals(
+ array(
+ array('tag' => 'two', 'bCount' => '2'),
+ array('tag' => 'one', 'bCount' => '1'),
+ ),
+ $arTags
+ );
+
+ $arTags = $this->b2ts->getPopularTags(array($user2, $user3));
+ $this->assertEquals(3, count($arTags));
+ $this->assertContains(array('tag' => 'one', 'bCount' => '2'), $arTags);
+ $this->assertContains(array('tag' => 'two', 'bCount' => '2'), $arTags);
+ $this->assertContains(array('tag' => 'three', 'bCount' => '1'), $arTags);
+ }
+
+ /**
+ * @covers SemanticScuttle_Service_Bookmark2Tag::getPopularTags
+ */
+ public function testGetPopularTagsPublicOnly()
+ {
+ $user1 = $this->addUser();
+ $this->addBookmark($user1, null, 0, array('one'));
+ $this->addBookmark($user1, null, 1, array('one', 'two'));
+ $this->addBookmark($user1, null, 2, array('three'));
+
+ $arTags = $this->b2ts->getPopularTags();
+ $this->assertEquals(1, count($arTags));
+ $this->assertEquals(
+ array(
+ array('tag' => 'one', 'bCount' => '1'),
+ ),
+ $arTags
+ );
+
+ $user1 = $this->addUser();
+ $this->addBookmark($user1, null, 0, array('one'));
+ $this->addBookmark($user1, null, 1, array('one', 'two'));
+ $this->addBookmark($user1, null, 2, array('three'));
+
+ $arTags = $this->b2ts->getPopularTags($user1);
+ $this->assertEquals(1, count($arTags));
+ $this->assertEquals(
+ array(
+ array('tag' => 'one', 'bCount' => '1'),
+ ),
+ $arTags
+ );
+ }
+
+ /**
+ * @covers SemanticScuttle_Service_Bookmark2Tag::getPopularTags
+ */
+ public function testGetPopularTagsUserPrivatesWhenLoggedIn()
+ {
+ $user1 = $this->addUser();
+ $this->addBookmark($user1, null, 0, array('one'));
+ $this->addBookmark($user1, null, 1, array('one', 'two'));
+ $this->addBookmark($user1, null, 2, array('three'));
+
+ $arTags = $this->b2ts->getPopularTags($user1, 10, $user1);
+ $this->assertEquals(3, count($arTags));
+ $this->assertContains(array('tag' => 'one', 'bCount' => '2'), $arTags);
+ $this->assertContains(array('tag' => 'two', 'bCount' => '1'), $arTags);
+ $this->assertContains(array('tag' => 'three', 'bCount' => '1'), $arTags);
+ }
}
if (PHPUnit_MAIN_METHOD == 'Bookmark2TagTest::main') {