| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- declare(strict_types=1);
- namespace App\Tests\Controllers;
- use App\Controllers\SprintController;
- use App\Tests\TestCase;
- use ReflectionMethod;
- /**
- * Pure-static guards on SprintController. Mirrors ImportControllerTest:
- * exercise the bits that do not need PDO or session wiring.
- */
- final class SprintControllerTest extends TestCase
- {
- public function testWeeksBetweenInclusiveSameDayIsOneWeek(): void
- {
- $this->assertSame(1, self::call('weeksBetween', '2026-01-05', '2026-01-05'));
- }
- public function testWeeksBetweenSpansFullCalendarWeeks(): void
- {
- // Mon → Fri of the same week → 1 week.
- $this->assertSame(1, self::call('weeksBetween', '2026-01-05', '2026-01-09'));
- // Mon → Sun (end of the same week, +6 days) → 1 week.
- $this->assertSame(1, self::call('weeksBetween', '2026-01-05', '2026-01-11'));
- // Mon → Mon next week (+7 days) flips to 2 weeks.
- $this->assertSame(2, self::call('weeksBetween', '2026-01-05', '2026-01-12'));
- // Mon → Fri three weeks later → 3 weeks.
- $this->assertSame(3, self::call('weeksBetween', '2026-01-05', '2026-01-23'));
- }
- public function testWeeksBetweenClampsToOneWhenDatesAreReversed(): void
- {
- $this->assertSame(1, self::call('weeksBetween', '2026-01-12', '2026-01-05'));
- }
- private static function call(string $method, mixed ...$args): mixed
- {
- $r = new ReflectionMethod(SprintController::class, $method);
- $r->setAccessible(true);
- return $r->invoke(null, ...$args);
- }
- }
|