entityManager = static::getContainer()->get(EntityManagerInterface::class); } public function testReleaseDateUpdatesOnCampaignStart(): void { $owner = new User(); $owner->setHandle('test_calendar_user'); $owner->setEmail('testcalendaruser@example.com'); $owner->setPassword('projectapitestcalendaruserpassword'); // Create Project $project = new Project(); $project->setTitle('Test Project'); $project->setSubtitle('Test Project Subtitle'); $project->setDeadline(ProjectDeadline::Minimum); $project->setCategory(Category::LibreSoftware); $project->setDescription('Test Project Description'); $project->setTerritory(new ProjectTerritory('ES')); $project->setOwner($owner); $project->setStatus(ProjectStatus::InReview); $this->entityManager->persist($owner); $this->entityManager->persist($project); $this->entityManager->flush(); // Change State to IN_CAMPAIGN $project->setStatus(ProjectStatus::InCampaign); $this->entityManager->flush(); $this->assertNotNull($project->getCalendar()->release); } public function testMinimumDeadlineIsSetCorrectly(): void { $owner = new User(); $owner->setHandle('test_min_deadline_user'); $owner->setEmail('testmindeadlineuser@example.com'); $owner->setPassword('projectapitestmindeadlineuserpassword'); $project = new Project(); $project->setTitle('Test Project'); $project->setSubtitle('Test Project Subtitle'); $project->setDeadline(ProjectDeadline::Minimum); $project->setCategory(Category::LibreSoftware); $project->setDescription('Test Project Description'); $project->setTerritory(new ProjectTerritory('ES')); $project->setOwner($owner); $project->setStatus(ProjectStatus::InReview); $this->entityManager->persist($owner); $this->entityManager->persist($project); $this->entityManager->flush(); $project->setStatus(ProjectStatus::InCampaign); $this->entityManager->flush(); $releaseDate = $project->getCalendar()->release; $minimumDeadline = $project->getCalendar()->minimum; $this->assertNotNull($minimumDeadline); $this->assertGreaterThan($releaseDate, $minimumDeadline); $this->assertEquals($releaseDate->modify('+40 days'), $minimumDeadline); } public function testOptimumDeadlineIsSetCorrectly(): void { $owner = new User(); $owner->setHandle('test_optimum_deadline_user'); $owner->setEmail('testoptimumdeadlineuser@example.com'); $owner->setPassword('projectapitestoptimumdeadlineuserpassword'); $project = new Project(); $project->setTitle('Test Project'); $project->setSubtitle('Test Project Subtitle'); $project->setDeadline(ProjectDeadline::Optimum); $project->setCategory(Category::LibreSoftware); $project->setDescription('Test Project Description'); $project->setTerritory(new ProjectTerritory('ES')); $project->setOwner($owner); $project->setStatus(ProjectStatus::InReview); $project->setCalendar(new ProjectCalendar()); $this->entityManager->persist($owner); $this->entityManager->persist($project); $this->entityManager->flush(); $project->setStatus(ProjectStatus::InCampaign); $this->entityManager->flush(); $minimumDeadline = $project->getCalendar()->minimum; $optimumDeadline = $project->getCalendar()->optimum; $this->assertNotNull($optimumDeadline); $this->assertGreaterThan($minimumDeadline, $optimumDeadline); $this->assertEquals($minimumDeadline->modify('+40 days'), $optimumDeadline); } }