SprintControllerTest.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. /**
  39. * R01-N24: the per-batch list cap is a drift-sensitive number — bumping
  40. * it has security implications (memory + DB pressure under attacker
  41. * load) and operator implications (existing tooling that batches near
  42. * the cap may break). A future refactor that tweaks it must update
  43. * REVIEW_01.md §R01-N24 in the same commit.
  44. */
  45. public function testMaxBatchItemsConstant(): void
  46. {
  47. $this->assertSame(5000, SprintController::MAX_BATCH_ITEMS);
  48. }
  49. }