Exemplo n.º 1
0
 /**
  * {@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');
 }
Exemplo n.º 2
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');
 }