spec\Newscoop\NewscoopBundle\Controller\TopicsControllerSpec::its_addAction_should_add_a_new_topic_when_form_is_valid PHP Method

its_addAction_should_add_a_new_topic_when_form_is_valid() public method

public its_addAction_should_add_a_new_topic_when_form_is_valid ( $request, $formFactory, $form, $entityManager, $topicService, $repository, $topic, $csrfTokenManagerAdapter, $cacheService )
    public function its_addAction_should_add_a_new_topic_when_form_is_valid($request, $formFactory, $form, $entityManager, $topicService, $repository, $topic, $csrfTokenManagerAdapter, $cacheService)
    {
        $csrfTokenManagerAdapter->isCsrfTokenValid('default', $this->token)->willReturn(true);
        $classTopic = Argument::exact('Newscoop\\NewscoopBundle\\Entity\\Topic')->getValue();
        $topic = new $classTopic();
        $classTopicType = Argument::exact('Newscoop\\NewscoopBundle\\Form\\Type\\TopicType')->getValue();
        $topicType = new $classTopicType();
        $formFactory->create($topicType, $topic)->willReturn($form);
        $form->handleRequest($request)->willReturn($form);
        $form->isValid()->willReturn(true);
        $topicService->saveNewTopic($topic, 'en')->willReturn(true);
        $cacheService->clearNamespace('topic')->shouldBeCalled();
        $response = $this->addAction($request);
        $response->getStatusCode()->shouldReturn(200);
        $response->shouldBeAnInstanceOf('Symfony\\Component\\HttpFoundation\\JsonResponse');
    }