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

its_addAction_should_not_add_a_new_topic_when_form_is_invalid() public method

public its_addAction_should_not_add_a_new_topic_when_form_is_invalid ( Symfony\Component\Form\FormErrorIterator $formIterator, FormError $formError, $request, $formFactory, $form, $entityManager, $topicRepository, $repository, $topic, $csrfTokenManagerAdapter )
$formIterator Symfony\Component\Form\FormErrorIterator
$formError Symfony\Component\Form\FormError
    public function its_addAction_should_not_add_a_new_topic_when_form_is_invalid(FormErrorIterator $formIterator, FormError $formError, $request, $formFactory, $form, $entityManager, $topicRepository, $repository, $topic, $csrfTokenManagerAdapter)
    {
        $entityManager->getRepository('Newscoop\\NewscoopBundle\\Entity\\Topic')->willReturn($topicRepository);
        $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(false);
        $form->getErrors()->willReturn($formIterator);
        $formIterator->getChildren()->willReturn($formError);
        $formError->getMessage()->willReturn('Invalid form');
        $responseArray = '{"status":false,"message":"Invalid form"}';
        $response = $this->addAction($request);
        $response->getContent()->shouldReturn($responseArray);
        $response->getStatusCode()->shouldReturn(200);
        $response->shouldBeAnInstanceOf('Symfony\\Component\\HttpFoundation\\JsonResponse');
    }