summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorcweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>2009-10-28 22:16:37 +0000
committercweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>2009-10-28 22:16:37 +0000
commit80464e45e84ee7b7b3bb6217adb3649132d43708 (patch)
tree08c65601aea83ba40b8bbe8caa28cbe38e81d7e3 /tests
parentbb5205053e9ae9e584df9715dafd85f9c576f248 (diff)
downloadsemanticscuttle-80464e45e84ee7b7b3bb6217adb3649132d43708.tar.gz
semanticscuttle-80464e45e84ee7b7b3bb6217adb3649132d43708.tar.bz2
test previously fixed bug: voting was updated for all bookmarks, not only the current one
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@449 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'tests')
-rw-r--r--tests/BookmarkTest.php91
1 files changed, 91 insertions, 0 deletions
diff --git a/tests/BookmarkTest.php b/tests/BookmarkTest.php
index 1224dfe..e5cf760 100644
--- a/tests/BookmarkTest.php
+++ b/tests/BookmarkTest.php
@@ -182,6 +182,97 @@ class BookmarkTest extends TestBase
$this->assertTrue($this->vs->hasVoted($bid2, $uid));
}
+
+
+ /**
+ * Verify that getBookmark() does not include user voting
+ * data when no user is logged on.
+ *
+ * @return void
+ */
+ public function testGetBookmarkUserVotingNoUser()
+ {
+ $uid = $this->addUser();
+ $bid = $this->addBookmark($uid);
+ //no user
+ $this->us->setCurrentUserId(null);
+
+ $bm = $this->bs->getBookmark($bid);
+ $this->assertArrayNotHasKey('hasVoted', $bm);
+ $this->assertArrayNotHasKey('vote', $bm);
+ }
+
+
+
+ /**
+ * Verify that getBookmark() automatically includes
+ * voting data of the currently logged on user,
+ * even if he did not vote yet.
+ *
+ * @return void
+ */
+ public function testGetBookmarkUserVotingWithUserNoVote()
+ {
+ $uid = $this->addUser();
+ $bid = $this->addBookmark($uid);
+ //log user in
+ $this->us->setCurrentUserId($uid);
+
+ $bm = $this->bs->getBookmark($bid);
+ $this->assertArrayHasKey('hasVoted', $bm);
+ $this->assertArrayHasKey('vote', $bm);
+ $this->assertEquals(0, $bm['hasVoted']);
+ $this->assertEquals(null, $bm['vote']);
+ }
+
+
+
+ /**
+ * Verify that getBookmark() automatically includes
+ * voting data of the currently logged on user
+ * when he voted positive.
+ *
+ * @return void
+ */
+ public function testGetBookmarkUserVotingWithUserPositiveVote()
+ {
+ $uid = $this->addUser();
+ $bid = $this->addBookmark($uid);
+ //log user in
+ $this->us->setCurrentUserId($uid);
+ $this->assertTrue($this->vs->vote($bid, $uid, 1));
+
+ $bm = $this->bs->getBookmark($bid);
+ $this->assertArrayHasKey('hasVoted', $bm);
+ $this->assertArrayHasKey('vote', $bm);
+ $this->assertEquals(1, $bm['hasVoted']);
+ $this->assertEquals(1, $bm['vote']);
+ }
+
+
+
+ /**
+ * Verify that getBookmark() automatically includes
+ * voting data of the currently logged on user
+ * when he voted positive.
+ *
+ * @return void
+ */
+ public function testGetBookmarkUserVotingWithUserNegativeVote()
+ {
+ $uid = $this->addUser();
+ $bid = $this->addBookmark($uid);
+ //log user in
+ $this->us->setCurrentUserId($uid);
+ $this->assertTrue($this->vs->vote($bid, $uid, -1));
+
+ $bm = $this->bs->getBookmark($bid);
+ $this->assertArrayHasKey('hasVoted', $bm);
+ $this->assertArrayHasKey('vote', $bm);
+ $this->assertEquals(1, $bm['hasVoted']);
+ $this->assertEquals(-1, $bm['vote']);
+ }
+
}