/** * Crea un post; * Associa al post un commento (lo crea); * Cancella il commento dal database; * Carica il post e cerca di caricare il commento; * Controlla che il post non abbia quel commento e di non essere riuscito a caricare il commento; */ function testDeleteComment() { $data = $this->post_data_all; $p = PostManager::createPost($data); $p1 = PostManager::commentPost($p, $this->author_id, $this->comment_text); if (count($p1->getComments()) == 0) { return "<br />Post deleting test NOT PASSED: not added"; } $comm = $p1->getComments(); $com = PostManager::loadComment($comm[0]->getId()); $post = PostManager::loadPost($p1->getId()); if ($com !== false && $post !== false) { $com = PostManager::removeComment($com); $post = PostManager::loadPost($post->getID()); $com = PostManager::loadComment($com->getID()); if ($post !== false && $com === false) { if (count($post->getComments()) == 0) { return "<br />Comment deleting test passed"; } } } return "<br />Comment deleting test NOT PASSED: not deleted"; }
private static function doCommentAction($request) { require_once 'manager/PostManager.php'; self::$currentObject = PostManager::loadComment(self::$currentID); switch (self::$requestedAction) { case "Delete": $c->delete(); require_once 'manager/PostManager.php'; $p = PostManager::loadPostByPermalink(self::$currentObject->getPost()); header("location: " . $p->getFullPermalink()); break; case "Read": default: require_once 'manager/PostManager.php'; $p = PostManager::loadPostByPermalink(self::$currentObject->getPost()); header("location: " . $p->getFullPermalink() . "#comment" . self::$currentObject->getID()); break; } }