summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorcweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>2009-11-02 09:35:38 +0000
committercweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>2009-11-02 09:35:38 +0000
commitd05aebe54e02ab4a8362088ca09caaff265fa670 (patch)
tree03f1a01fcc7470f59b52f335708ba0fd8e10d114 /tests
parentb569921136030a5030731abe2c9e4b8d0712a249 (diff)
downloadsemanticscuttle-d05aebe54e02ab4a8362088ca09caaff265fa670.tar.gz
semanticscuttle-d05aebe54e02ab4a8362088ca09caaff265fa670.tar.bz2
allow changing of votes
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@493 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'tests')
-rw-r--r--tests/VoteTest.php127
1 files changed, 125 insertions, 2 deletions
diff --git a/tests/VoteTest.php b/tests/VoteTest.php
index 9d6d904..b211dcd 100644
--- a/tests/VoteTest.php
+++ b/tests/VoteTest.php
@@ -35,6 +35,13 @@ class VoteTest extends TestBase
*/
protected $vs = null;
+ /**
+ * Bookmark service instance.
+ *
+ * @var SemanticScuttle_Service_Bookmark
+ */
+ protected $bs = null;
+
/**
@@ -293,11 +300,11 @@ class VoteTest extends TestBase
$uid = 1;
$bid = $this->addBookmark();
$this->assertTrue($this->vs->vote($bid, $uid, 1));
- $this->assertFalse($this->vs->vote($bid, $uid, 1));
+ $this->assertTrue($this->vs->vote($bid, $uid, 1));
$bid = $this->addBookmark();
$this->assertTrue($this->vs->vote($bid, $uid, -1));
- $this->assertFalse($this->vs->vote($bid, $uid, 1));
+ $this->assertTrue($this->vs->vote($bid, $uid, 1));
}
@@ -333,6 +340,122 @@ class VoteTest extends TestBase
/**
+ * Verify that changing the vote from positive to negative
+ * works.
+ *
+ * @return void
+ */
+ public function testVoteChangePosNeg()
+ {
+ $uid = 1;
+ $bid = $this->addBookmark();
+
+ $this->assertTrue($this->vs->vote($bid, $uid, 1));
+ $this->assertEquals(1, $this->vs->getVote($bid, $uid));
+ $this->assertEquals(1, $this->vs->getVotes($bid));
+
+ $b = $this->bs->getBookmark($bid);
+ $this->assertEquals(1, $b['bVoting']);
+
+ //change vote
+ $this->assertTrue($this->vs->vote($bid, $uid, -1));
+ $this->assertEquals(-1, $this->vs->getVote($bid, $uid));
+ $this->assertEquals(1, $this->vs->getVotes($bid));
+
+ $b = $this->bs->getBookmark($bid);
+ $this->assertEquals(-1, $b['bVoting']);
+ }
+
+
+
+ /**
+ * Verify that changing the vote from negative to positive
+ * works.
+ *
+ * @return void
+ */
+ public function testVoteChangeNegPos()
+ {
+ $uid = 1;
+ $bid = $this->addBookmark();
+
+ $this->assertTrue($this->vs->vote($bid, $uid, -1));
+ $this->assertEquals(-1, $this->vs->getVote($bid, $uid));
+ $this->assertEquals(1, $this->vs->getVotes($bid));
+
+ $b = $this->bs->getBookmark($bid);
+ $this->assertEquals(-1, $b['bVoting']);
+
+ //change vote
+ $this->assertTrue($this->vs->vote($bid, $uid, 1));
+ $this->assertEquals(1, $this->vs->getVote($bid, $uid));
+ $this->assertEquals(1, $this->vs->getVotes($bid));
+
+ $b = $this->bs->getBookmark($bid);
+ $this->assertEquals(1, $b['bVoting']);
+ }
+
+
+
+ /**
+ * Verify that changing the vote from postitive to positive
+ * has no strange effects
+ *
+ * @return void
+ */
+ public function testVoteChangePosPos()
+ {
+ $uid = 1;
+ $bid = $this->addBookmark();
+
+ $this->assertTrue($this->vs->vote($bid, $uid, 1));
+ $this->assertEquals(1, $this->vs->getVote($bid, $uid));
+ $this->assertEquals(1, $this->vs->getVotes($bid));
+
+ $b = $this->bs->getBookmark($bid);
+ $this->assertEquals(1, $b['bVoting']);
+
+ //change vote
+ $this->assertTrue($this->vs->vote($bid, $uid, 1));
+ $this->assertEquals(1, $this->vs->getVote($bid, $uid));
+ $this->assertEquals(1, $this->vs->getVotes($bid));
+
+ $b = $this->bs->getBookmark($bid);
+ $this->assertEquals(1, $b['bVoting']);
+ }
+
+
+
+ /**
+ * Verify that changing the vote from postitive to positive
+ * has no strange effects
+ *
+ * @return void
+ */
+ public function testVoteChangeNegNeg()
+ {
+ $uid = 1;
+ $bid = $this->addBookmark();
+
+ $this->assertTrue($this->vs->vote($bid, $uid, -1));
+ $this->assertEquals(-1, $this->vs->getVote($bid, $uid));
+ $this->assertEquals(1, $this->vs->getVotes($bid));
+
+ $b = $this->bs->getBookmark($bid);
+ $this->assertEquals(-1, $b['bVoting']);
+
+ //change vote to same value
+ $this->assertTrue($this->vs->vote($bid, $uid, -1));
+ $this->assertEquals(-1, $this->vs->getVote($bid, $uid));
+ $this->assertEquals(1, $this->vs->getVotes($bid));
+
+ $b = $this->bs->getBookmark($bid);
+ $this->assertEquals(-1, $b['bVoting']);
+ }
+
+
+
+ /**
* Test that rewriting votings does work
*
* @return void