/** * {@inheritDoc} */ public function setUp() { $this->serviceManager = Bootstrap::getServiceManager(); $this->versionService = $this->serviceManager->get(VersionService::class); $version = new Version(); $version->setId(1); $versionType = new Type(); $versionType->setDescription('This is the description'); $version->setVersionType($versionType); $this->versionService->setVersion($version); $project = new Project(); $project->setProject('This is the project'); $this->projectService = $this->serviceManager->get(ProjectService::class); // $this->projectService->setProject($project); $this->projectService->setProjectId(1); $this->versionService->getVersion()->setProject($this->projectService->getProject()); $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->versionLink = $viewHelperManager->get('versionlink'); }
/** * {@inheritDoc} */ public function setUp() { $this->serviceManager = Bootstrap::getServiceManager(); $this->document = new Document(); $this->document->setId(1); $this->document->setDocument('This is the document'); $contentType = new ContentType(); $contentType->setExtension('.xyz'); $this->document->setContentType($contentType); $project = new Project(); $project->setId(1); $project->setNumber('1234'); $project->setProject('This is the number'); $workpackage = new Workpackage(); $workpackage->setSequence(1); $workpackage->setProject($project); $this->document->setWorkpackage($workpackage); $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->documentLink = $viewHelperManager->get('workpackageDocumentlink'); }
/** * @return array */ public function provider() { $dateTime = new \DateTime(); $dateStart = $dateTime->sub(new \DateInterval('P1Y')); $dateEnd = $dateTime->add(new \DateInterval('P4Y')); $dateTime = new \DateTime(); $dateStartActual = $dateTime->sub(new \DateInterval('P6M')); $dateEndActual = $dateTime->add(new \DateInterval('P3Y')); $contactTest = new ContactTest(); $callTest = new CallTest(); $project = new Project(); $project->setCall($callTest->provider()[0][0]); $project->setDateStart($dateStart); $project->setDateEnd($dateEnd); $project->setDateStartActual($dateStartActual); $project->setDateEndActual($dateEndActual); $project->setNumber(Rand::getString(4)); $project->setContact($contactTest->provider()[0][0]); $project->setSummary('This is the summary'); $project->setDescription('This is the description'); $versionType = new Type(); $versionType->setType('Type'); $versionType->setId(1); return [[$project, $versionType]]; }
public function testCanCreateDifferentReportLinks() { $project = new Project(); $project->setId(1); $this->assertContains('<a href', $this->reportLink->__invoke($this->report, 'create-community', 'text', $project)); $this->assertContains('<a href', $this->reportLink->__invoke($this->report, 'report-community')); $this->assertContains('<a href', $this->reportLink->__invoke($this->report, 'download')); $this->assertContains('<a href', $this->reportLink->__invoke($this->report, 'download-binder', 'text', null, 2014, 2)); $this->assertContains('<a href', $this->reportLink->__invoke($this->report, 'overview-community', 'text', null, 2014, 2)); }
/** * Redirect an old project to a new project. */ public function projectAction() { $this->getProjectService()->setProjectId((int) $this->getRequest()->getQuery()->get('project')); /* * Return a 404 when no project can be found */ if ($this->getProjectService()->isEmpty()) { return $this->notFoundAction(); } $project = new Project(); return $this->redirect()->toRoute('route-' . $project->get('underscore_full_entity_name'), ['docRef' => $this->getProjectService()->getProject()->getDocRef()])->setStatusCode(301); }
public function testCanCreateDifferentResultLinks() { $project = new Project(); $project->setId(1); $this->assertContains('<a href', $this->resultLink->__invoke($this->result, 'download', 'text')); }
public function testGetFunctions() { $project = new Project(); $this->assertNotNull($project->get('entity_name')); $this->assertNotNull($project->get('dashed_entity_name')); $this->assertNotNull($project->get('underscore_entity_name')); }
public function getProjectComments(Project $project) { $query = $this->_em->createQuery("SELECT u FROM Comment\\Entity\\Comment u WHERE u.projectId = :projectId"); $query->setParameters(array('projectId' => $project->getProjectId())); return $query->getResult(); }
/** * Check to see if a project is in prepare mode. * * @return bool */ public function isPrepareMode() { return $this->project->getMode() !== Project::MODE_DEFAULT; }
/** * Produce a list of organisations for a project (only active). * * @param Project $project * @param bool $onlyActiveProject * * @return OrganisationService[] */ public function findOrganisationByProject(Project $project, $onlyActiveProject = true) { $organisations = []; foreach ($project->getAffiliation() as $affiliation) { if ($onlyActiveProject && is_null($affiliation->getDateEnd())) { //Add the organisation in the key to sort on it $organisations[sprintf("%s-%s", $affiliation->getOrganisation()->getOrganisation(), $affiliation->getOrganisation()->getCountry()->getCountry())] = $this->createServiceElement($affiliation->getOrganisation()); } } //Sort on the key (ASC) ksort($organisations); return $organisations; }
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'); }
/** * @param bool $onlyFinal * @param Project $project * * @return Calendar[] */ public function findCalendarByProject(Project $project, $onlyFinal = true) { $calendar = []; /** * Add the calendar items from the project */ foreach ($project->getProjectCalendar() as $calendarItem) { if (!$onlyFinal || $calendarItem->getCalendar()->getFinal() === Calendar::FINAL_FINAL) { $calendar[$calendarItem->getCalendar()->getId()] = $calendarItem->getCalendar(); } } foreach ($project->getCall()->getCalendar() as $calendarItem) { if (!$onlyFinal || $calendarItem->getFinal() === Calendar::FINAL_FINAL) { if ($calendarItem->getDateEnd() > new \DateTime()) { $calendar[$calendarItem->getId()] = $calendarItem; } } } return $calendar; }
/** * @param Project $project * @param Contact $contact * @param int $which * * @return null|Affiliation */ public function findAffiliationByProjectAndContactAndWhich(Project $project, Contact $contact, $which = self::WHICH_ONLY_ACTIVE) { /** * If the contact has no contact organisation, return null because we will not have a affiliation */ if (is_null($contact->getContactOrganisation())) { return; } foreach ($project->getAffiliation() as $affiliation) { if ($which === self::WHICH_ONLY_ACTIVE && !is_null($affiliation->getDateEnd())) { continue; } if ($which === self::WHICH_ONLY_INACTIVE && is_null($affiliation->getDateEnd())) { continue; } if ($affiliation->getOrganisation()->getId() === $contact->getContactOrganisation()->getOrganisation()->getId()) { return $affiliation; } } return; }
/** * This function takes all the cost versions grouped by a project version. By toggling the toArray * a special array is produced for displaying purposes. * * @param Project $project * @param Version $version * * @return Effort\Version[]|array */ public function findEffortVersionByProjectPerWorkpackageByVersion(Project $project, Version $version) { $effortByWorkpackage = []; $versionService = new VersionService(); foreach ($project->getWorkpackage() as $workpackage) { if (!is_null($workpackage->getDateEnd())) { continue; } $effortVersion = $this->getEntityManager()->getRepository($this->getFullEntityName('Effort\\Version'))->findEffortVersionByWorkpackageAndVersion($workpackage, $version); $effortByWorkpackage[$workpackage->getId()] = ['workpackage' => $workpackage, 'effort' => $versionService->parseCostOrEffortVersionAsArray($effortVersion)]; } return $effortByWorkpackage; }
/** * Load the Project * * @param ObjectManager $manager */ public function load(ObjectManager $manager) { $project = new Project(); $project->setCall($manager->find("Program\\Entity\\Call\\Call", 1)); $project->setNumber('12345'); $project->setProject('This is a testProject'); $project->setTitle('This is the title'); $dateTime = new \DateTime(); $project->setDateStart($dateTime->sub(new \DateInterval('P1Y'))); $project->setDateEnd($dateTime->add(new \DateInterval('P4Y'))); $dateTime = new \DateTime(); $project->setDateStartActual($dateTime->sub(new \DateInterval('P6M'))); $project->setDateEndActual($dateTime->add(new \DateInterval('P3Y'))); $project->setContact($manager->find("Contact\\Entity\\Contact", 1)); $project->setDescription('This is the description'); $project->setMode(Project::MODE_DEFAULT); $project->setSummary('This is the summary'); $manager->persist($project); $manager->flush(); }