protected function setUp() { if ($GLOBALS['unittestUrl'] === null) { $this->assertTrue(false, 'Unittest URL not set in config'); } if ($this->urlPart === null) { $this->assertTrue(false, 'Set the urlPart variable'); } $this->url = $GLOBALS['unittestUrl'] . $this->urlPart; //clean up before test $configFile = $GLOBALS['datadir'] . '/config.testing-tmp.php'; if (file_exists($configFile)) { unlink($configFile); } $this->us = SemanticScuttle_Service_Factory::get('User'); $this->us->deleteAll(); $this->bs = SemanticScuttle_Service_Factory::get('Bookmark'); $this->bs->deleteAll(); $this->b2t = SemanticScuttle_Service_Factory::get('Bookmark2Tag'); $this->b2t->deleteAll(); }
/** * Test that rewriting votings does work * * @return void */ public function testRewriteVotings() { $uid = 1; $bid = $this->addBookmark(); $this->assertTrue($this->vs->vote($bid, $uid, 1)); $bm = $this->bs->getBookmark($bid); $this->assertEquals(1, $bm['bVoting']); $this->assertEquals(1, $bm['bVotes']); $this->vs->deleteAll(); //we assume that $vs->deleteAll() does *not* reset //voting in bookmarks table $bm = $this->bs->getBookmark($bid); $this->assertEquals(1, $bm['bVoting']); $this->assertEquals(1, $bm['bVotes']); $this->vs->rewriteVotings(); $bm = $this->bs->getBookmark($bid); //now it should be reset to 0 $this->assertEquals(0, $bm['bVoting']); $this->assertEquals(0, $bm['bVotes']); }