feat: collect assignment and disposition events for statistics

This commit is contained in:
2026-08-26 15:17:17 +02:00
parent e210021fe3
commit 2662d56ac1
26 changed files with 2557 additions and 96 deletions
+73
View File
@@ -0,0 +1,73 @@
<?php
declare(strict_types=1);
namespace App\Tests\Form;
use App\Entity\Assignment;
use App\Form\AssignmentType;
use PHPUnit\Framework\TestCase;
/**
* Calling off an assignment has to go through the dedicated action, because that is the
* only path that also cancels the dispositions on it. Offering "abgesagt" in this form left
* teamers holding a live placement on a trip that had been cancelled - 23 assignments in the
* database are in exactly that state.
*
* The choice list is asserted directly rather than through a built form: the form also
* carries EntityType fields that query the database, and this suite does not have one.
* ChoiceType validates submissions against exactly this list, so it is the enforcement
* point, not merely what gets rendered.
*/
class AssignmentTypeTest extends TestCase
{
public function testADraftCannotBeCalledOffThroughTheStatusField(): void
{
$this->assertSame(
[Assignment::STATUS_DRAFT, Assignment::STATUS_PUBLISHED],
$this->statusChoices(Assignment::STATUS_DRAFT)
);
}
/**
* The published case is the one that mattered: a staffed trip cancelled from the edit
* form kept every disposition on it alive.
*/
public function testAPublishedAssignmentCannotBeCalledOffEither(): void
{
$this->assertNotContains(Assignment::STATUS_CALLED_OFF, $this->statusChoices(Assignment::STATUS_PUBLISHED));
}
/**
* Otherwise opening its edit form would render an empty status, and saving anything
* else on the page would silently resurrect the assignment.
*/
public function testAnAlreadyCalledOffAssignmentKeepsTheValue(): void
{
$this->assertContains(Assignment::STATUS_CALLED_OFF, $this->statusChoices(Assignment::STATUS_CALLED_OFF));
}
/**
* There is no dedicated undo for a call-off, so this form stays the way back.
*/
public function testACalledOffAssignmentCanStillBeRestored(): void
{
$this->assertContains(Assignment::STATUS_PUBLISHED, $this->statusChoices(Assignment::STATUS_CALLED_OFF));
}
/**
* A brand new assignment has no entity behind the form yet.
*/
public function testTheChoicesHoldWithoutAnAssignment(): void
{
$this->assertNotContains(Assignment::STATUS_CALLED_OFF, array_values(AssignmentType::statusChoices(null)));
}
/**
* @return array<int, string>
*/
private function statusChoices(string $status): array
{
return array_values(AssignmentType::statusChoices((new Assignment())->setStatus($status)));
}
}