private static function doVoteAction($request) { switch (self::$requestedAction) { case "Delete": require_once 'post/PostManager.php'; $vote = PostManager::loadVote(self::$user, self::$currentID); PostManager::removeVote($vote); header("location: " . FileManager::appendToRootPath("Post/" . self::$currentID)); break; case "Edit": //fare /Post/postid/Vote invece... //fare /Post/postid/Vote invece... default: header("location: " . FileManager::appendToRootPath("Post/" . self::$currentID)); break; } }
/** * Crea un post; * Associa al post un voto (lo crea); * Cancella il voto dal database; * Carica il post e cerca di caricare il voto; * Controlla che il post non abbia quel voto e di non essere riuscito a caricare il voto; */ function testDeleteVote() { $data = $this->post_data_all; $p = PostManager::createPost($data); $p1 = PostManager::votePost($this->author_id, $p, $this->vote_value); if (count($p1->getVotes()) == 0) { return "<br />Vote deleting test NOT PASSED: not added"; } $votes = $p1->getVotes(); $vote = PostManager::loadVote($votes[0]->getAuthor(), $votes[0]->getPost()); $post = PostManager::loadPost($p1->getId()); if ($vote !== false && $post !== false) { $vote = PostManager::removeVote($vote); $post = PostManager::loadPost($post->getID()); $vote = PostManager::loadVote($vote->getAuthor(), $vote->getPost()); if ($post !== false && $vote === false) { if (count($post->getVotes()) == 0) { return "<br />Vote deleting test passed"; } } } return "<br />Vote deleting test NOT PASSED: not deleted"; }