createDisposition(createdAt: 'today -2 days', assignmentEndsIn: '+30 days'); $this->assertFalse($disposition->isContractDue(self::CONTRACT_DEADLINE_DAYS)); } public function testTheContractIsDueOnceTheUploadPeriodHasRunOut(): void { $disposition = $this->createDisposition(createdAt: 'today -6 days', assignmentEndsIn: '+30 days'); $this->assertTrue($disposition->isContractDue(self::CONTRACT_DEADLINE_DAYS)); } /** * The upload is blocked from the day before the assignment ends, so past that point the * dashboard would be asking for something the workflow guard refuses. */ public function testTheContractStopsBeingDueOnceTheUploadIsBlocked(): void { $disposition = $this->createDisposition(createdAt: 'today -60 days', assignmentEndsIn: '+1 day'); $this->assertFalse($disposition->isContractDue(self::CONTRACT_DEADLINE_DAYS)); } public function testAnUploadedContractIsNeverDue(): void { $disposition = $this->createDisposition(createdAt: 'today -60 days', assignmentEndsIn: '+30 days'); $disposition->addDocument((new Upload())->setType(Upload::TYPE_CONTRACT)); $this->assertFalse($disposition->isContractDue(self::CONTRACT_DEADLINE_DAYS)); } public function testTheInvoiceIsNotDueWhileTheAssignmentIsStillRunning(): void { $disposition = $this->createDisposition(createdAt: 'today -30 days', assignmentEndsIn: '+5 days'); $this->assertFalse($disposition->isInvoiceDue(self::INVOICE_DEADLINE_DAYS)); } public function testTheInvoiceIsDueOnceTheAssignmentHasEnded(): void { $disposition = $this->createDisposition(createdAt: 'today -30 days', assignmentEndsIn: '-1 day'); $this->assertTrue($disposition->isInvoiceDue(self::INVOICE_DEADLINE_DAYS)); } /** * Nothing blocks a late invoice upload, so unlike the contract this must keep asking. */ public function testTheInvoiceStaysDueAfterTheUploadPeriodHasRunOut(): void { $disposition = $this->createDisposition(createdAt: 'today -90 days', assignmentEndsIn: '-60 days'); $this->assertTrue($disposition->isInvoiceDue(self::INVOICE_DEADLINE_DAYS)); } private function createDisposition(string $createdAt, string $assignmentEndsIn): Disposition { $destination = (new Destination()) ->setProduct('Skireise') ->setDateFrom(new \DateTimeImmutable($assignmentEndsIn.' -7 days')) ->setDateTo(new \DateTimeImmutable($assignmentEndsIn)) ; $disposition = new Disposition( new Application((new Assignment())->setDestination($destination), new Teamer()) ); return $disposition->setCreatedAt(new \DateTimeImmutable($createdAt)); } }