public function its_unlinkFromUserAction_should_unlink_topic_from_user($request, $repository, $user) { $topic = new Topic(); $topic->setId(10); $topic->setTitle('test'); $topic->setParent(null); $userId = 1; $parameterBag = new ParameterBag(); $parameterBag->set('links', array(array('object' => $topic))); $request->attributes = $parameterBag; $repository->findOneBy(array('id' => $userId))->shouldBeCalled()->willReturn($user); $this->unlinkFromUserAction($request, $userId)->shouldReturn(null); }
// if child if (count($row) > 1) { try { $topicToInsert = end($row); $topicToInsertDetails = $app['db']->fetchAll($topicSql, array($topicToInsert)); $parentTopic = prev($row); $parentTopicDetails = $app['db']->fetchAll($topicSql, array($parentTopic)); if (empty($parentTopicDetails) || empty($topicToInsertDetails)) { continue; } $params = array('parent' => $parentTopic, 'last' => true); try { $locale = $app['orm.em']->getReference("Newscoop\\Entity\\Language", $topicToInsertDetails[0]['languageId'])->getCode(); $topic = new Topic(); $topic->setId($topicToInsertDetails[0]['id']); $topic->setTitle($topicToInsertDetails[0]['name']); $topic->setTranslatableLocale($locale); $app['topics_service']->saveTopicPosition($topic, $params); } catch (\Exception $e) { //topic already exists or language can not be found continue; } if (count($topicToInsertDetails) > 1) { unset($topicToInsertDetails[0]); foreach ($topicToInsertDetails as $key => $translation) { $locale = $app['orm.em']->getReference("Newscoop\\Entity\\Language", $translation['languageId'])->getCode(); $topicTranslation = new TopicTranslation($locale, 'title', $translation['name']); $topic->addTranslation($topicTranslation); } $app['orm.em']->flush(); }