From 07454e6e1e2b9b513ab58ce23468fb871a24c875 Mon Sep 17 00:00:00 2001 From: Ivan Mercedes <53806989+ivanmercedes@users.noreply.github.com> Date: Tue, 23 Jan 2024 08:42:24 -0400 Subject: [PATCH] Added Haiti holidays (#148) --- src/Countries/Haiti.php | 41 +++++++++++++++ .../it_can_calculate_haiti_holidays.snap | 50 +++++++++++++++++++ tests/Countries/HaitiTest.php | 18 +++++++ 3 files changed, 109 insertions(+) create mode 100644 src/Countries/Haiti.php create mode 100644 tests/.pest/snapshots/Countries/HaitiTest/it_can_calculate_haiti_holidays.snap create mode 100644 tests/Countries/HaitiTest.php diff --git a/src/Countries/Haiti.php b/src/Countries/Haiti.php new file mode 100644 index 000000000..f35c3aa29 --- /dev/null +++ b/src/Countries/Haiti.php @@ -0,0 +1,41 @@ + */ + protected function allHolidays(int $year): array + { + return array_merge([ + 'Nouvel an / Jour de l\'Indépendance' => '01-01', + 'Jour des Aieux' => '01-2', + 'Fête du Travail / Fête des Travailleurs' => '05-01', + 'Jour du Drapeau et de l\'Université' => '05-18', + 'L\'Assomption de Marie' => '08-15', + 'Anniversaire de la mort de Dessalines' => '10-17', + 'Toussaint' => '11-01', + 'Jour des Morts' => '11-02', + 'Vertières' => '11-18', + 'Noël' => '12-25', + ], $this->variableHolidays($year)); + } + + /** @return array */ + protected function variableHolidays(int $year): array + { + $easter = $this->easter($year); + + return [ + 'Carnaval/Mardi Gras' => $easter->subDays(47), + 'Vendredi saint' => $easter->subDays(2), + ]; + } +} diff --git a/tests/.pest/snapshots/Countries/HaitiTest/it_can_calculate_haiti_holidays.snap b/tests/.pest/snapshots/Countries/HaitiTest/it_can_calculate_haiti_holidays.snap new file mode 100644 index 000000000..0a09db87f --- /dev/null +++ b/tests/.pest/snapshots/Countries/HaitiTest/it_can_calculate_haiti_holidays.snap @@ -0,0 +1,50 @@ +[ + { + "name": "Nouvel an \/ Jour de l'Ind\u00e9pendance", + "date": "2024-01-01" + }, + { + "name": "Jour des Aieux", + "date": "2024-01-02" + }, + { + "name": "Carnaval\/Mardi Gras", + "date": "2024-02-13" + }, + { + "name": "Vendredi saint", + "date": "2024-03-29" + }, + { + "name": "F\u00eate du Travail \/ F\u00eate des Travailleurs", + "date": "2024-05-01" + }, + { + "name": "Jour du Drapeau et de l'Universit\u00e9", + "date": "2024-05-18" + }, + { + "name": "L'Assomption de Marie", + "date": "2024-08-15" + }, + { + "name": "Anniversaire de la mort de Dessalines", + "date": "2024-10-17" + }, + { + "name": "Toussaint", + "date": "2024-11-01" + }, + { + "name": "Jour des Morts", + "date": "2024-11-02" + }, + { + "name": "Verti\u00e8res", + "date": "2024-11-18" + }, + { + "name": "No\u00ebl", + "date": "2024-12-25" + } +] \ No newline at end of file diff --git a/tests/Countries/HaitiTest.php b/tests/Countries/HaitiTest.php new file mode 100644 index 000000000..9e5632765 --- /dev/null +++ b/tests/Countries/HaitiTest.php @@ -0,0 +1,18 @@ +get(); + + expect($holidays) + ->toBeArray() + ->not()->toBeEmpty(); + + expect(formatDates($holidays))->toMatchSnapshot(); +});