format('Y-m-d'))->toBe($easter) ->and(array_search('midsummer_eve', $holidays, true))->toBe($midsummerEve); })->with([ [2025, '2025-04-20', '2025-06-20'], [2026, '2026-04-05', '2026-06-19'], [2027, '2027-03-28', '2027-06-25'], ]); it('lists the holidays of a year in date order', function () { expect(FinnishHolidays::forYear(2026))->toBe([ '2026-01-01' => 'new_years_day', '2026-01-06' => 'epiphany', '2026-04-03' => 'good_friday', '2026-04-06' => 'easter_monday', '2026-05-01' => 'may_day', '2026-05-14' => 'ascension_day', '2026-06-19' => 'midsummer_eve', '2026-12-06' => 'independence_day', '2026-12-24' => 'christmas_eve', '2026-12-25' => 'christmas_day', '2026-12-26' => 'st_stephens_day', ]); }); it('takes holidays out of use and adds company days off', function () { $calendar = new HolidayCalendar(new InMemoryHolidayOverrides); $calendar->disable('2026-12-24'); $calendar->addCompanyDay('2026-12-23', ' Pikkujoulu '); $december = $calendar->between('2026-12-20', '2026-12-31'); expect(array_map(fn ($holiday) => [$holiday->date, $holiday->key, $holiday->name, $holiday->active], $december))->toBe([ ['2026-12-23', null, 'Pikkujoulu', true], ['2026-12-24', 'christmas_eve', null, false], ['2026-12-25', 'christmas_day', null, true], ['2026-12-26', 'st_stephens_day', null, true], ])->and($calendar->activeDatesBetween('2026-12-20', '2026-12-31'))->toBe(['2026-12-23', '2026-12-25', '2026-12-26']); $calendar->enable('2026-12-24'); $calendar->removeCompanyDay('2026-12-23'); expect($calendar->activeDatesBetween('2026-12-20', '2026-12-31'))->toBe(['2026-12-24', '2026-12-25', '2026-12-26']); }); it('rejects invalid holiday changes', function () { $calendar = new HolidayCalendar(new InMemoryHolidayOverrides); expect(fn () => $calendar->disable('2026-12-23'))->toThrow(NotAHoliday::class) ->and(fn () => $calendar->removeCompanyDay('2026-12-25'))->toThrow(NotAHoliday::class) ->and(fn () => $calendar->addCompanyDay('2026-12-25', 'Joulu'))->toThrow(HolidayAlreadyExists::class) ->and(fn () => $calendar->addCompanyDay('2026-12-23', ' '))->toThrow(InvalidHolidayName::class); });