Пример #1
0
 /**
  * {@inheritDoc}
  */
 public function setUp()
 {
     $this->serviceManager = Bootstrap::getServiceManager();
     $this->call = new Call();
     $this->call->setId(1);
     $this->call->setCall('This is the call');
     $program = new Program();
     $program->setProgram('This is the program');
     $this->call->setProgram($program);
     $this->authorizeService = $this->serviceManager->get('BjyAuthorize\\Service\\Authorize');
     if (!$this->authorizeService->getAcl()->hasResource($this->call)) {
         $this->authorizeService->getAcl()->addResource($this->call);
         $this->authorizeService->getAcl()->allow([], $this->call, []);
     }
     /**
      * Add the resource on the fly
      */
     if (!$this->authorizeService->getAcl()->hasResource(new Call())) {
         $this->authorizeService->getAcl()->addResource(new Call());
     }
     $this->authorizeService->getAcl()->allow([], new Call(), []);
     $this->callLink = $this->serviceManager->get('viewhelpermanager')->get('calllink');
     /**
      * Bootstrap the application to have the other information available
      */
     $application = $this->serviceManager->get('application');
     $application->bootstrap();
 }
Пример #2
0
 /**
  * @param Call    $call
  * @param Contact $contact
  *
  * @return null|NdaEntity
  *
  * @throws \Doctrine\ORM\NonUniqueResultException
  */
 public function findNdaByCallAndContact(Call $call, Contact $contact)
 {
     $qb = $this->_em->createQueryBuilder();
     $qb->select('n');
     $qb->from("Program\\Entity\\Nda", 'n');
     $qb->join('n.call', 'call');
     $qb->andWhere($qb->expr()->in('call', [$call->getId()]));
     $qb->andWhere('n.contact = ?2');
     $qb->setParameter(2, $contact);
     $qb->addOrderBy('n.dateCreated', 'DESC');
     $qb->setMaxResults(1);
     return $qb->getQuery()->getOneOrNullResult();
 }
Пример #3
0
 /**
  * Load the Gender
  *
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $program = $manager->find("Program\\Entity\\Program", 1);
     $call = new \Program\Entity\Call\Call();
     $call->setProgram($program);
     $call->setCall('1');
     $call->setPoOpenDate(new \DateTime());
     $call->setPoCloseDate(new \DateTime());
     $call->setFppOpenDate(new \DateTime());
     $call->setFppCloseDate(new \DateTime());
     $call->setDoaRequirement(Call::DOA_REQUIREMENT_PER_PROGRAM);
     $manager->persist($call);
     $manager->flush();
 }
Пример #4
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();
 }
Пример #5
0
 public function testHasInputFilter()
 {
     $call = new Call();
     $this->assertInstanceOf('Zend\\InputFilter\\InputFilter', $call->getInputFilter());
 }
Пример #6
0
 /**
  * Returns true when a DOA per partner is required
  *
  * @return bool
  */
 public function requireDoaPerProject()
 {
     return $this->call->getDoaRequirement() === Call::DOA_REQUIREMENT_PER_PROJECT;
 }
Пример #7
0
 public function testToString()
 {
     $project = new Project();
     $project->setProject('12');
     $call = new Call();
     $call->setCall('test');
     $project->setCall($call);
     $this->assertNotNull((string) $project);
 }
Пример #8
0
 public function testCanCreateDifferentIdeaLinks()
 {
     $call = new Call();
     $call->setId(1);
     $this->assertContains('<a href', $this->ideaLink->__invoke($this->ideaService, 'view'));
 }
Пример #9
0
 /**
  * Returns the number for a new project in a call.
  * The number has a format of YYXXX where YY is the year of the call opening and XXX the number.
  *
  * @param Call $call
  *
  * @return string
  */
 public function findNextProjectNumberInCall(Call $call)
 {
     /*
      * Find the latest project in the given programCall
      */
     $project = $this->getEntityManager()->getRepository($this->getFullEntityName('project'))->findOneBy(['call' => $call], ['number' => 'DESC']);
     if (is_null($project)) {
         return $call->getPoOpenDate()->format("y") . sprintf("%1\$03d", 1);
     } else {
         return $project->getNumber() + 1;
     }
 }
