diff --git a/src/Actions/Belgium.php b/src/Actions/Belgium.php index 13633930e..311a0e9cf 100644 --- a/src/Actions/Belgium.php +++ b/src/Actions/Belgium.php @@ -3,7 +3,6 @@ namespace Spatie\Holidays\Actions; use Carbon\CarbonImmutable; -use Spatie\Holidays\Data\Holiday; use Spatie\Holidays\Exceptions\HolidaysException; class Belgium implements Executable diff --git a/src/Holidays.php b/src/Holidays.php index d8629d10c..bba68ceb5 100755 --- a/src/Holidays.php +++ b/src/Holidays.php @@ -46,6 +46,10 @@ public function country(string $countryCode): static /** @return arrayholidays === []) { + $this->calculate(); + } + return $this->format($this->holidays); } diff --git a/tests/.pest/snapshots/HolidaysTest/it_can_get_all_holidays_of_another_year.snap b/tests/.pest/snapshots/HolidaysTest/it_can_get_all_holidays_of_another_year.snap new file mode 100644 index 000000000..cb3cfc36f --- /dev/null +++ b/tests/.pest/snapshots/HolidaysTest/it_can_get_all_holidays_of_another_year.snap @@ -0,0 +1,42 @@ +[ + { + "name": "Nieuwjaar", + "date": "01-01-2022" + }, + { + "name": "Paasmaandag", + "date": "04-17-2022" + }, + { + "name": "Dag van de Arbeid", + "date": "05-01-2022" + }, + { + "name": "OH Hemelvaart", + "date": "05-25-2022" + }, + { + "name": "Pinkstermaandag", + "date": "06-05-2022" + }, + { + "name": "Nationale Feestdag", + "date": "07-21-2022" + }, + { + "name": "OLV Hemelvaart", + "date": "08-15-2022" + }, + { + "name": "Allerheiligen", + "date": "11-01-2022" + }, + { + "name": "Wapenstilstand", + "date": "11-11-2022" + }, + { + "name": "Kerstmis", + "date": "12-25-2022" + } +] \ No newline at end of file diff --git a/tests/.pest/snapshots/HolidaysTest/it_can_get_all_holidays_of_another_year_and_a_specific_country.snap b/tests/.pest/snapshots/HolidaysTest/it_can_get_all_holidays_of_another_year_and_a_specific_country.snap new file mode 100644 index 000000000..8afb9aa5e --- /dev/null +++ b/tests/.pest/snapshots/HolidaysTest/it_can_get_all_holidays_of_another_year_and_a_specific_country.snap @@ -0,0 +1,42 @@ +[ + { + "name": "Nieuwjaar", + "date": "01-01-2024" + }, + { + "name": "Paasmaandag", + "date": "03-31-2024" + }, + { + "name": "Dag van de Arbeid", + "date": "05-01-2024" + }, + { + "name": "OH Hemelvaart", + "date": "05-08-2024" + }, + { + "name": "Pinkstermaandag", + "date": "05-19-2024" + }, + { + "name": "Nationale Feestdag", + "date": "07-21-2024" + }, + { + "name": "OLV Hemelvaart", + "date": "08-15-2024" + }, + { + "name": "Allerheiligen", + "date": "11-01-2024" + }, + { + "name": "Wapenstilstand", + "date": "11-11-2024" + }, + { + "name": "Kerstmis", + "date": "12-25-2024" + } +] \ No newline at end of file diff --git a/tests/.pest/snapshots/HolidaysTest/it_can_get_all_holidays_of_the_current_year.snap b/tests/.pest/snapshots/HolidaysTest/it_can_get_all_holidays_of_the_current_year.snap index e8712c415..8afb9aa5e 100644 --- a/tests/.pest/snapshots/HolidaysTest/it_can_get_all_holidays_of_the_current_year.snap +++ b/tests/.pest/snapshots/HolidaysTest/it_can_get_all_holidays_of_the_current_year.snap @@ -3,10 +3,22 @@ "name": "Nieuwjaar", "date": "01-01-2024" }, + { + "name": "Paasmaandag", + "date": "03-31-2024" + }, { "name": "Dag van de Arbeid", "date": "05-01-2024" }, + { + "name": "OH Hemelvaart", + "date": "05-08-2024" + }, + { + "name": "Pinkstermaandag", + "date": "05-19-2024" + }, { "name": "Nationale Feestdag", "date": "07-21-2024" @@ -26,17 +38,5 @@ { "name": "Kerstmis", "date": "12-25-2024" - }, - { - "name": "Paasmaandag", - "date": "03-31-2024" - }, - { - "name": "OH Hemelvaart", - "date": "05-08-2024" - }, - { - "name": "Pinkstermaandag", - "date": "05-19-2024" } ] \ No newline at end of file diff --git a/tests/HolidaysTest.php b/tests/HolidaysTest.php index 72ed8da70..e3e7ae29f 100644 --- a/tests/HolidaysTest.php +++ b/tests/HolidaysTest.php @@ -27,8 +27,8 @@ }); it('cannot get all holidays of an unknown country code', function () { - Holidays::new()->country('unknown')->get(); -})->throws(HolidaysException::class, 'Please provide a country code.'); + dd(Holidays::new()->country('unknown')->get()); +})->throws(HolidaysException::class, 'Country code `unknown` is not supported'); it('cannot get holidays for years before 1970', function () { Holidays::new()->year(1969)->get();