public function it_should_return_a_path_of_the_topic(JsonSerializationVisitor $visitor, Topic $topic, $topicRepository) { $topic->getId()->willReturn(1); $topic->getTitle()->willReturn("Test topic"); $topic->getParent()->willReturn("Parent topic"); $topicRepository->getReadablePath($topic)->willReturn(" / Parent topic / Test topic"); $type = array('name' => "topic_path", 'params' => array()); $this->serializeToJson($visitor, $topic, $type)->shouldReturn(" / Parent topic / Test topic"); }
/** * Get topic id * * @return int */ public function getTopicId() { return $this->topic->getId(); }
/** * Deletes the topic. If topic is attached to any article * it is first detached and deleted. * * @param Topic $topic Topic * * @return bool */ public function deleteTopic(Topic $topic) { if ($this->isAttached($topic->getId())) { $this->removeTopicFromAllArticles($topic->getId()); } $this->removeTopicFromAllUsers($topic->getId()); $this->em->remove($topic); $this->em->flush(); $this->em->clear(); return true; }