Esempio n. 1
0
 /**
  * Initialize comment threads for each post, create new thread if none exists.
  *
  * @param array $posts
  */
 public function initializeCommentThreads(array $posts)
 {
     foreach ($posts as $post) {
         $thread = $this->commentThreadManager->findThreadById($post->getId());
         if (!$thread) {
             $thread = $this->commentThreadManager->createThread($post->getId());
             $postUrl = $this->router->generate('CobaseAppBundle_post_view', array('postId' => $post->getId(), 'groupId' => $post->getGroup()->getShortUrl()), true);
             $permalink = urldecode($postUrl);
             $thread->setPermalink($permalink);
             $this->commentThreadManager->saveThread($thread);
         }
         $post->setCommentThread($thread);
     }
 }
 public function testFindThreadById()
 {
     $threadId = 'hello';
     $thread = $this->getMock('FOS\\CommentBundle\\Model\\ThreadInterface');
     $this->repository->expects($this->once())->method('findOneBy')->with(array('id' => $threadId))->will($this->returnValue($thread));
     $manager = new ThreadManager($this->em, $this->class);
     $result = $manager->findThreadById($threadId);
     $this->assertEquals($thread, $result);
 }