1
0

SprintControllerTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Tests\Controllers;
  4. use App\Controllers\SprintController;
  5. use App\Tests\TestCase;
  6. use ReflectionMethod;
  7. /**
  8. * Pure-static guards on SprintController. Mirrors ImportControllerTest:
  9. * exercise the bits that do not need PDO or session wiring.
  10. */
  11. final class SprintControllerTest extends TestCase
  12. {
  13. public function testWeeksBetweenInclusiveSameDayIsOneWeek(): void
  14. {
  15. $this->assertSame(1, self::call('weeksBetween', '2026-01-05', '2026-01-05'));
  16. }
  17. public function testWeeksBetweenSpansFullCalendarWeeks(): void
  18. {
  19. // Mon → Fri of the same week → 1 week.
  20. $this->assertSame(1, self::call('weeksBetween', '2026-01-05', '2026-01-09'));
  21. // Mon → Sun (end of the same week, +6 days) → 1 week.
  22. $this->assertSame(1, self::call('weeksBetween', '2026-01-05', '2026-01-11'));
  23. // Mon → Mon next week (+7 days) flips to 2 weeks.
  24. $this->assertSame(2, self::call('weeksBetween', '2026-01-05', '2026-01-12'));
  25. // Mon → Fri three weeks later → 3 weeks.
  26. $this->assertSame(3, self::call('weeksBetween', '2026-01-05', '2026-01-23'));
  27. }
  28. public function testWeeksBetweenClampsToOneWhenDatesAreReversed(): void
  29. {
  30. $this->assertSame(1, self::call('weeksBetween', '2026-01-12', '2026-01-05'));
  31. }
  32. private static function call(string $method, mixed ...$args): mixed
  33. {
  34. $r = new ReflectionMethod(SprintController::class, $method);
  35. $r->setAccessible(true);
  36. return $r->invoke(null, ...$args);
  37. }
  38. }