/**
  * {@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;
     });
 }
Exemple #2
0
 /**
  * {@inheritDoc}
  */
 public function setUp()
 {
     $this->serviceManager = Bootstrap::getServiceManager();
     $this->ideaImage = $this->serviceManager->get('viewhelpermanager')->get('ideaImage');
     $idea = new Idea();
     $idea->setId(1);
     $idea->setIdea('This is the idea');
     $this->image = new Image();
     $this->image->setId(1);
     $this->image->setIdea($idea);
     $contentType = new ContentType();
     $contentType->setExtension('jpg');
     $this->image->setContentType($contentType);
 }
Exemple #3
0
 /**
  * {@inheritDoc}
  */
 public function setUp()
 {
     $this->serviceManager = Bootstrap::getServiceManager();
     $idea = new Idea();
     $idea->setId(1);
     $idea->setNumber(123123);
     $idea->setIdea('This is the idea');
     $this->ideaService = $this->serviceManager->get(IdeaService::class);
     $this->ideaService->setIdea($idea);
     $authorizeServiceMock = $this->getMockBuilder('BjyAuthorize\\View\\Helper\\IsAllowed')->disableOriginalConstructor()->getMock();
     $authorizeServiceMock->expects($this->any())->method('__invoke')->will($this->returnValue(true));
     $viewHelperManager = $this->serviceManager->get('viewhelpermanager');
     $viewHelperManager->setService('isAllowed', $authorizeServiceMock);
     $urlViewHelperMock = $this->getMockBuilder(Url::class)->disableOriginalConstructor()->getMock();
     $urlViewHelperMock->expects($this->any())->method('__invoke')->will($this->returnValue(true));
     $viewHelperManager->setService('url', $urlViewHelperMock);
     $this->ideaLink = $this->serviceManager->get('viewhelpermanager')->get('idealink');
 }
Exemple #4
0
 /**
  * Load the Project
  *
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $idea = new Idea();
     $idea->setNumber('1');
     $idea->setDescription('This is an idea description');
     $idea->setIdea("TIAD");
     $idea->setContact($manager->find("Contact\\Entity\\Contact", 1));
     $idea->setCall($manager->find("Program\\Entity\\Call\\Call", 1));
     $idea->setKeywords('test, idea, woei');
     $idea->setTitle('This is the title');
     $idea->setShortDescription('This is the short description');
     $idea->setApplicationDescription("This is the application description");
     $idea->setExternalPartners('These are the external partners');
     $idea->setHasPresentation(Idea::HAS_PRESENTATION);
     $idea->setHasPoster(Idea::HAS_POSTER);
     $idea->setVisibility(Idea::VISIBILITY_VISIBLE);
     $manager->persist($idea);
     $manager->flush();
 }
Exemple #5
0
 /**
  * @param Idea    $idea
  * @param Contact $contact
  * @param         $toggle
  */
 public function toggleFavouriteIdea(Idea $idea, Contact $contact, $toggle)
 {
     switch ($toggle) {
         case 'notFavourite':
             if ($idea->getFavourite()->contains($contact)) {
                 $idea->getFavourite()->removeElement($contact);
                 $this->updateEntity($idea);
             }
             break;
         case 'favourite':
             if (!$idea->getFavourite()->contains($contact)) {
                 $idea->getFavourite()->add($contact);
                 $this->updateEntity($idea);
             }
             break;
     }
 }