TaskAssignmentTest.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /*
  3. * Copyright 2026 Alessandro Chiapparini <sprint_planer_web@chiapparini.org>
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * See the LICENSE file in the project root for the full license text.
  9. */
  10. declare(strict_types=1);
  11. namespace App\Tests\Domain;
  12. use App\Domain\TaskAssignment;
  13. use PHPUnit\Framework\TestCase;
  14. /**
  15. * Phase 18: status enum guard. The repo + controller both lean on this for
  16. * validation, so it gets its own pin.
  17. */
  18. final class TaskAssignmentTest extends TestCase
  19. {
  20. public function testKnownStatusesAreValid(): void
  21. {
  22. $this->assertTrue(TaskAssignment::isValidStatus('zugewiesen'));
  23. $this->assertTrue(TaskAssignment::isValidStatus('gestartet'));
  24. $this->assertTrue(TaskAssignment::isValidStatus('abgeschlossen'));
  25. $this->assertTrue(TaskAssignment::isValidStatus('abgebrochen'));
  26. }
  27. public function testUnknownStatusesAreRejected(): void
  28. {
  29. $this->assertFalse(TaskAssignment::isValidStatus(''));
  30. $this->assertFalse(TaskAssignment::isValidStatus('done'));
  31. $this->assertFalse(TaskAssignment::isValidStatus('in-progress'));
  32. $this->assertFalse(TaskAssignment::isValidStatus('ZUGEWIESEN'));
  33. }
  34. public function testAuditSnapshotIncludesStatus(): void
  35. {
  36. $a = new TaskAssignment(1, 2, 3, 1.5, TaskAssignment::STATUS_GESTARTET);
  37. $snapshot = $a->toAuditSnapshot();
  38. $this->assertSame(1, $snapshot['id']);
  39. $this->assertSame(2, $snapshot['task_id']);
  40. $this->assertSame(3, $snapshot['sprint_worker_id']);
  41. $this->assertSame(1.5, $snapshot['days']);
  42. $this->assertSame(TaskAssignment::STATUS_GESTARTET, $snapshot['status']);
  43. }
  44. public function testStatusesListIsCanonicalOrder(): void
  45. {
  46. // Workflow order: assigned → started → done | cancelled. Tests both
  47. // the constant order and the count, so adding a new status doesn't
  48. // silently slot in the wrong spot.
  49. $this->assertSame(
  50. [
  51. TaskAssignment::STATUS_ZUGEWIESEN,
  52. TaskAssignment::STATUS_GESTARTET,
  53. TaskAssignment::STATUS_ABGESCHLOSSEN,
  54. TaskAssignment::STATUS_ABGEBROCHEN,
  55. ],
  56. TaskAssignment::STATUSES,
  57. );
  58. }
  59. }