/**
  * findAmbassadorByContact returns a generator with only elements of ambassadors
  * based on the country.
  */
 public function testfindAmbassadorByContact()
 {
     $contact = new Contact();
     $contact->setId(1);
     $ambassadorCollection = $this->ambassadorService->findAmbassadorByContact($contact);
     foreach ($ambassadorCollection as $ambassador) {
         $this->assertInstanceOf('Ambassador', $ambassador);
         // contact and all Ambassadors selected have the Contact
         $this->assertEquals($ambassador->getContact(), $contact);
     }
 }
예제 #2
0
 /**
  * Tests the Contact.
  */
 public function testContact()
 {
     $ambassador = new Ambassador();
     $this->assertInstanceOf("Contact\\Entity\\Contact", $ambassador->getContact());
     // check if ambassador is initialized with an empty country
     $this->assertNull($ambassador->getContact()->getId());
     // if a new country is set check if it is set correctly
     $contact = new Contact();
     $contact->setId(rand(1, 10000));
     $ambassador->setContact($contact);
     $this->assertEquals($contact, $ambassador->getContact());
 }
예제 #3
0
 /**
  * {@inheritDoc}
  */
 public function setUp()
 {
     $this->serviceManager = Bootstrap::getServiceManager();
     $this->nda = new Nda();
     $this->nda->setId(1);
     $contact = new Contact();
     $contact->setId(1234);
     $this->nda->setContact($contact);
     $program = new Program();
     $program->setId(1);
     $program->setProgram('Program');
     $call = new Call();
     $call->setId(1);
     $call->setCall("Call");
     $call->setProgram($program);
     $this->nda->setCall(new ArrayCollection([$call]));
     $this->ndaLink = $this->serviceManager->get('viewhelpermanager')->get('ndaLink');
     /**
      * Bootstrap the application to have the other information available
      */
     $application = $this->serviceManager->get('application');
     $application->bootstrap();
 }
예제 #4
0
 /**
  * Function which returns true/false based ont he fact if a user can view the calendar
  *
  * @param Entity\Calendar $calendar
  * @param Contact         $contact
  *
  * @return bool
  */
 public function canViewCalendar(Entity\Calendar $calendar, Contact $contact = null)
 {
     $qb = $this->_em->createQueryBuilder();
     $qb->select('c');
     $qb->from("Calendar\\Entity\\Calendar", 'c');
     if ($contact->isEmpty()) {
         $contact = new Contact();
         $contact->setId(0);
         $access = new Access();
         $access->setAccess(strtolower(Access::ACCESS_PUBLIC));
         $contact->setAccess([$access]);
     }
     $qb = $this->filterForAccess($qb, $contact);
     $qb->andWhere('c = ?100');
     $qb->setParameter(100, $calendar);
     return !is_null($qb->getQuery()->getOneOrNullResult());
 }