feat: review received form submissions in the admin ui
This commit is contained in:
1 parent
f073a2014d
commit
cb2d64f2cd
19 files changed
+999
-7
No files matched your search
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Model;
|
||||
|
||||
use App\Entity\ApplicationFormSubmission;
|
||||
use App\Model\ApplicationFormSubmissionCallsDto;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ApplicationFormSubmissionCallsDtoTest extends TestCase
|
||||
{
|
||||
public function testTickingABoxStampsToday(): void
|
||||
{
|
||||
$submission = $this->submission();
|
||||
|
||||
$dto = new ApplicationFormSubmissionCallsDto($submission);
|
||||
$dto->setFirstCallHeld(true)->applyToSubmission();
|
||||
|
||||
$this->assertSame(
|
||||
(new \DateTimeImmutable('today'))->format('Y-m-d'),
|
||||
$submission->getFirstCallHeldAt()?->format('Y-m-d')
|
||||
);
|
||||
$this->assertNull($submission->getSecondCallHeldAt());
|
||||
}
|
||||
|
||||
/**
|
||||
* The reason the DTO exists: saving the form again must not move a call from the day it
|
||||
* happened to today.
|
||||
*/
|
||||
public function testAnAlreadyHeldCallKeepsItsDate(): void
|
||||
{
|
||||
$held = new \DateTimeImmutable('2026-09-01');
|
||||
$submission = $this->submission()->setFirstCallHeldAt($held);
|
||||
|
||||
$dto = new ApplicationFormSubmissionCallsDto($submission);
|
||||
$this->assertTrue($dto->isFirstCallHeld());
|
||||
|
||||
$dto->applyToSubmission();
|
||||
|
||||
$this->assertSame($held, $submission->getFirstCallHeldAt());
|
||||
}
|
||||
|
||||
public function testUntickingClearsTheDate(): void
|
||||
{
|
||||
$submission = $this->submission()->setSecondCallHeldAt(new \DateTimeImmutable('2026-09-01'));
|
||||
|
||||
$dto = new ApplicationFormSubmissionCallsDto($submission);
|
||||
$dto->setSecondCallHeld(false)->applyToSubmission();
|
||||
|
||||
$this->assertNull($submission->getSecondCallHeldAt());
|
||||
}
|
||||
|
||||
private function submission(): ApplicationFormSubmission
|
||||
{
|
||||
return new ApplicationFormSubmission(
|
||||
'applicationform',
|
||||
'Bewerbungsformular',
|
||||
new \DateTimeImmutable('2026-09-22T12:30:00+02:00')
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user