Esempio n. 1
0
 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;
     }
 }
Esempio n. 2
0
 /**
  * Crea un post;
  * Crea una collezione con il post nel contenuto;
  * Associa alla collezione un voto (lo crea);
  * Carica il voto dal database e lo confronta con quello salvato in memoria;
  */
 function testSaveVoteOnCollection()
 {
     require_once "post/PostManager.php";
     $data = $this->post_data_all;
     $p = PostManager::createPost($data);
     $data1 = $this->collection_data_all;
     $p2 = CollectionManager::addCollection($data1);
     $p1 = CollectionManager::voteCollection($this->author_id, $p2, $this->vote_value);
     if (count($p1->getVotes()) == 0) {
         return "<br />Vote saving test NOT PASSED: not added";
     }
     $votes = $p1->getVotes();
     $vote = PostManager::loadVote($votes[0]->getAuthor(), $votes[0]->getPost());
     $post = CollectionManager::loadCollection($p1->getId());
     if (count($post->getVotes()) == 0) {
         return "<br />Vote saving test NOT PASSED: not added";
     }
     //echo $votes[0] . "<br />" . $vote; //DEBUG
     //echo "<br />" . $p1 . "<br />" . $post; //DEBUG
     if ($vote === false) {
         return "<br />Vote saving test NOT PASSED: not created";
     }
     if ($votes[0]->getAuthor() != $vote->getAuthor()) {
         return "<br />Vote saving test NOT PASSED: author";
     }
     if ($votes[0]->getVote() != $vote->getVote()) {
         return "<br />Vote saving test NOT PASSED: comment";
     }
     if ($votes[0]->getPost() != $vote->getPost()) {
         return "<br />Vote saving test NOT PASSED: post";
     }
     if ($votes[0]->getCreationDate() != $vote->getCreationDate()) {
         return "<br />Vote saving test NOT PASSED: creationDate";
     }
     return "<br />Vote saving test passed";
 }