From 4de040f75e624397e5a3f6aa4caddaa15545bccc Mon Sep 17 00:00:00 2001 From: Niels Vanpachtenbeke <10651054+Nielsvanpach@users.noreply.github.com> Date: Thu, 25 Jan 2024 09:54:30 +0100 Subject: [PATCH 1/8] remove all timezones from tests country holidays should be properly calculated in every timezone --- tests/Countries/AndorraTest.php | 2 +- tests/Countries/AustraliaTest.php | 24 +++++++++++------------ tests/Countries/AustriaTest.php | 2 +- tests/Countries/BangladeshTest.php | 2 +- tests/Countries/BelarusTest.php | 8 ++++---- tests/Countries/BelgiumTest.php | 2 +- tests/Countries/BoliviaTest.php | 2 +- tests/Countries/BrazilTest.php | 2 +- tests/Countries/CanadaTest.php | 2 +- tests/Countries/ColombiaTest.php | 2 +- tests/Countries/CroatiaTest.php | 2 +- tests/Countries/CzechiaTest.php | 2 +- tests/Countries/DenmarkTest.php | 2 +- tests/Countries/DominicanRepublicTest.php | 2 +- tests/Countries/ElSalvadorTest.php | 2 +- tests/Countries/EstoniaTest.php | 2 +- tests/Countries/FinlandTest.php | 4 ++-- tests/Countries/FranceTest.php | 6 +++--- tests/Countries/GermanyTest.php | 10 +++++----- tests/Countries/GreeceTest.php | 2 +- tests/Countries/GuatemalaTest.php | 2 +- tests/Countries/HaitiTest.php | 2 +- tests/Countries/HungaryTest.php | 2 +- tests/Countries/IrelandTest.php | 2 +- tests/Countries/ItalyTest.php | 2 +- tests/Countries/JapanTest.php | 2 +- tests/Countries/KosovoTest.php | 2 +- tests/Countries/LatviaTest.php | 2 +- tests/Countries/LiechtensteinTest.php | 2 +- tests/Countries/LithuaniaTest.php | 2 +- tests/Countries/LuxembourgTest.php | 2 +- tests/Countries/MalawiTest.php | 2 +- tests/Countries/MexicoTest.php | 2 +- tests/Countries/NetherlandsTest.php | 2 +- tests/Countries/NicaraguaTest.php | 2 +- tests/Countries/NorthMacedoniaTest.php | 2 +- tests/Countries/NorwayTest.php | 2 +- tests/Countries/PanamaTest.php | 2 +- tests/Countries/PeruTest.php | 2 +- tests/Countries/PhilippinesTest.php | 2 +- tests/Countries/PolandTest.php | 2 +- tests/Countries/PortugalTest.php | 2 +- tests/Countries/RomaniaTest.php | 2 +- tests/Countries/SerbiaTest.php | 2 +- tests/Countries/SlovakiaTest.php | 2 +- tests/Countries/SouthAfricaTest.php | 2 +- tests/Countries/TurkeyTest.php | 2 +- tests/Countries/TurkmenistanTest.php | 2 +- tests/Countries/UgandaTest.php | 2 +- tests/Countries/UkraineTest.php | 2 +- tests/Countries/UnitedStatesTest.php | 4 ++-- tests/Countries/VenezuelaTest.php | 2 +- tests/Countries/ZambiaTest.php | 2 +- 53 files changed, 75 insertions(+), 75 deletions(-) diff --git a/tests/Countries/AndorraTest.php b/tests/Countries/AndorraTest.php index 43f1c49cc..184dad385 100644 --- a/tests/Countries/AndorraTest.php +++ b/tests/Countries/AndorraTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate andorra holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'ad')->get(); diff --git a/tests/Countries/AustraliaTest.php b/tests/Countries/AustraliaTest.php index e274579df..be239874d 100644 --- a/tests/Countries/AustraliaTest.php +++ b/tests/Countries/AustraliaTest.php @@ -7,7 +7,7 @@ use Spatie\Holidays\Holidays; it('can calculate australian holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-22', 'Australia/Melbourne'); + CarbonImmutable::setTestNow('2024-01-22'); $holidays = Holidays::for(country: 'au')->get(); @@ -19,7 +19,7 @@ }); it('can calculate australian holidays for a specific year', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-22', 'Australia/Melbourne'); + CarbonImmutable::setTestNow('2024-01-22'); $holidays = Holidays::for(country: 'au', year: 2025)->get(); @@ -31,7 +31,7 @@ }); it('can calculate regional australian holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-22', 'Australia/Melbourne'); + CarbonImmutable::setTestNow('2024-01-22'); $holidays = Holidays::for(Australia::make('vic'))->get(); @@ -43,7 +43,7 @@ }); it('can calculate the day before afl grand final', function () { - CarbonImmutable::setTestNowAndTimezone('2021-01-22', 'Australia/Melbourne'); + CarbonImmutable::setTestNow('2021-01-22'); $holidays = Holidays::for(Australia::make('vic'))->get(); @@ -52,7 +52,7 @@ }); it('can calculate the day before afl grand final during lockdown', function () { - CarbonImmutable::setTestNowAndTimezone('2020-01-22', 'Australia/Melbourne'); + CarbonImmutable::setTestNow('2020-01-22'); $holidays = Holidays::for(Australia::make('vic'))->get(); @@ -61,7 +61,7 @@ }); it('does not return the day before afl grand final before 2015', function () { - CarbonImmutable::setTestNowAndTimezone('2014-01-22', 'Australia/Melbourne'); + CarbonImmutable::setTestNow('2014-01-22'); $holidays = Holidays::for(Australia::make('vic'))->get(); @@ -70,7 +70,7 @@ }); it("returns queen's birthday before her death", function () { - CarbonImmutable::setTestNowAndTimezone('2021-01-22', 'Australia/Perth'); + CarbonImmutable::setTestNow('2021-01-22', 'Australia/Perth'); $holidays = Holidays::for(Australia::make('wa'))->get(); @@ -82,7 +82,7 @@ }); it("returns king's birthday after her death", function () { - CarbonImmutable::setTestNowAndTimezone('2022-01-22', 'Australia/Perth'); + CarbonImmutable::setTestNow('2022-01-22', 'Australia/Perth'); $holidays = Holidays::for(Australia::make('wa'))->get(); @@ -94,7 +94,7 @@ }); it('can calculate Adelaide Cup Day before 2006', function () { - CarbonImmutable::setTestNowAndTimezone('2005-01-22', 'Australia/Adelaide'); + CarbonImmutable::setTestNow('2005-01-22', 'Australia/Adelaide'); $holidays = Holidays::for(Australia::make('sa'))->get(); @@ -103,7 +103,7 @@ }); it('can calculate Adelaide Cup Day after 2006', function () { - CarbonImmutable::setTestNowAndTimezone('2007-01-22', 'Australia/Adelaide'); + CarbonImmutable::setTestNow('2007-01-22', 'Australia/Adelaide'); $holidays = Holidays::for(Australia::make('sa'))->get(); @@ -112,7 +112,7 @@ }); it('can calculate Reconciliation Day on 27 May', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-22', 'Australia/Canberra'); + CarbonImmutable::setTestNow('2024-01-22', 'Australia/Canberra'); $holidays = Holidays::for(Australia::make('act'))->get(); @@ -121,7 +121,7 @@ }); it('can calculate Reconciliation Day after 27 May', function () { - CarbonImmutable::setTestNowAndTimezone('2025-01-22', 'Australia/Canberra'); + CarbonImmutable::setTestNow('2025-01-22', 'Australia/Canberra'); $holidays = Holidays::for(Australia::make('act'))->get(); diff --git a/tests/Countries/AustriaTest.php b/tests/Countries/AustriaTest.php index 9018307f2..2e196c8ce 100644 --- a/tests/Countries/AustriaTest.php +++ b/tests/Countries/AustriaTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate austrian holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'at')->get(); diff --git a/tests/Countries/BangladeshTest.php b/tests/Countries/BangladeshTest.php index b5b0f0b59..d978a795d 100644 --- a/tests/Countries/BangladeshTest.php +++ b/tests/Countries/BangladeshTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate bangladesh holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'bd')->get(); diff --git a/tests/Countries/BelarusTest.php b/tests/Countries/BelarusTest.php index 5fc33f7e7..2f8d1be47 100644 --- a/tests/Countries/BelarusTest.php +++ b/tests/Countries/BelarusTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate belarus holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'by')->get(); @@ -18,7 +18,7 @@ }); it('can calculate belarus holidays in English', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'by', locale: 'en')->get(); @@ -30,7 +30,7 @@ }); it('can calculate belarus holidays in Belarus Lacinka', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'by', locale: 'be-latn')->get(); @@ -42,7 +42,7 @@ }); it('can calculate belarus holidays in Russian', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'by', locale: 'ru')->get(); diff --git a/tests/Countries/BelgiumTest.php b/tests/Countries/BelgiumTest.php index 822834377..173922950 100644 --- a/tests/Countries/BelgiumTest.php +++ b/tests/Countries/BelgiumTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate belgian holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'be')->get(); diff --git a/tests/Countries/BoliviaTest.php b/tests/Countries/BoliviaTest.php index e1305657f..2c50b0130 100644 --- a/tests/Countries/BoliviaTest.php +++ b/tests/Countries/BoliviaTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate bolivian holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'bo')->get(); diff --git a/tests/Countries/BrazilTest.php b/tests/Countries/BrazilTest.php index 91be74d40..39668d09c 100644 --- a/tests/Countries/BrazilTest.php +++ b/tests/Countries/BrazilTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate brazil holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'br')->get(); diff --git a/tests/Countries/CanadaTest.php b/tests/Countries/CanadaTest.php index 0619c4ecc..8d4e8ca23 100644 --- a/tests/Countries/CanadaTest.php +++ b/tests/Countries/CanadaTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate canadian holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'ca')->get(); diff --git a/tests/Countries/ColombiaTest.php b/tests/Countries/ColombiaTest.php index 623ffd94b..7a97c0542 100644 --- a/tests/Countries/ColombiaTest.php +++ b/tests/Countries/ColombiaTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate colombian holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'co')->get(); diff --git a/tests/Countries/CroatiaTest.php b/tests/Countries/CroatiaTest.php index a78f5258a..e394ccba5 100644 --- a/tests/Countries/CroatiaTest.php +++ b/tests/Countries/CroatiaTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate croatian holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'hr')->get(); diff --git a/tests/Countries/CzechiaTest.php b/tests/Countries/CzechiaTest.php index 5b9f09bb3..b6b027f04 100644 --- a/tests/Countries/CzechiaTest.php +++ b/tests/Countries/CzechiaTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate czech holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'cz')->get(); diff --git a/tests/Countries/DenmarkTest.php b/tests/Countries/DenmarkTest.php index dc01757ce..64034ba09 100644 --- a/tests/Countries/DenmarkTest.php +++ b/tests/Countries/DenmarkTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate danish holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'da')->get(); diff --git a/tests/Countries/DominicanRepublicTest.php b/tests/Countries/DominicanRepublicTest.php index 954e2a589..166348751 100644 --- a/tests/Countries/DominicanRepublicTest.php +++ b/tests/Countries/DominicanRepublicTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate dominican republic holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'do')->get(); diff --git a/tests/Countries/ElSalvadorTest.php b/tests/Countries/ElSalvadorTest.php index 892a8f791..d6260641c 100644 --- a/tests/Countries/ElSalvadorTest.php +++ b/tests/Countries/ElSalvadorTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate el salvador holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'sv')->get(); diff --git a/tests/Countries/EstoniaTest.php b/tests/Countries/EstoniaTest.php index c7ee1aa0b..5f1c0ee79 100644 --- a/tests/Countries/EstoniaTest.php +++ b/tests/Countries/EstoniaTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate estonian holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01', 'Europe/Tallinn'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'ee')->get(); diff --git a/tests/Countries/FinlandTest.php b/tests/Countries/FinlandTest.php index 565dc1623..ac347ba0e 100644 --- a/tests/Countries/FinlandTest.php +++ b/tests/Countries/FinlandTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate finnish holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'fi')->get(); @@ -19,7 +19,7 @@ }); it('can get finnish holidays in swedish', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'fi', locale: 'sv')->get(); diff --git a/tests/Countries/FranceTest.php b/tests/Countries/FranceTest.php index 358f8b1c0..300881b1e 100644 --- a/tests/Countries/FranceTest.php +++ b/tests/Countries/FranceTest.php @@ -7,7 +7,7 @@ use Spatie\Holidays\Holidays; it('can calculate french holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'fr')->get(); @@ -19,7 +19,7 @@ }); it('can calculate french easter based region holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(France::make('FR-57'))->get(); @@ -31,7 +31,7 @@ }); it('can calculate french date based regional holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(France::make('FR-BL'))->get(); diff --git a/tests/Countries/GermanyTest.php b/tests/Countries/GermanyTest.php index 3cb388e5b..b6a4f710f 100644 --- a/tests/Countries/GermanyTest.php +++ b/tests/Countries/GermanyTest.php @@ -7,7 +7,7 @@ use Spatie\Holidays\Holidays; it('can calculate german holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'de')->get(); @@ -20,7 +20,7 @@ }); it('can calculate german historical reformationstag in year 2017', function () { - CarbonImmutable::setTestNowAndTimezone('2017-01-01'); + CarbonImmutable::setTestNow('2017-01-01'); $holiday = Holidays::for('de')->isHoliday('2017-10-31'); @@ -28,7 +28,7 @@ }); it('can calculate german historical reformationstag in year 2018 is not a holiday', function () { - CarbonImmutable::setTestNowAndTimezone('2018-01-01'); + CarbonImmutable::setTestNow('2018-01-01'); $holiday = Holidays::for('de')->isHoliday('2018-10-31'); @@ -37,7 +37,7 @@ }); it('can calculate german buß- und bettag in year 1990', function () { - CarbonImmutable::setTestNowAndTimezone('1990-01-01'); + CarbonImmutable::setTestNow('1990-01-01'); $holiday = Holidays::for('de')->isHoliday('1990-10-03'); @@ -49,7 +49,7 @@ The total numbers are referenced in the wikipedia article. */ it('can get german holidays for other regions', function (string $region, int $totalHolidays) { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(Germany::make('DE-'.$region))->get(); expect($holidays) diff --git a/tests/Countries/GreeceTest.php b/tests/Countries/GreeceTest.php index 26805abbe..924065235 100644 --- a/tests/Countries/GreeceTest.php +++ b/tests/Countries/GreeceTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate hellenic holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'el')->get(); diff --git a/tests/Countries/GuatemalaTest.php b/tests/Countries/GuatemalaTest.php index 106ce7d4d..572dfbced 100644 --- a/tests/Countries/GuatemalaTest.php +++ b/tests/Countries/GuatemalaTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate guatemalan holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'gt')->get(); diff --git a/tests/Countries/HaitiTest.php b/tests/Countries/HaitiTest.php index 9e5632765..8a31192ea 100644 --- a/tests/Countries/HaitiTest.php +++ b/tests/Countries/HaitiTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate haiti holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'ht')->get(); diff --git a/tests/Countries/HungaryTest.php b/tests/Countries/HungaryTest.php index f1c20ab25..4df502bb0 100644 --- a/tests/Countries/HungaryTest.php +++ b/tests/Countries/HungaryTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate hungarian holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'hu')->get(); diff --git a/tests/Countries/IrelandTest.php b/tests/Countries/IrelandTest.php index 6ed63548f..1b3ff2c31 100644 --- a/tests/Countries/IrelandTest.php +++ b/tests/Countries/IrelandTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate irish holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'ie')->get(); diff --git a/tests/Countries/ItalyTest.php b/tests/Countries/ItalyTest.php index bd42933b6..55af7f42d 100644 --- a/tests/Countries/ItalyTest.php +++ b/tests/Countries/ItalyTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate italian holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'it')->get(); diff --git a/tests/Countries/JapanTest.php b/tests/Countries/JapanTest.php index 3a948815e..3404f3a87 100644 --- a/tests/Countries/JapanTest.php +++ b/tests/Countries/JapanTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate japanese holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'jp')->get(); diff --git a/tests/Countries/KosovoTest.php b/tests/Countries/KosovoTest.php index 2621722ff..313bd3c0e 100644 --- a/tests/Countries/KosovoTest.php +++ b/tests/Countries/KosovoTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate kosovo holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'xk')->get(); diff --git a/tests/Countries/LatviaTest.php b/tests/Countries/LatviaTest.php index bce7acb68..1995326af 100644 --- a/tests/Countries/LatviaTest.php +++ b/tests/Countries/LatviaTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate latvian holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01', 'Europe/Riga'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'lv')->get(); diff --git a/tests/Countries/LiechtensteinTest.php b/tests/Countries/LiechtensteinTest.php index 00b62a5c6..3d385c0c3 100644 --- a/tests/Countries/LiechtensteinTest.php +++ b/tests/Countries/LiechtensteinTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate liechtenstein holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'li')->get(); diff --git a/tests/Countries/LithuaniaTest.php b/tests/Countries/LithuaniaTest.php index 310f58f5b..91fbd0c1b 100644 --- a/tests/Countries/LithuaniaTest.php +++ b/tests/Countries/LithuaniaTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate lithuanian holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01', 'Europe/Vilnius'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'lt')->get(); diff --git a/tests/Countries/LuxembourgTest.php b/tests/Countries/LuxembourgTest.php index 48c69782c..13b500dc0 100644 --- a/tests/Countries/LuxembourgTest.php +++ b/tests/Countries/LuxembourgTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate luxembourgish holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'lu')->get(); diff --git a/tests/Countries/MalawiTest.php b/tests/Countries/MalawiTest.php index bc2710322..0d30d5ad8 100644 --- a/tests/Countries/MalawiTest.php +++ b/tests/Countries/MalawiTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate malawi holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'mw')->get(); diff --git a/tests/Countries/MexicoTest.php b/tests/Countries/MexicoTest.php index dfd62a71e..c6be2b64e 100644 --- a/tests/Countries/MexicoTest.php +++ b/tests/Countries/MexicoTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate mexican holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'mx')->get(); diff --git a/tests/Countries/NetherlandsTest.php b/tests/Countries/NetherlandsTest.php index 993201976..b743adae2 100644 --- a/tests/Countries/NetherlandsTest.php +++ b/tests/Countries/NetherlandsTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate dutch holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'nl')->get(); diff --git a/tests/Countries/NicaraguaTest.php b/tests/Countries/NicaraguaTest.php index 840a0609a..d079f1cfd 100644 --- a/tests/Countries/NicaraguaTest.php +++ b/tests/Countries/NicaraguaTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate nicaragua holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'ni')->get(); diff --git a/tests/Countries/NorthMacedoniaTest.php b/tests/Countries/NorthMacedoniaTest.php index b68507ff4..5021d229e 100644 --- a/tests/Countries/NorthMacedoniaTest.php +++ b/tests/Countries/NorthMacedoniaTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate macedonian holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'mk')->get(); diff --git a/tests/Countries/NorwayTest.php b/tests/Countries/NorwayTest.php index b9a342763..aba873f40 100644 --- a/tests/Countries/NorwayTest.php +++ b/tests/Countries/NorwayTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate norwegian holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'no')->get(); diff --git a/tests/Countries/PanamaTest.php b/tests/Countries/PanamaTest.php index f848a26f2..215cf15ff 100644 --- a/tests/Countries/PanamaTest.php +++ b/tests/Countries/PanamaTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate panama holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'pa')->get(); diff --git a/tests/Countries/PeruTest.php b/tests/Countries/PeruTest.php index aff6670eb..127694482 100644 --- a/tests/Countries/PeruTest.php +++ b/tests/Countries/PeruTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate peru holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'pe')->get(); diff --git a/tests/Countries/PhilippinesTest.php b/tests/Countries/PhilippinesTest.php index 4fd997173..22526a812 100644 --- a/tests/Countries/PhilippinesTest.php +++ b/tests/Countries/PhilippinesTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate philippine holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'ph')->get(); diff --git a/tests/Countries/PolandTest.php b/tests/Countries/PolandTest.php index 25a75ebc7..ed8e5a333 100644 --- a/tests/Countries/PolandTest.php +++ b/tests/Countries/PolandTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate polish holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'pl')->get(); diff --git a/tests/Countries/PortugalTest.php b/tests/Countries/PortugalTest.php index 7c2ed381f..db49ca87b 100644 --- a/tests/Countries/PortugalTest.php +++ b/tests/Countries/PortugalTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate portuguese holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'pt')->get(); diff --git a/tests/Countries/RomaniaTest.php b/tests/Countries/RomaniaTest.php index 80c177a98..95584b37d 100644 --- a/tests/Countries/RomaniaTest.php +++ b/tests/Countries/RomaniaTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate romanian holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'ro')->get(); diff --git a/tests/Countries/SerbiaTest.php b/tests/Countries/SerbiaTest.php index 1a44fbb44..4f8f640ef 100644 --- a/tests/Countries/SerbiaTest.php +++ b/tests/Countries/SerbiaTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate serbian holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'sr')->get(); diff --git a/tests/Countries/SlovakiaTest.php b/tests/Countries/SlovakiaTest.php index cb08ebd5a..65ab74a03 100644 --- a/tests/Countries/SlovakiaTest.php +++ b/tests/Countries/SlovakiaTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate slovak holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'sk')->get(); diff --git a/tests/Countries/SouthAfricaTest.php b/tests/Countries/SouthAfricaTest.php index fe98169c5..86454c506 100644 --- a/tests/Countries/SouthAfricaTest.php +++ b/tests/Countries/SouthAfricaTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate south africa holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'za')->get(); diff --git a/tests/Countries/TurkeyTest.php b/tests/Countries/TurkeyTest.php index 4deb524c9..129d4c4b6 100644 --- a/tests/Countries/TurkeyTest.php +++ b/tests/Countries/TurkeyTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate turkey holidays', function ($year) { - CarbonImmutable::setTestNowAndTimezone($year.'-01-01'); + CarbonImmutable::setTestNow($year.'-01-01'); $holidays = Holidays::for(country: 'tr')->get(); diff --git a/tests/Countries/TurkmenistanTest.php b/tests/Countries/TurkmenistanTest.php index 7f29d6635..c551f5720 100644 --- a/tests/Countries/TurkmenistanTest.php +++ b/tests/Countries/TurkmenistanTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate turkmen holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'tm')->get(); diff --git a/tests/Countries/UgandaTest.php b/tests/Countries/UgandaTest.php index 82ab1f7f6..93dd2ddcf 100644 --- a/tests/Countries/UgandaTest.php +++ b/tests/Countries/UgandaTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate ugandan holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'ug')->get(); diff --git a/tests/Countries/UkraineTest.php b/tests/Countries/UkraineTest.php index 04e9b3115..cabb8dd1c 100644 --- a/tests/Countries/UkraineTest.php +++ b/tests/Countries/UkraineTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate ukrainian holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'ua')->get(); diff --git a/tests/Countries/UnitedStatesTest.php b/tests/Countries/UnitedStatesTest.php index bdf277d2f..32ebff2bf 100644 --- a/tests/Countries/UnitedStatesTest.php +++ b/tests/Countries/UnitedStatesTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate united states holidays after 2021', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'us')->get(); @@ -19,7 +19,7 @@ }); it('can calculate united states holidays before 2021', function () { - CarbonImmutable::setTestNowAndTimezone('2020-01-01'); + CarbonImmutable::setTestNow('2020-01-01'); $holidays = Holidays::for(country: 'us')->get(); diff --git a/tests/Countries/VenezuelaTest.php b/tests/Countries/VenezuelaTest.php index 5b2cf5ea2..77c7682d1 100644 --- a/tests/Countries/VenezuelaTest.php +++ b/tests/Countries/VenezuelaTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate venezuelan holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 've')->get(); diff --git a/tests/Countries/ZambiaTest.php b/tests/Countries/ZambiaTest.php index 83e732256..c67b3982d 100644 --- a/tests/Countries/ZambiaTest.php +++ b/tests/Countries/ZambiaTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate zambian holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'zm')->get(); From 06c5f38d480cd703e9567cbcb80a3833429526e4 Mon Sep 17 00:00:00 2001 From: Niels Vanpachtenbeke <10651054+Nielsvanpach@users.noreply.github.com> Date: Thu, 25 Jan 2024 09:54:44 +0100 Subject: [PATCH 2/8] try a different orthodox easter calculation --- src/Countries/Country.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Countries/Country.php b/src/Countries/Country.php index b6cfab347..3294bc536 100644 --- a/src/Countries/Country.php +++ b/src/Countries/Country.php @@ -56,6 +56,19 @@ protected function easter(int $year): CarbonImmutable protected function orthodoxEaster(int $year): CarbonImmutable { + $a = $year % 4; + $b = $year % 7; + $c = $year % 19; + $d = (19 * $c + 15) % 30; + $e = (2 * $a + 4 * $b - $d + 34) % 7; + $month = floor(($d + $e + 114) / 31); + $day = (($d + $e + 114) % 31) + 1; + + $easterDate = mktime(0, 0, 0, $month, $day + 13, $year); + + return CarbonImmutable::create($year, $month, $day); + + $timestamp = easter_date($year, CAL_EASTER_ALWAYS_JULIAN); $daysDifference = (int) ($year / 100) - (int) ($year / 400) - 2; From 799196ff730b37f9b61ecc74f2ba4081df36fcfa Mon Sep 17 00:00:00 2001 From: Niels Vanpachtenbeke <10651054+Nielsvanpach@users.noreply.github.com> Date: Thu, 25 Jan 2024 11:13:27 +0100 Subject: [PATCH 3/8] fix calculating orthodox easter --- src/Countries/Country.php | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/Countries/Country.php b/src/Countries/Country.php index 3294bc536..9e9a85533 100644 --- a/src/Countries/Country.php +++ b/src/Countries/Country.php @@ -56,23 +56,13 @@ protected function easter(int $year): CarbonImmutable protected function orthodoxEaster(int $year): CarbonImmutable { - $a = $year % 4; - $b = $year % 7; - $c = $year % 19; - $d = (19 * $c + 15) % 30; - $e = (2 * $a + 4 * $b - $d + 34) % 7; - $month = floor(($d + $e + 114) / 31); - $day = (($d + $e + 114) % 31) + 1; - - $easterDate = mktime(0, 0, 0, $month, $day + 13, $year); - - return CarbonImmutable::create($year, $month, $day); - - - $timestamp = easter_date($year, CAL_EASTER_ALWAYS_JULIAN); - $daysDifference = (int) ($year / 100) - (int) ($year / 400) - 2; + // Paschal full moon date + // Not covered edge case: + // when the full moon is on a 3 April, Easter is the next Sunday + $easter = CarbonImmutable::createFromFormat('Y-m-d', "{$year}-04-03") + ->startOfDay(); - return CarbonImmutable::createFromTimestamp(strtotime("+$daysDifference days", $timestamp)); + return $easter->addDays(easter_days($year, CAL_EASTER_ALWAYS_JULIAN)); } public static function find(string $countryCode): ?Country From 9b0988e48754925c78597b5e03e76057b57f935c Mon Sep 17 00:00:00 2001 From: Nielsvanpach Date: Thu, 25 Jan 2024 10:13:54 +0000 Subject: [PATCH 4/8] Fix styling --- src/Countries/Australia.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Countries/Australia.php b/src/Countries/Australia.php index 87dcb6a6f..0b43bae4e 100644 --- a/src/Countries/Australia.php +++ b/src/Countries/Australia.php @@ -36,7 +36,7 @@ protected function variableHolidays(int $year): array 'Good Friday' => $easter->subDays(2), 'Easter Monday' => $easter->addDay(), // https://en.wikipedia.org/wiki/Public_holidays_in_Australia - ...array_filter(match($this->region) { + ...array_filter(match ($this->region) { 'act' => [ 'Canberra Day' => CarbonImmutable::parse("second monday of march {$year}"), 'Easter Saturday' => $easter->subDay(), From eb9833e7f6faf9ca91eaed6a97371a87e282cfad Mon Sep 17 00:00:00 2001 From: Niels Vanpachtenbeke <10651054+Nielsvanpach@users.noreply.github.com> Date: Thu, 25 Jan 2024 11:15:15 +0100 Subject: [PATCH 5/8] move to baseline --- phpstan-baseline.neon | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 31f8d0e58..ec51df55b 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -12,7 +12,7 @@ parameters: - message: "#^Cannot call method startOfDay\\(\\) on Carbon\\\\CarbonImmutable\\|false\\.$#" - count: 1 + count: 2 path: src/Countries/Country.php - @@ -20,11 +20,6 @@ parameters: count: 1 path: src/Countries/Country.php - - - message: "#^Parameter \\#1 \\$timestamp of static method Carbon\\\\CarbonImmutable\\:\\:createFromTimestamp\\(\\) expects float\\|int\\|string, int\\|false given\\.$#" - count: 1 - path: src/Countries/Country.php - - message: "#^Parameter \\#2 \\$callback of function uasort expects callable\\(bool\\|Carbon\\\\CarbonImmutable, bool\\|Carbon\\\\CarbonImmutable\\)\\: int, Closure\\(Carbon\\\\CarbonImmutable, Carbon\\\\CarbonImmutable\\)\\: int\\<\\-1, 1\\> given\\.$#" count: 1 From 03fe5c205528416b95b0e3b0a45a80d6b1090275 Mon Sep 17 00:00:00 2001 From: Niels Vanpachtenbeke <10651054+Nielsvanpach@users.noreply.github.com> Date: Thu, 25 Jan 2024 11:46:41 +0100 Subject: [PATCH 6/8] add a test case to make sure orthodox easter is calculated correctly --- tests/CountryTest.php | 51 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 tests/CountryTest.php diff --git a/tests/CountryTest.php b/tests/CountryTest.php new file mode 100644 index 000000000..598698254 --- /dev/null +++ b/tests/CountryTest.php @@ -0,0 +1,51 @@ +setAccessible(true); + + $easter = $reflectionMethod->invoke($country, $year); + + expect($easter->format('Y-m-d'))->toBe($date); +})->with([ + [1997, "1997-04-27"], + [1998, "1998-04-19"], + [1999, "1999-04-11"], + [2000, "2000-04-30"], + [2001, "2001-04-15"], + [2002, "2002-05-05"], + [2003, "2003-04-27"], + [2004, "2004-04-11"], + [2005, "2005-05-01"], + [2006, "2006-04-23"], + [2007, "2007-04-08"], + [2008, "2008-04-27"], + [2009, "2009-04-19"], + [2010, "2010-04-04"], + [2011, "2011-04-24"], + [2012, "2012-04-15"], + [2013, "2013-05-05"], + [2014, "2014-04-20"], + [2015, "2015-04-12"], + [2016, "2016-05-01"], + [2017, "2017-04-16"], + [2018, "2018-04-08"], + [2019, "2019-04-28"], + [2020, "2020-04-19"], + [2021, "2021-05-02"], + [2022, "2022-04-24"], + [2023, "2023-04-16"], + [2024, "2024-05-05"], + [2025, "2025-04-20"], + [2026, "2026-04-12"], + [2027, "2027-05-02"], + [2028, "2028-04-16"], + [2029, "2029-04-08"], +]); From 76a87d7b3459193e920e48102ef7de0d42f75a7c Mon Sep 17 00:00:00 2001 From: Nielsvanpach Date: Thu, 25 Jan 2024 10:47:02 +0000 Subject: [PATCH 7/8] Fix styling --- tests/CountryTest.php | 66 +++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/tests/CountryTest.php b/tests/CountryTest.php index 598698254..513b7c419 100644 --- a/tests/CountryTest.php +++ b/tests/CountryTest.php @@ -15,37 +15,37 @@ expect($easter->format('Y-m-d'))->toBe($date); })->with([ - [1997, "1997-04-27"], - [1998, "1998-04-19"], - [1999, "1999-04-11"], - [2000, "2000-04-30"], - [2001, "2001-04-15"], - [2002, "2002-05-05"], - [2003, "2003-04-27"], - [2004, "2004-04-11"], - [2005, "2005-05-01"], - [2006, "2006-04-23"], - [2007, "2007-04-08"], - [2008, "2008-04-27"], - [2009, "2009-04-19"], - [2010, "2010-04-04"], - [2011, "2011-04-24"], - [2012, "2012-04-15"], - [2013, "2013-05-05"], - [2014, "2014-04-20"], - [2015, "2015-04-12"], - [2016, "2016-05-01"], - [2017, "2017-04-16"], - [2018, "2018-04-08"], - [2019, "2019-04-28"], - [2020, "2020-04-19"], - [2021, "2021-05-02"], - [2022, "2022-04-24"], - [2023, "2023-04-16"], - [2024, "2024-05-05"], - [2025, "2025-04-20"], - [2026, "2026-04-12"], - [2027, "2027-05-02"], - [2028, "2028-04-16"], - [2029, "2029-04-08"], + [1997, '1997-04-27'], + [1998, '1998-04-19'], + [1999, '1999-04-11'], + [2000, '2000-04-30'], + [2001, '2001-04-15'], + [2002, '2002-05-05'], + [2003, '2003-04-27'], + [2004, '2004-04-11'], + [2005, '2005-05-01'], + [2006, '2006-04-23'], + [2007, '2007-04-08'], + [2008, '2008-04-27'], + [2009, '2009-04-19'], + [2010, '2010-04-04'], + [2011, '2011-04-24'], + [2012, '2012-04-15'], + [2013, '2013-05-05'], + [2014, '2014-04-20'], + [2015, '2015-04-12'], + [2016, '2016-05-01'], + [2017, '2017-04-16'], + [2018, '2018-04-08'], + [2019, '2019-04-28'], + [2020, '2020-04-19'], + [2021, '2021-05-02'], + [2022, '2022-04-24'], + [2023, '2023-04-16'], + [2024, '2024-05-05'], + [2025, '2025-04-20'], + [2026, '2026-04-12'], + [2027, '2027-05-02'], + [2028, '2028-04-16'], + [2029, '2029-04-08'], ]); From 1fa7a39e20b2938ddd46b70f07b9eaf123a24740 Mon Sep 17 00:00:00 2001 From: Niels Vanpachtenbeke <10651054+Nielsvanpach@users.noreply.github.com> Date: Thu, 25 Jan 2024 11:50:10 +0100 Subject: [PATCH 8/8] use our invade package instead of Reflection --- composer.json | 1 + tests/CountryTest.php | 6 +----- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 9f8a2f7fb..8e0f585dc 100644 --- a/composer.json +++ b/composer.json @@ -29,6 +29,7 @@ "laravel/prompts": "^0.1.15", "pestphp/pest": "^2.31", "phpstan/phpstan": "^1.10.56", + "spatie/invade": "^2.0", "spatie/ray": "^1.40.1", "symfony/var-dumper": "^6.4" }, diff --git a/tests/CountryTest.php b/tests/CountryTest.php index 513b7c419..6699ab606 100644 --- a/tests/CountryTest.php +++ b/tests/CountryTest.php @@ -2,16 +2,12 @@ namespace Spatie\Holidays\Tests; -use ReflectionMethod; use Spatie\Holidays\Countries\Belgium; it('can calculate orthodox easter', function (int $year, string $date) { $country = Belgium::make(); - $reflectionMethod = new ReflectionMethod('Spatie\Holidays\Countries\Belgium', 'orthodoxEaster'); - $reflectionMethod->setAccessible(true); - - $easter = $reflectionMethod->invoke($country, $year); + $easter = invade($country)->orthodoxEaster($year); expect($easter->format('Y-m-d'))->toBe($date); })->with([