9d2e70f81e
Auto Tag Develop / tag (push) Successful in 13s
Le récap des congés se fige désormais à la fin de la semaine précédente (S-1) au lieu de l'avant-dernière (S-2), incluant ainsi une semaine de plus. Demande métier. - LeaveRecapCutoff : -14j -> -7j - Test unitaire figeant la règle S-1 - Doc fonctionnelle, doc in-app et CLAUDE.md mis à jour Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
51 lines
1.6 KiB
PHP
51 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Tests\Util;
|
|
|
|
use App\Util\LeaveRecapCutoff;
|
|
use DateTimeImmutable;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
/**
|
|
* Cutoff rule: end of ISO week S-1 (previous week's Sunday 23:59:59).
|
|
*
|
|
* @internal
|
|
*/
|
|
final class LeaveRecapCutoffTest extends TestCase
|
|
{
|
|
public function testCutoffIsPreviousWeekSunday(): void
|
|
{
|
|
// Tuesday 2026-04-14 (S16) → Sunday 2026-04-12 23:59:59 (end of S15).
|
|
$cutoff = LeaveRecapCutoff::resolveCutoff(new DateTimeImmutable('2026-04-14'));
|
|
|
|
self::assertSame('2026-04-12 23:59:59', $cutoff->format('Y-m-d H:i:s'));
|
|
}
|
|
|
|
public function testCutoffFromMondayPointsToPreviousSunday(): void
|
|
{
|
|
// Monday 2026-06-08 → previous Sunday 2026-06-07 23:59:59.
|
|
$cutoff = LeaveRecapCutoff::resolveCutoff(new DateTimeImmutable('2026-06-08'));
|
|
|
|
self::assertSame('2026-06-07 23:59:59', $cutoff->format('Y-m-d H:i:s'));
|
|
}
|
|
|
|
public function testCutoffFromSundayPointsToPreviousSunday(): void
|
|
{
|
|
// Sunday 2026-06-14 (still in current ISO week) → previous Sunday 2026-06-07.
|
|
$cutoff = LeaveRecapCutoff::resolveCutoff(new DateTimeImmutable('2026-06-14'));
|
|
|
|
self::assertSame('2026-06-07 23:59:59', $cutoff->format('Y-m-d H:i:s'));
|
|
}
|
|
|
|
public function testCutoffIsAlwaysASundayExactlyOneWeekBeforeCurrentWeek(): void
|
|
{
|
|
// Today 2026-06-11 (Thursday) → end of S-1 = Sunday 2026-06-07.
|
|
$cutoff = LeaveRecapCutoff::resolveCutoff(new DateTimeImmutable('2026-06-11'));
|
|
|
|
self::assertSame('Sunday', $cutoff->format('l'));
|
|
self::assertSame('2026-06-07 23:59:59', $cutoff->format('Y-m-d H:i:s'));
|
|
}
|
|
}
|