From 17a1595b312e5c9d0dac6d5b33685b457647cb8d Mon Sep 17 00:00:00 2001 From: cweiske Date: Thu, 23 Sep 2010 07:30:49 +0000 Subject: [PATCH] add more countother-watchlist tests that are simpler than the previous test git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@736 b3834d28-1941-0410-a4f8-b48e95affb8f --- tests/BookmarkTest.php | 88 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 87 insertions(+), 1 deletion(-) diff --git a/tests/BookmarkTest.php b/tests/BookmarkTest.php index 40869b2..40b40e3 100644 --- a/tests/BookmarkTest.php +++ b/tests/BookmarkTest.php @@ -1085,6 +1085,92 @@ class BookmarkTest extends TestBase + /** + * Test what countOther() returns when the user is logged in + * and a friend (people on the watchlist) has bookmarked + * and the same address with public status. + * + * @return void + */ + public function testCountOthersWatchlistPublic() + { + $uid = $this->addUser(); + $address = 'http://example.org'; + + //create other user and add main user to his watchlist + $friendPublic1 = $this->addUser(); + $this->us->setCurrentUserId($friendPublic1); + $this->us->setWatchStatus($uid); + + //create bookmarks for main user and other one + $this->addBookmark($uid, $address, 0); + $this->addBookmark($friendPublic1, $address, 0);//0 is public + + //log main user in + $this->us->setCurrentUserId($uid); + + $this->assertEquals(1, $this->bs->countOthers($address)); + } + + + + /** + * Test what countOther() returns when the user is logged in + * and a friend (people on the watchlist) has bookmarked + * and shared the same address for the watchlist. + * + * @return void + */ + public function testCountOthersWatchlistShared() + { + $uid = $this->addUser(); + $address = 'http://example.org'; + + //create other user and add main user to his watchlist + $friendPublic1 = $this->addUser(); + $this->us->setCurrentUserId($friendPublic1); + $this->us->setWatchStatus($uid); + + //create bookmarks for main user and other one + $this->addBookmark($uid, $address, 0); + $this->addBookmark($friendPublic1, $address, 1);//1 is shared + + //log main user in + $this->us->setCurrentUserId($uid); + + $this->assertEquals(1, $this->bs->countOthers($address)); + } + + + + /** + * Test what countOther() returns when the user is logged in + * and one friends (people on the watchlist) has bookmarked + * the same address but made it private. + * + * @return void + */ + public function testCountOthersWatchlistPrivate() + { + $uid = $this->addUser(); + $address = 'http://example.org'; + + //create other user and add main user to his watchlist + $friendPublic1 = $this->addUser(); + $this->us->setCurrentUserId($friendPublic1); + $this->us->setWatchStatus($uid); + + //create bookmarks for main user and other one + $this->addBookmark($uid, $address, 0); + $this->addBookmark($friendPublic1, $address, 2);//2 is private + + //log main user in + $this->us->setCurrentUserId($uid); + + $this->assertEquals(0, $this->bs->countOthers($address)); + } + + /** * Test what countOther() returns when the user is logged in * and friends (people on the watchlist) have bookmarked @@ -1092,7 +1178,7 @@ class BookmarkTest extends TestBase * * @return void */ - public function testCountOthersWatchlist() + public function testCountOthersWatchlistComplex() { $uid = $this->addUser(); $address = 'http://example.org';