spec\Newscoop\NewscoopBundle\Controller\TopicsControllerSpec::its_attachTopicAction_should_attach_topics PHP Méthode

its_attachTopicAction_should_attach_topics() public méthode

public its_attachTopicAction_should_attach_topics ( $request, $topic, $topicService, $queryBuilder, $user, $entityManager, $repository, $articleTopicrepository, $query, $article, $cacheService )
    public function its_attachTopicAction_should_attach_topics($request, $topic, $topicService, $queryBuilder, $user, $entityManager, $repository, $articleTopicrepository, $query, $article, $cacheService)
    {
        $user->hasPermission('AttachTopicToArticle')->willReturn(true);
        $entityManager->getRepository('Newscoop\\Entity\\Article')->willReturn($repository);
        $request->get('_articleNumber')->willReturn('64');
        $request->get('_languageCode')->willReturn('1');
        $request->get('ids')->willReturn(array('112', '113'));
        $repository->createQueryBuilder('a')->willReturn($queryBuilder);
        $queryBuilder->join('a.language', 'l')->willReturn($queryBuilder);
        $queryBuilder->where('a.number = :number')->willReturn($queryBuilder);
        $queryBuilder->andWhere('l.code = :code')->willReturn($queryBuilder);
        $queryBuilder->setParameters(array('number' => '64', 'code' => '1'))->willReturn($queryBuilder);
        $queryBuilder->getQuery()->willReturn($query);
        $query->getOneOrNullResult()->willReturn($article);
        $entityManager->getReference("Newscoop\\NewscoopBundle\\Entity\\Topic", Argument::type('string', 'integer'))->willReturn($topic);
        $articleTopicrepository->getArticleTopicsIds('64', true)->willReturn($query);
        $query->getArrayResult()->willReturn(array(array('109'), array('111')));
        $cacheService->clearNamespace('topic')->shouldBeCalled();
        $response = $this->attachTopicAction($request);
        $response->getStatusCode()->shouldReturn(200);
        $response->shouldBeAnInstanceOf('Symfony\\Component\\HttpFoundation\\JsonResponse');
    }