Http::response([ '2026-01-01' => '1er janvier', '2026-12-25' => 'Jour de Noël', ], 200), ]); $service = new PublicHolidaysApiService(); // WHEN $holidays = $service->fetchForYear(2026); // THEN expect($holidays)->toHaveCount(2) ->and($holidays[0]->date->format('Y-m-d'))->toBe('2026-01-01') ->and($holidays[0]->label)->toBe('1er janvier') ->and($holidays[1]->date->format('Y-m-d'))->toBe('2026-12-25') ->and($holidays[1]->label)->toBe('Jour de Noël'); Http::assertSent(fn (Request $request): bool => $request->url() === 'https://calendrier.api.gouv.fr/jours-feries/metropole/2026.json'); }); it('throws when the API returns a non-successful status', function (): void { // GIVEN Http::fake([ '*' => Http::response([], 503), ]); $service = new PublicHolidaysApiService(); // WHEN / THEN expect(fn () => $service->fetchForYear(2026)) ->toThrow(\UnexpectedValueException::class, 'Failed to fetch calendar from api'); }); it('throws when year is before 2026', function (): void { // GIVEN $service = new PublicHolidaysApiService(); // WHEN / THEN expect(fn () => $service->fetchForYear(2025)) ->toThrow(\InvalidArgumentException::class); }); });