public function its_detachTopicAction_should_return_404_status_code_when_no_article($request, $user, $entityManager, $repository) { $user->hasPermission('AttachTopicToArticle')->willReturn(true); $entityManager->getRepository('Newscoop\\Entity\\Article')->willReturn($repository); $request->get('articleNumber')->willReturn('64'); $request->get('topicId')->willReturn('1'); $request->get('language')->willReturn('1'); $repository->findOneBy(array('number' => '64', 'language' => '1'))->willReturn(null); $response = $this->detachTopicAction($request); $response->getStatusCode()->shouldReturn(404); $response->shouldBeAnInstanceOf('Symfony\\Component\\HttpFoundation\\JsonResponse'); }