| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- /*
- * Copyright 2026 Alessandro Chiapparini <sprint_planer_web@chiapparini.org>
- * SPDX-License-Identifier: Apache-2.0
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * See the LICENSE file in the project root for the full license text.
- */
- declare(strict_types=1);
- namespace App\Tests\Domain;
- use App\Domain\TaskAssignment;
- use PHPUnit\Framework\TestCase;
- /**
- * Phase 18: status enum guard. The repo + controller both lean on this for
- * validation, so it gets its own pin.
- */
- final class TaskAssignmentTest extends TestCase
- {
- public function testKnownStatusesAreValid(): void
- {
- $this->assertTrue(TaskAssignment::isValidStatus('zugewiesen'));
- $this->assertTrue(TaskAssignment::isValidStatus('gestartet'));
- $this->assertTrue(TaskAssignment::isValidStatus('abgeschlossen'));
- $this->assertTrue(TaskAssignment::isValidStatus('abgebrochen'));
- }
- public function testUnknownStatusesAreRejected(): void
- {
- $this->assertFalse(TaskAssignment::isValidStatus(''));
- $this->assertFalse(TaskAssignment::isValidStatus('done'));
- $this->assertFalse(TaskAssignment::isValidStatus('in-progress'));
- $this->assertFalse(TaskAssignment::isValidStatus('ZUGEWIESEN'));
- }
- public function testAuditSnapshotIncludesStatus(): void
- {
- $a = new TaskAssignment(1, 2, 3, 1.5, TaskAssignment::STATUS_GESTARTET);
- $snapshot = $a->toAuditSnapshot();
- $this->assertSame(1, $snapshot['id']);
- $this->assertSame(2, $snapshot['task_id']);
- $this->assertSame(3, $snapshot['sprint_worker_id']);
- $this->assertSame(1.5, $snapshot['days']);
- $this->assertSame(TaskAssignment::STATUS_GESTARTET, $snapshot['status']);
- }
- public function testStatusesListIsCanonicalOrder(): void
- {
- // Workflow order: assigned → started → done | cancelled. Tests both
- // the constant order and the count, so adding a new status doesn't
- // silently slot in the wrong spot.
- $this->assertSame(
- [
- TaskAssignment::STATUS_ZUGEWIESEN,
- TaskAssignment::STATUS_GESTARTET,
- TaskAssignment::STATUS_ABGESCHLOSSEN,
- TaskAssignment::STATUS_ABGEBROCHEN,
- ],
- TaskAssignment::STATUSES,
- );
- }
- }
|