From db6122b138e344f1949aa4cd836c5afdd6fae16b Mon Sep 17 00:00:00 2001 From: insoutt Date: Tue, 9 Apr 2024 11:48:22 -0500 Subject: [PATCH] Add holidays for Ecuador --- src/Countries/Ecuador.php | 42 +++++++++++++++++ .../it_can_calculate_ecuador_holidays.snap | 46 +++++++++++++++++++ tests/Countries/EcuadorTest.php | 18 ++++++++ 3 files changed, 106 insertions(+) create mode 100644 src/Countries/Ecuador.php create mode 100644 tests/.pest/snapshots/Countries/EcuadorTest/it_can_calculate_ecuador_holidays.snap create mode 100644 tests/Countries/EcuadorTest.php diff --git a/src/Countries/Ecuador.php b/src/Countries/Ecuador.php new file mode 100644 index 000000000..feb5063db --- /dev/null +++ b/src/Countries/Ecuador.php @@ -0,0 +1,42 @@ + '01-01', + 'Día del Trabajo' => '05-01', + 'Batalla de Pichincha' => '05-24', + 'Primer Grito de la Independencia' => '08-10', + 'Independencia de Guayaquil' => '10-09', + 'Día de Los Difuntos' => '11-02', + 'Independencia de Cuenca' => '11-03', + 'Navidad' => '12-25', + ], $this->variableHolidays($year)); + } + + /** @return array */ + protected function variableHolidays(int $year): array + { + $easter = $this->easter($year); + $ashWednesday = $easter->subDays(46); + $carnivalMonday = $ashWednesday->subDays(2); + $carnivalTuesday = $ashWednesday->subDay(); + + return [ + 'Viernes Santo' => $easter->subDays(2), + 'Lunes de Carnaval' => $carnivalMonday, + 'Martes de Carnaval' => $carnivalTuesday, + ]; + } +} \ No newline at end of file diff --git a/tests/.pest/snapshots/Countries/EcuadorTest/it_can_calculate_ecuador_holidays.snap b/tests/.pest/snapshots/Countries/EcuadorTest/it_can_calculate_ecuador_holidays.snap new file mode 100644 index 000000000..aca8c20a5 --- /dev/null +++ b/tests/.pest/snapshots/Countries/EcuadorTest/it_can_calculate_ecuador_holidays.snap @@ -0,0 +1,46 @@ +[ + { + "name": "A\u00f1o Nuevo", + "date": "2024-01-01" + }, + { + "name": "Lunes de Carnaval", + "date": "2024-02-12" + }, + { + "name": "Martes de Carnaval", + "date": "2024-02-13" + }, + { + "name": "Viernes Santo", + "date": "2024-03-29" + }, + { + "name": "D\u00eda del Trabajo", + "date": "2024-05-01" + }, + { + "name": "Batalla de Pichincha", + "date": "2024-05-24" + }, + { + "name": "Primer Grito de la Independencia", + "date": "2024-08-10" + }, + { + "name": "Independencia de Guayaquil", + "date": "2024-10-09" + }, + { + "name": "D\u00eda de Los Difuntos", + "date": "2024-11-02" + }, + { + "name": "Independencia de Cuenca", + "date": "2024-11-03" + }, + { + "name": "Navidad", + "date": "2024-12-25" + } +] \ No newline at end of file diff --git a/tests/Countries/EcuadorTest.php b/tests/Countries/EcuadorTest.php new file mode 100644 index 000000000..4655d1738 --- /dev/null +++ b/tests/Countries/EcuadorTest.php @@ -0,0 +1,18 @@ +get(); + + expect($holidays) + ->toBeArray() + ->not()->toBeEmpty(); + + expect(formatDates($holidays))->toMatchSnapshot(); +});