$t->is($forum->getUpdatedAt('U'), $msg3->getCreatedAt('U'), 'Updating a message doesn\'t change the forum\'s last update date'); $t->is($forum->getLatestPost()->getId(), $msg3->getId(), 'Updating a message doesn\'t change the forum\'s last reply'); $t->diag('Updating the topic'); sleep(1); $topic = sfSimpleForumTopicPeer::retrieveByPk($topic->getId()); $topic->setTitle('this is another test'); $topic->save(); $t->is($topic->getNbPosts(), 3, 'Updating a topic doesn\'t change the topic number of replies'); $t->isnt($topic->getUpdatedAt('U'), $msg3->getCreatedAt('U'), 'Updating a topic changes the topic\'s latest update date'); $t->is($topic->getLatestPost()->getId(), $msg3->getId(), 'Updating a topic doesn\'t change the topic\'s latest reply'); $forum = sfSimpleForumForumPeer::retrieveByPk($forum->getId()); $t->is($forum->getLatestPost()->getCreatedAt('U'), $msg3->getCreatedAt('U'), 'Updating the topic doesn\'t change the forum\'s last update date'); $t->is($forum->getLatestPost()->getAuthorName(), $user3->getUsername(), 'Updating the topic doesn\'t change the forum\'s last reply author name'); $t->diag('Deleting a message from the end'); $msg3->delete(); $topic = sfSimpleForumTopicPeer::retrieveByPk($topic->getId()); $t->is($topic->getNbPosts(), 2, 'Deleting a message decrements the topic number of replies'); $t->is($topic->getUpdatedAt('U'), $msg2->getCreatedAt('U'), 'Deleting a message changes the topic\'s latest update date to the latest message creation date'); $t->is($topic->getLatestPost()->getId(), $msg2->getId(), 'Deleting a message changes the topic\'s latest reply'); $forum = sfSimpleForumForumPeer::retrieveByPk($forum->getId()); $t->is($forum->getUpdatedAt('U'), $msg2->getCreatedAt('U'), 'Deleting a message changes the forums\'s latest update date to the latest message creation date'); $t->is($forum->getLatestPost()->getId(), $msg2->getId(), 'Deleting a message changes the forums\'s latest reply'); $t->diag('Deleting a message from the middle'); $msg1->delete(); $topic = sfSimpleForumTopicPeer::retrieveByPk($topic->getId()); $t->is($topic->getNbPosts(), 1, 'Deleting a message decrements the topic number of replies'); $t->is($topic->getUpdatedAt('U'), $msg2->getCreatedAt('U'), 'Deleting a message from the middle doesn\'t change the topic\'s latest update date'); $t->is($topic->getLatestPost()->getId(), $msg2->getId(), 'Deleting a message from the middle doesn\'t change the topic\'s latest reply'); $forum = sfSimpleForumForumPeer::retrieveByPk($forum->getId()); $t->is($forum->getUpdatedAt('U'), $msg2->getCreatedAt('U'), 'Deleting a message from the middle doesn\'t change the forum\'s latest update date'); $t->is($forum->getLatestPost()->getId(), $msg2->getId(), 'Deleting a message from the middle doesn\'t change the forum\'s latest reply');
public function executeToggleLock() { $topic = sfSimpleForumTopicPeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($topic); $topic->setIsLocked(!$topic->getIsLocked()); $topic->leaveUpdatedAtUnchanged(); $topic->save(); $this->redirect($this->getModuleName() . '/topic?id=' . $topic->getId()); }