$msg3->setTopicId($topic->getId()); $msg3->setUserId($user3->getId()); $msg3->save(); $topic = sfSimpleForumTopicPeer::retrieveByPk($topic->getId()); $t->is($topic->getNbPosts(), 3, 'Adding a third message increments the topic number of replies'); $t->is($topic->getUpdatedAt('U'), $msg3->getCreatedAt('U'), 'Adding a third message changes the latest reply date of the topic to the message creation date'); $t->is($topic->getLatestPost()->getAuthorName(), $user3->getUsername(), 'Adding a third message changes the latest reply author name to the message author name'); $t->diag('Updating a message'); sleep(1); $msg1 = sfSimpleForumPostPeer::retrieveByPk($msg1->getId()); $msg1->setTitle('this is a test'); $msg1->save(); $topic = sfSimpleForumTopicPeer::retrieveByPk($topic->getId()); $t->is($topic->getNbPosts(), 3, 'Updating a message doesn\'t change the topic post count'); $t->is($topic->getUpdatedAt('U'), $msg3->getCreatedAt('U'), 'Updating a message doesn\'t change the topic\'s last update date'); $t->is($topic->getLatestPost()->getId(), $msg3->getId(), 'Updating a message doesn\'t change the topic\'s latest reply'); $forum = sfSimpleForumForumPeer::retrieveByPk($forum->getId()); $t->is($forum->getNbPosts(), 3, 'Updating a message doesn\'t change the forum\'s post count'); $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');
protected function redirectToPost(sfSimpleForumPost $post) { $position = $post->getPositionInTopic(); $page = ceil(($position + 1) / sfConfig::get('app_sfSimpleForumPlugin_max_per_page', 10)); $this->redirect($this->getModuleName() . '/topic?id=' . $post->getTopic()->getId() . '&stripped_title=' . $post->getTopic()->getSlug() . '&page=' . $page . '#post' . $post->getId()); }