Пример #10
0
 /**
  * This function returns an array with three elements
  *
  * 'partners' which contains the amount of partners
  * 'projects' which contains the amount of projects
  *
  * @param  CallEntity $call
  * @return array
  */
 public function findProjectAndPartners(CallEntity $call)
 {
     $queryBuilder = $this->_em->createQueryBuilder();
     $queryBuilder->select('COUNT(DISTINCT a.organisation) partners');
     $queryBuilder->addSelect('COUNT(DISTINCT a.project) projects');
     $queryBuilder->addSelect('SUM(c.fundingEu) funding_eu');
     $queryBuilder->addSelect('SUM(c.fundingNational) funding_national');
     $queryBuilder->from('Project\\Entity\\Cost\\Cost', 'c');
     $queryBuilder->join('c.affiliation', 'a');
     $queryBuilder->join('a.organisation', 'o');
     $queryBuilder->join('a.project', 'p');
     $queryBuilder->join('p.call', 'pc');
     $queryBuilder->where('pc.call = ?1');
     $queryBuilder->addGroupBy('pc.call');
     $queryBuilder->addOrderBy('pc.call');
     $queryBuilder->setParameter(1, $call->getCall());
     return $queryBuilder->getQuery()->getResult();
 }
Пример #11
0
 public function testParseProjectVersion()
 {
     $date = new \DateTime();
     $yesterday = $date->sub(new \DateInterval('P1D'));
     $date = new \DateTime();
     $tomorrow = $date->add(new \DateInterval('P1D'));
     $project = new Project();
     $call = new Call();
     $call->setFppCloseDate($yesterday);
     $project->setCall($call);
     $this->projectService->setProject($project);
     $versionType = new Type();
     $versionType->setId(Type::TYPE_PO);
     $version = new Version();
     $version->setApproved(Version::STATUS_APPROVED);
     $version->setVersionType($versionType);
     $versionService = new VersionService();
     $versionService->setVersion($version);
     $this->assertEquals('No FPP Submitted', $this->projectService->parseProjectVersion($versionService), 'Call close date is yesterday and version is approved');
     $this->projectService->getProject()->getCall()->setFppCloseDate($tomorrow);
     $this->assertContains('PO', $this->projectService->parseProjectVersion($versionService), 'Call close date is tomorrow and version is approved');
     $versionService->getVersion()->getVersionType()->setId(Type::TYPE_FPP);
     $versionService->getVersion()->getVersionType()->setType('fpp');
     $this->assertContains('Labelled', $this->projectService->parseProjectVersion($versionService), 'FPP submitted and approved');
     $versionService->getVersion()->getVersionType()->setId(Type::TYPE_CR);
     $this->projectService->getProject()->setDateStartActual($tomorrow);
     $this->assertEquals('Labelled', $this->projectService->parseProjectVersion($versionService), 'CR Project is labelled (will start)');
     $this->projectService->getProject()->setDateStartActual($yesterday);
     $this->assertEquals('Running', $this->projectService->parseProjectVersion($versionService), 'CR Project is running');
     $this->projectService->getProject()->setDateStartActual($yesterday);
     $this->projectService->getProject()->setDateEndActual($yesterday);
     $this->assertEquals('Completed', $this->projectService->parseProjectVersion($versionService), 'CR Project is completed');
     $versionService->getVersion()->getVersionType()->setId(Type::TYPE_SR);
     $this->assertEquals('Cancelled', $this->projectService->parseProjectVersion($versionService), 'CR Project is cancelled');
     $versionService->getVersion()->getVersionType()->setId('blaat');
     $this->assertEquals('Cannot determine state.', $this->projectService->parseProjectVersion($versionService), 'Incomplete state');
 }