protected function getAuthPlugin()
 {
     $controllerPlugin = new \ZfcUser\Controller\Plugin\ZfcUserAuthentication();
     $controllerPlugin->setAuthService($this->getAuthService());
     $controllerPlugin->setAuthAdapter($this->getAuthAdapter());
     return $controllerPlugin;
 }
 /**
  * {@inheritDoc}
  */
 public function setUp()
 {
     $this->setApplicationConfig(include __DIR__ . '/../../../../../../tests/config/application.config.php');
     parent::setUp();
     $this->controller = new IdeaController();
     $this->request = new Request();
     $this->response = null;
     $this->routeMatch = new RouteMatch(['controller' => 'project-idea']);
     $this->event = new MvcEvent();
     $router = new SimpleRouteStack();
     $router->addRoute('idea/idea', ['type' => 'Zend\\Mvc\\Router\\Http\\Literal', 'options' => ['route' => "project/idea.html"]]);
     $this->event->setRouter($router);
     $this->event->setRouteMatch($this->routeMatch);
     $this->controller->setEvent($this->event);
     //Get the serviceLocation and inject it into the controller
     $serviceLocator = $this->getApplicationServiceLocator();
     $this->controller->setServiceLocator($serviceLocator);
     $formService = $serviceLocator->get(FormService::class);
     $this->controller->setFormService($formService);
     $ideaServiceMock = $this->getMockBuilder('Project\\Service\\IdeaService')->disableOriginalConstructor()->getMock();
     $newEntityResult = new Idea();
     $newEntityResult->setId(1);
     $ideaServiceMock->expects($this->any())->method('newEntity')->will($this->returnValue($newEntityResult));
     $ideaServiceMock->expects($this->any())->method('findAll')->will($this->returnValue([]));
     $this->controller->setIdeaService($serviceLocator->get(IdeaService::class));
     $serviceManager = $this->getApplicationServiceLocator();
     $serviceManager->setAllowOverride(true);
     $serviceManager->setService(IdeaService::class, $ideaServiceMock);
     $authorizeServiceMock = $this->getMockBuilder('BjyAuthorize\\View\\Helper\\IsAllowed')->disableOriginalConstructor()->getMock();
     $authorizeServiceMock->expects($this->any())->method('__invoke')->will($this->returnValue(true));
     $serviceManager = $this->getApplicationServiceLocator()->get('viewhelpermanager');
     $serviceManager->setAllowOverride(true);
     $serviceManager->setService('isAllowed', $authorizeServiceMock);
     $this->controller->getPluginManager()->setFactory('zfcUserAuthentication', function ($sm) {
         $serviceLocator = $sm->getController()->getServiceLocator();
         $authService = new AuthenticationService();
         $nonPersistent = new NonPersistent();
         /**
          * Store a reference if the contact in the session
          */
         $entityManager = $serviceLocator->get('doctrine.entitymanager.orm_default');
         $contact = $entityManager->getReference("Contact\\Entity\\Contact", 1);
         $nonPersistent->write($contact);
         $authService->setStorage($nonPersistent);
         $authAdapter = $serviceLocator->get('ZfcUser\\Authentication\\Adapter\\AdapterChain');
         $controllerPlugin = new \ZfcUser\Controller\Plugin\ZfcUserAuthentication();
         $controllerPlugin->setAuthService($authService);
         $controllerPlugin->setAuthAdapter($authAdapter);
         return $controllerPlugin;
     });
 }