generated from spatie/package-skeleton-php
-
-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
56959a3
commit 7ad1f80
Showing
7 changed files
with
234 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace Spatie\Holidays\Countries; | ||
|
||
use Carbon\CarbonImmutable; | ||
|
||
class England extends Wales | ||
{ | ||
public function countryCode(): string | ||
{ | ||
return 'en'; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
tests/.pest/snapshots/Countries/EnglandTest/it_can_calculate_english_holidays.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[ | ||
{ | ||
"name": "New Year's Day", | ||
"date": "2024-01-01" | ||
}, | ||
{ | ||
"name": "Good Friday", | ||
"date": "2024-03-29" | ||
}, | ||
{ | ||
"name": "Easter Monday", | ||
"date": "2024-04-01" | ||
}, | ||
{ | ||
"name": "Early May bank holiday", | ||
"date": "2024-05-06" | ||
}, | ||
{ | ||
"name": "Spring bank holiday", | ||
"date": "2024-05-27" | ||
}, | ||
{ | ||
"name": "Summer bank holiday", | ||
"date": "2024-08-26" | ||
}, | ||
{ | ||
"name": "Christmas Day", | ||
"date": "2024-12-25" | ||
}, | ||
{ | ||
"name": "Boxing Day", | ||
"date": "2024-12-26" | ||
} | ||
] |
34 changes: 34 additions & 0 deletions
34
.../Countries/EnglandTest/it_can_calculate_english_holidays_if_christmas_is_on_a_friday.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[ | ||
{ | ||
"name": "New Year's Day", | ||
"date": "2020-01-01" | ||
}, | ||
{ | ||
"name": "Good Friday", | ||
"date": "2020-04-10" | ||
}, | ||
{ | ||
"name": "Easter Monday", | ||
"date": "2020-04-13" | ||
}, | ||
{ | ||
"name": "Early May bank holiday", | ||
"date": "2020-05-04" | ||
}, | ||
{ | ||
"name": "Spring bank holiday", | ||
"date": "2020-05-25" | ||
}, | ||
{ | ||
"name": "Summer bank holiday", | ||
"date": "2020-08-31" | ||
}, | ||
{ | ||
"name": "Christmas Day", | ||
"date": "2020-12-25" | ||
}, | ||
{ | ||
"name": "Boxing Day (substitute day)", | ||
"date": "2020-12-28" | ||
} | ||
] |
34 changes: 34 additions & 0 deletions
34
...ountries/EnglandTest/it_can_calculate_english_holidays_if_christmas_is_on_a_saturday.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[ | ||
{ | ||
"name": "New Year's Day", | ||
"date": "2021-01-01" | ||
}, | ||
{ | ||
"name": "Good Friday", | ||
"date": "2021-04-02" | ||
}, | ||
{ | ||
"name": "Easter Monday", | ||
"date": "2021-04-05" | ||
}, | ||
{ | ||
"name": "Early May bank holiday", | ||
"date": "2021-05-03" | ||
}, | ||
{ | ||
"name": "Spring bank holiday", | ||
"date": "2021-05-31" | ||
}, | ||
{ | ||
"name": "Summer bank holiday", | ||
"date": "2021-08-30" | ||
}, | ||
{ | ||
"name": "Christmas Day (substitute day)", | ||
"date": "2021-12-27" | ||
}, | ||
{ | ||
"name": "Boxing Day (substitute day)", | ||
"date": "2021-12-28" | ||
} | ||
] |
34 changes: 34 additions & 0 deletions
34
.../Countries/EnglandTest/it_can_calculate_english_holidays_if_christmas_is_on_a_sunday.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[ | ||
{ | ||
"name": "New Year's Day (substitute day)", | ||
"date": "2022-01-03" | ||
}, | ||
{ | ||
"name": "Good Friday", | ||
"date": "2022-04-15" | ||
}, | ||
{ | ||
"name": "Easter Monday", | ||
"date": "2022-04-18" | ||
}, | ||
{ | ||
"name": "Early May bank holiday", | ||
"date": "2022-05-02" | ||
}, | ||
{ | ||
"name": "Spring bank holiday", | ||
"date": "2022-05-30" | ||
}, | ||
{ | ||
"name": "Summer bank holiday", | ||
"date": "2022-08-29" | ||
}, | ||
{ | ||
"name": "Boxing Day", | ||
"date": "2022-12-26" | ||
}, | ||
{ | ||
"name": "Christmas Day (substitute day)", | ||
"date": "2022-12-27" | ||
} | ||
] |
34 changes: 34 additions & 0 deletions
34
...ountries/EnglandTest/it_returns_a_substitute_day_if_new_years_day_falls_on_a_weekend.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[ | ||
{ | ||
"name": "New Year's Day (substitute day)", | ||
"date": "2033-01-03" | ||
}, | ||
{ | ||
"name": "Good Friday", | ||
"date": "2033-04-15" | ||
}, | ||
{ | ||
"name": "Easter Monday", | ||
"date": "2033-04-18" | ||
}, | ||
{ | ||
"name": "Early May bank holiday", | ||
"date": "2033-05-02" | ||
}, | ||
{ | ||
"name": "Spring bank holiday", | ||
"date": "2033-05-30" | ||
}, | ||
{ | ||
"name": "Summer bank holiday", | ||
"date": "2033-08-29" | ||
}, | ||
{ | ||
"name": "Boxing Day", | ||
"date": "2033-12-26" | ||
}, | ||
{ | ||
"name": "Christmas Day (substitute day)", | ||
"date": "2033-12-27" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
use Carbon\CarbonImmutable; | ||
use Spatie\Holidays\Holidays; | ||
|
||
it( 'can calculate english holidays', function () { | ||
CarbonImmutable::setTestNowAndTimezone('2024-01-01'); | ||
|
||
$holidays = Holidays::for(country: 'en')->get(); | ||
|
||
expect($holidays)->toBeArray()->not()->toBeEmpty() | ||
->and(formatDates($holidays))->toMatchSnapshot(); | ||
|
||
}); | ||
|
||
it('returns a substitute day if new years day falls on a weekend', function () { | ||
CarbonImmutable::setTestNowAndTimezone('2033-01-01'); | ||
|
||
$holidays = Holidays::for(country: 'en')->get(); | ||
|
||
expect($holidays)->toBeArray()->not()->toBeEmpty() | ||
->and(formatDates($holidays))->toMatchSnapshot(); | ||
}); | ||
|
||
|
||
it('can calculate english holidays if christmas is on a friday', function () { | ||
CarbonImmutable::setTestNowAndTimezone('2020-01-01'); | ||
|
||
$holidays = Holidays::for(country: 'en')->get(); | ||
|
||
expect($holidays)->toBeArray()->not()->toBeEmpty() | ||
->and(formatDates($holidays))->toMatchSnapshot(); | ||
}); | ||
|
||
it('can calculate english holidays if christmas is on a saturday', function () { | ||
CarbonImmutable::setTestNowAndTimezone('2021-01-01'); | ||
|
||
$holidays = Holidays::for(country: 'en')->get(); | ||
|
||
expect($holidays)->toBeArray()->not()->toBeEmpty() | ||
->and(formatDates($holidays))->toMatchSnapshot(); | ||
}); | ||
|
||
it('can calculate english holidays if christmas is on a sunday', function () { | ||
CarbonImmutable::setTestNowAndTimezone('2022-01-01'); | ||
|
||
$holidays = Holidays::for(country: 'en')->get(); | ||
|
||
expect($holidays)->toBeArray()->not()->toBeEmpty() | ||
->and(formatDates($holidays))->toMatchSnapshot(); | ||
}); |