Skip to content

Commit

Permalink
Add Tests
Browse files Browse the repository at this point in the history
Tests based on Welsh Tests given same Mondayisation
  • Loading branch information
jpgnz committed Feb 18, 2024
1 parent 4460038 commit 3e2692e
Show file tree
Hide file tree
Showing 8 changed files with 420 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/Countries/NewZealand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ protected function allHolidays(int $year): array

protected function observedHolidays(int $year): array

Check failure on line 26 in src/Countries/NewZealand.php

View workflow job for this annotation

GitHub Actions / phpstan

Method Spatie\Holidays\Countries\NewZealand::observedHolidays() return type has no value type specified in iterable type array.
{
//https://www.employment.govt.nz/leave-and-holidays/public-holidays/public-holidays-and-anniversary-dates/
$holidays = [
'New Year\'s Day' => '01-01',
'Day after New Year\'s Day' => '01-02',
Expand All @@ -33,7 +34,7 @@ protected function observedHolidays(int $year): array
'Christmas Day' => '12-25',
'Boxing Day' => '12-26',
];

//https://www.employment.govt.nz/leave-and-holidays/public-holidays/public-holidays-falling-on-a-weekend/
foreach ($holidays as $name => $date) {
$observedDay = match ($name) {
Expand Down Expand Up @@ -64,7 +65,7 @@ protected function variableHolidays(int $year): array
$sovereignMonday = CarbonImmutable::parse("first monday of june {$year}");

//Labour Day
$labourMonday = CarbonImmutable::parse("fourth monday of october {$year}");
$labourMonday = CarbonImmutable::parse("fourth monday of october {$year}");

return [
'Good Friday' => $goodFriday,
Expand Down Expand Up @@ -96,8 +97,8 @@ private function calculateMatariki(int $year): ?CarbonImmutable
{
//https://www.tepapa.govt.nz/discover-collections/read-watch-play/matariki-maori-new-year/dates-for-matariki-public-holiday
$matarikiDates = [
2022 => '2022-07-14',
2023 => '2023-06-24',
2022 => '2022-06-24',
2023 => '2023-07-14',
2024 => '2024-06-28',
2025 => '2025-06-20',
2026 => '2026-07-10',
Expand Down Expand Up @@ -129,8 +130,8 @@ private function calculateMatariki(int $year): ?CarbonImmutable
2052 => '2052-06-21',
];

return isset($matarikiDates[$year])
? CarbonImmutable::createFromFormat('Y-m-d', $matarikiDates[$year])->setTimezone('Pacific/Auckland')
return isset($matarikiDates[$year])
? CarbonImmutable::createFromFormat('Y-m-d', $matarikiDates[$year])->setTimezone('Pacific/Auckland')
: null; // Return null if year not defined
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[
{
"name": "New Year's Day",
"date": "2030-01-01"
},
{
"name": "Day after New Year's Day",
"date": "2030-01-02"
},
{
"name": "Waitangi Day",
"date": "2030-02-06"
},
{
"name": "Good Friday",
"date": "2030-04-19"
},
{
"name": "Easter Monday",
"date": "2030-04-22"
},
{
"name": "ANZAC Day",
"date": "2030-04-25"
},
{
"name": "King's Birthday",
"date": "2030-06-03"
},
{
"name": "Matariki",
"date": "2030-06-21"
},
{
"name": "Labour Day",
"date": "2030-10-28"
},
{
"name": "Christmas Day",
"date": "2030-12-25"
},
{
"name": "Boxing Day",
"date": "2030-12-26"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[
{
"name": "New Year's Day",
"date": "2024-01-01"
},
{
"name": "Day after New Year's Day",
"date": "2024-01-02"
},
{
"name": "Waitangi Day",
"date": "2024-02-06"
},
{
"name": "Good Friday",
"date": "2024-03-29"
},
{
"name": "Easter Monday",
"date": "2024-04-01"
},
{
"name": "ANZAC Day",
"date": "2024-04-25"
},
{
"name": "King's Birthday",
"date": "2024-06-03"
},
{
"name": "Matariki",
"date": "2024-06-28"
},
{
"name": "Labour Day",
"date": "2024-10-28"
},
{
"name": "Christmas Day",
"date": "2024-12-25"
},
{
"name": "Boxing Day",
"date": "2024-12-26"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[
{
"name": "New Year's Day (Mondayisation)",
"date": "2028-01-03"
},
{
"name": "Day after New Year's Day (Mondayisation)",
"date": "2028-01-04"
},
{
"name": "Waitangi Day (Mondayisation)",
"date": "2028-02-07"
},
{
"name": "Good Friday",
"date": "2028-04-14"
},
{
"name": "Easter Monday",
"date": "2028-04-17"
},
{
"name": "ANZAC Day",
"date": "2028-04-25"
},
{
"name": "King's Birthday",
"date": "2028-06-05"
},
{
"name": "Matariki",
"date": "2028-07-14"
},
{
"name": "Labour Day",
"date": "2028-10-23"
},
{
"name": "Christmas Day",
"date": "2028-12-25"
},
{
"name": "Boxing Day",
"date": "2028-12-26"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[
{
"name": "New Year's Day",
"date": "2027-01-01"
},
{
"name": "Day after New Year's Day (Mondayisation)",
"date": "2027-01-04"
},
{
"name": "Waitangi Day (Mondayisation)",
"date": "2027-02-08"
},
{
"name": "Good Friday",
"date": "2027-03-26"
},
{
"name": "Easter Monday",
"date": "2027-03-29"
},
{
"name": "ANZAC Day (Mondayisation)",
"date": "2027-04-26"
},
{
"name": "King's Birthday",
"date": "2027-06-07"
},
{
"name": "Matariki",
"date": "2027-06-25"
},
{
"name": "Labour Day",
"date": "2027-10-25"
},
{
"name": "Christmas Day (Mondayisation)",
"date": "2027-12-27"
},
{
"name": "Boxing Day (Mondayisation)",
"date": "2027-12-28"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[
{
"name": "New Year's Day (Mondayisation)",
"date": "2022-01-03"
},
{
"name": "Day after New Year's Day (Mondayisation)",
"date": "2022-01-04"
},
{
"name": "Waitangi Day (Mondayisation)",
"date": "2022-02-07"
},
{
"name": "Good Friday",
"date": "2022-04-15"
},
{
"name": "Easter Monday",
"date": "2022-04-18"
},
{
"name": "ANZAC Day",
"date": "2022-04-25"
},
{
"name": "Queen's Birthday",
"date": "2022-06-06"
},
{
"name": "Matariki",
"date": "2022-06-24"
},
{
"name": "Labour Day",
"date": "2022-10-24"
},
{
"name": "Boxing Day",
"date": "2022-12-26"
},
{
"name": "Christmas Day (Mondayisation)",
"date": "2022-12-27"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[
{
"name": "New Year's Day (Mondayisation)",
"date": "2033-01-03"
},
{
"name": "Day after New Year's Day (Mondayisation)",
"date": "2033-01-04"
},
{
"name": "Waitangi Day (Mondayisation)",
"date": "2033-02-07"
},
{
"name": "Good Friday",
"date": "2033-04-15"
},
{
"name": "Easter Monday",
"date": "2033-04-18"
},
{
"name": "ANZAC Day",
"date": "2033-04-25"
},
{
"name": "King's Birthday",
"date": "2033-06-06"
},
{
"name": "Matariki",
"date": "2033-06-24"
},
{
"name": "Labour Day",
"date": "2033-10-24"
},
{
"name": "Boxing Day",
"date": "2033-12-26"
},
{
"name": "Christmas Day (Mondayisation)",
"date": "2033-12-27"
}
]
Loading

0 comments on commit 3e2692e

Please sign in to comment.