Files
Lesstime/tests/Unit/Service/PublicHolidayProviderTest.php
T
Matthieu 306cfd34cd feat(absence) : migrate Absence domain into module (back)
LST-66 (2.3) backend. Behaviour-preserving move of the absences domain into
src/Module/Absence/. API operations, securities, routes and the 10 MCP tool
names are unchanged.

- 3 entities + 3 enums moved to Domain/{Entity,Enum}; user relations stay on
  UserInterface. 3 repositories split into Domain/Repository interfaces +
  Doctrine impls (bound in services.yaml); find() kept off interfaces
  (findById instead).
- Pure services (AbsenceDayCalculator, PublicHolidayProvider) -> Domain/Service;
  AbsenceBalanceService -> Application/Service; State (5), controllers (5),
  10 MCP tools and AccrueLeaveCommand -> Infrastructure/.
- New LeaveProfileInterface contract (Shared) exposes the HR getters used by
  AbsenceBalanceService/AccrueLeaveCommand; User implements it -> Absence no
  longer imports the concrete Core User. MCP tools/command inject
  UserRepositoryInterface (findById) instead of the concrete repository.
- Timestampable/Blamable added to AbsenceBalance and AbsencePolicy (additive
  migration: created_at/updated_at + created_by/updated_by FK ON DELETE SET
  NULL + COMMENT). AbsenceRequest untouched (already has createdAt/reviewedAt).
- AbsenceModule registered (id absence, 4 RBAC perms, not re-wired); doctrine
  mapping added; team-absences sidebar item gated by the module.

161 tests green, mapping valid, no API route regression, cs-fixer clean.
2026-06-20 18:32:02 +02:00

73 lines
2.3 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Tests\Unit\Service;
use App\Module\Absence\Domain\Service\PublicHolidayProvider;
use DateTimeImmutable;
use PHPUnit\Framework\TestCase;
/**
* @internal
*/
class PublicHolidayProviderTest extends TestCase
{
private PublicHolidayProvider $provider;
protected function setUp(): void
{
$this->provider = new PublicHolidayProvider();
}
public function testReturnsElevenHolidaysForMetropole(): void
{
self::assertCount(11, $this->provider->getHolidays(2026));
}
public function testFixedHolidaysHaveCorrectLabels(): void
{
$holidays = $this->provider->getHolidays(2026);
self::assertSame('Jour de l\'an', $holidays['2026-01-01']);
self::assertSame('Fête du Travail', $holidays['2026-05-01']);
self::assertSame('Victoire 1945', $holidays['2026-05-08']);
self::assertSame('Fête nationale', $holidays['2026-07-14']);
self::assertSame('Assomption', $holidays['2026-08-15']);
self::assertSame('Toussaint', $holidays['2026-11-01']);
self::assertSame('Armistice 1918', $holidays['2026-11-11']);
self::assertSame('Noël', $holidays['2026-12-25']);
}
/**
* Easter 2026 is April 5th, so Easter Monday is April 6th,
* Ascension is May 14th and Whit Monday is May 25th.
*/
public function testEasterBasedHolidays2026(): void
{
$holidays = $this->provider->getHolidays(2026);
self::assertSame('Lundi de Pâques', $holidays['2026-04-06']);
self::assertSame('Ascension', $holidays['2026-05-14']);
self::assertSame('Lundi de Pentecôte', $holidays['2026-05-25']);
}
/**
* Easter 2025 is April 20th, so Easter Monday is April 21st.
*/
public function testEasterBasedHolidays2025(): void
{
$holidays = $this->provider->getHolidays(2025);
self::assertSame('Lundi de Pâques', $holidays['2025-04-21']);
}
public function testIsHoliday(): void
{
self::assertTrue($this->provider->isHoliday(new DateTimeImmutable('2026-05-01')));
self::assertTrue($this->provider->isHoliday(new DateTimeImmutable('2026-05-14')));
self::assertFalse($this->provider->isHoliday(new DateTimeImmutable('2026-05-02')));
self::assertFalse($this->provider->isHoliday(new DateTimeImmutable('2026-06-01')));
}
}