aboutsummaryrefslogtreecommitdiff
path: root/tests/BookmarkTest.php
diff options
context:
space:
mode:
authorcweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>2010-02-20 11:44:06 +0000
committercweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>2010-02-20 11:44:06 +0000
commit858b188f87898099a4824d07fbcdf892a76c1876 (patch)
tree9b7737de824a4d8ee749c2ee8e82b00e77cd2ac8 /tests/BookmarkTest.php
parente993e994bb42637edc92bc139ac695a1d6458e67 (diff)
downloadsemanticscuttle-858b188f87898099a4824d07fbcdf892a76c1876.tar.gz
semanticscuttle-858b188f87898099a4824d07fbcdf892a76c1876.tar.bz2
add missing piece of faulty merge
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@683 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'tests/BookmarkTest.php')
-rw-r--r--tests/BookmarkTest.php165
1 files changed, 165 insertions, 0 deletions
diff --git a/tests/BookmarkTest.php b/tests/BookmarkTest.php
index 74685c4..0b4f01d 100644
--- a/tests/BookmarkTest.php
+++ b/tests/BookmarkTest.php
@@ -1179,6 +1179,171 @@ class BookmarkTest extends TestBase
+
+
+ /**
+ * Test what countOther() returns when the address does not exist
+ *
+ * @return void
+ */
+ public function testCountOthersAddressDoesNotExist()
+ {
+ $this->assertEquals(0, $this->bs->countOthers('http://example.org'));
+ }
+
+
+
+ /**
+ * Test what countOther() returns when nobody else has the same bookmark
+ *
+ * @return void
+ */
+ public function testCountOthersNone()
+ {
+ $uid = $this->addUser();
+ $address = 'http://example.org';
+ $this->addBookmark($uid, $address);
+ $this->assertEquals(0, $this->bs->countOthers($address));
+ }
+
+
+
+ /**
+ * Test what countOther() returns when the address exists only once
+ * and multiple bookmarks are in the database.
+ *
+ * @return void
+ */
+ public function testCountOthersMultipleNone()
+ {
+ $uid = $this->addUser();
+ $address = 'http://example.org';
+ $this->addBookmark($uid, $address);
+ $this->addBookmark($uid);
+ $this->addBookmark($uid);
+ $this->assertEquals(0, $this->bs->countOthers($address));
+ }
+
+
+
+ /**
+ * Test what countOther() returns when the address exists only once
+ * and the same user and other users have other bookmarks
+ *
+ * @return void
+ */
+ public function testCountOthersMultipleUsersNone()
+ {
+ $uid = $this->addUser();
+ $uid2 = $this->addUser();
+ $address = 'http://example.org';
+ $this->addBookmark($uid, $address);
+ $this->addBookmark($uid);
+ $this->addBookmark($uid2);
+ $this->assertEquals(0, $this->bs->countOthers($address));
+ }
+
+
+
+ /**
+ * Test what countOther() returns when the address exists two
+ * times in the database.
+ *
+ * @return void
+ */
+ public function testCountOthersOne()
+ {
+ $uid = $this->addUser();
+ $uid2 = $this->addUser();
+ $address = 'http://example.org';
+ $this->addBookmark($uid, $address);
+ $this->addBookmark($uid2, $address);
+ $this->assertEquals(1, $this->bs->countOthers($address));
+ }
+
+
+
+ /**
+ * Test what countOther() returns when the address exists four
+ * times in the database.
+ *
+ * @return void
+ */
+ public function testCountOthersThree()
+ {
+ $uid = $this->addUser();
+ $address = 'http://example.org';
+ $this->addBookmark($uid, $address);
+ $this->addBookmark(null, $address);
+ $this->addBookmark(null, $address);
+ $this->addBookmark(null, $address);
+ $this->assertEquals(3, $this->bs->countOthers($address));
+ }
+
+
+
+ /**
+ * Test what countOther() returns when the user is logged in
+ * and friends (people on the watchlist) have bookmarked
+ * and shared the same address.
+ *
+ * @return void
+ */
+ public function testCountOthersWatchlist()
+ {
+ $uid = $this->addUser();
+ $address = 'http://example.org';
+ //log user in
+ $this->us->setCurrentUserId($uid);
+
+ //setup users
+ $otherPublic1 = $this->addUser();
+ $otherPublic2 = $this->addUser();
+ $otherShared1 = $this->addUser();
+ $otherPrivate1 = $this->addUser();
+ $friendPublic1 = $this->addUser();
+ $friendShared1 = $this->addUser();
+ $friendShared2 = $this->addUser();
+ $friendPrivate1 = $this->addUser();
+ $friendSharing1 = $this->addUser();
+
+ //setup watchlists
+ $us = SemanticScuttle_Service_Factory::get('User');
+ $this->us->setCurrentUserId($friendPublic1);
+ $us->setWatchStatus($uid);
+ $this->us->setCurrentUserId($friendShared1);
+ $us->setWatchStatus($uid);
+ $this->us->setCurrentUserId($friendShared2);
+ $us->setWatchStatus($uid);
+ $this->us->setCurrentUserId($friendPrivate1);
+ $us->setWatchStatus($uid);
+
+ //back to login of main user
+ $this->us->setCurrentUserId($uid);
+ $us->setWatchStatus($friendSharing1);
+
+ //add bookmarks
+ $this->addBookmark($uid, $address, 0);
+ $this->addBookmark($otherPublic1, $address, 0);
+ $this->addBookmark($otherPublic2, $address, 0);
+ $this->addBookmark($otherShared1, $address, 1);
+ $this->addBookmark($otherPrivate1, $address, 2);
+ $this->addBookmark($friendPublic1, $address, 0);
+ $this->addBookmark($friendShared1, $address, 1);
+ $this->addBookmark($friendShared2, $address, 1);
+ $this->addBookmark($friendPrivate1, $address, 2);
+ //this user is on our watchlist, but we not on his
+ $this->addBookmark($friendSharing1, $address, 1);
+
+ //2 public
+ //1 public (friend)
+ //2 shared
+ //-> 5
+ $this->assertEquals(5, $this->bs->countOthers($address));
+ }
+
+
+
}