From ac4e66c360ce83fe13f00af99fbfad8a80b80e1f Mon Sep 17 00:00:00 2001 From: cweiske Date: Sat, 31 Oct 2009 10:19:38 +0000 Subject: enable voting when testing voting, test countBookmarks() git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@485 b3834d28-1941-0410-a4f8-b48e95affb8f --- tests/BookmarkTest.php | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) (limited to 'tests') diff --git a/tests/BookmarkTest.php b/tests/BookmarkTest.php index 01e6b38..dbb4172 100644 --- a/tests/BookmarkTest.php +++ b/tests/BookmarkTest.php @@ -134,6 +134,81 @@ class BookmarkTest extends TestBase + /** + * Test if countBookmarks() works with no bookmarks + * + * @return void + */ + public function testCountBookmarksNone() + { + $uid = $this->addUser(); + $this->assertEquals(0, $this->bs->countBookmarks($uid)); + $this->assertEquals(0, $this->bs->countBookmarks($uid, 'public')); + $this->assertEquals(0, $this->bs->countBookmarks($uid, 'private')); + $this->assertEquals(0, $this->bs->countBookmarks($uid, 'shared')); + } + + + + /** + * Test if countBookmarks() works with one public bookmark + * + * @return void + */ + public function testCountBookmarksOnePublic() + { + $uid = $this->addUser(); + $this->addBookmark($uid); + $this->assertEquals(1, $this->bs->countBookmarks($uid)); + $this->assertEquals(1, $this->bs->countBookmarks($uid, 'public')); + $this->assertEquals(0, $this->bs->countBookmarks($uid, 'private')); + $this->assertEquals(0, $this->bs->countBookmarks($uid, 'shared')); + } + + + + /** + * Test if countBookmarks() works with one private bookmark + * + * @return void + */ + public function testCountBookmarksOnePrivate() + { + $uid = $this->addUser(); + $this->bs->addBookmark( + 'http://test', 'test', 'desc', 'note', + 2,//private + array(), null, false, false, $uid + ); + $this->assertEquals(0, $this->bs->countBookmarks($uid)); + $this->assertEquals(0, $this->bs->countBookmarks($uid, 'public')); + $this->assertEquals(1, $this->bs->countBookmarks($uid, 'private')); + $this->assertEquals(0, $this->bs->countBookmarks($uid, 'shared')); + } + + + + /** + * Test if countBookmarks() works with one shared bookmark + * + * @return void + */ + public function testCountBookmarksOneShared() + { + $uid = $this->addUser(); + $this->bs->addBookmark( + 'http://test', 'test', 'desc', 'note', + 1,//shared + array(), null, false, false, $uid + ); + $this->assertEquals(0, $this->bs->countBookmarks($uid)); + $this->assertEquals(0, $this->bs->countBookmarks($uid, 'public')); + $this->assertEquals(0, $this->bs->countBookmarks($uid, 'private')); + $this->assertEquals(1, $this->bs->countBookmarks($uid, 'shared')); + } + + + /** * Test if deleting a bookmark works. * @@ -170,6 +245,8 @@ class BookmarkTest extends TestBase */ public function testDeleteBookmarkWithVote() { + $GLOBALS['enableVoting'] = true; + $uid = $this->addUser(); $bid = $this->addBookmark(); @@ -196,6 +273,8 @@ class BookmarkTest extends TestBase */ public function testGetBookmarkUserVotingNoUser() { + $GLOBALS['enableVoting'] = true; + $uid = $this->addUser(); $bid = $this->addBookmark($uid); //no user @@ -217,6 +296,8 @@ class BookmarkTest extends TestBase */ public function testGetBookmarkUserVotingWithUserNoVote() { + $GLOBALS['enableVoting'] = true; + $uid = $this->addUser(); $bid = $this->addBookmark($uid); //log user in @@ -240,6 +321,8 @@ class BookmarkTest extends TestBase */ public function testGetBookmarkUserVotingWithUserPositiveVote() { + $GLOBALS['enableVoting'] = true; + $uid = $this->addUser(); $bid = $this->addBookmark($uid); //log user in @@ -264,6 +347,8 @@ class BookmarkTest extends TestBase */ public function testGetBookmarkUserVotingWithUserNegativeVote() { + $GLOBALS['enableVoting'] = true; + $uid = $this->addUser(); $bid = $this->addBookmark($uid); //log user in -- cgit v1.2.3