From db6122b138e344f1949aa4cd836c5afdd6fae16b Mon Sep 17 00:00:00 2001 From: insoutt Date: Tue, 9 Apr 2024 11:48:22 -0500 Subject: [PATCH 01/14] 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(); +}); From febeceeb8c1ea6c975eb28d02c70673465fd0030 Mon Sep 17 00:00:00 2001 From: insoutt Date: Tue, 9 Apr 2024 13:22:31 -0500 Subject: [PATCH 02/14] Get nearest day of holiday --- src/Countries/Ecuador.php | 33 +++++++++++++++---- .../it_can_calculate_ecuador_holidays.snap | 10 +++--- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/src/Countries/Ecuador.php b/src/Countries/Ecuador.php index feb5063db..36b7f418e 100644 --- a/src/Countries/Ecuador.php +++ b/src/Countries/Ecuador.php @@ -15,16 +15,28 @@ protected function allHolidays(int $year): array { return array_merge([ 'Año Nuevo' => '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)); } + public function nearestDay(int $year, int $month, int $day) + { + $date = CarbonImmutable::createFromDate($year, $month, $day); + + if($date->is('Tuesday') || $date->is('Saturday')) { + return $date->subDay(); + } + + if($date->is('Sunday')) { + return $date->addDay(); + } + + if($date->is('Wednesday') || $date->is('Thursday')) { + return $date->next(CarbonImmutable::FRIDAY); + } + + return $date; + } + /** @return array */ protected function variableHolidays(int $year): array { @@ -37,6 +49,13 @@ protected function variableHolidays(int $year): array 'Viernes Santo' => $easter->subDays(2), 'Lunes de Carnaval' => $carnivalMonday, 'Martes de Carnaval' => $carnivalTuesday, + 'Día del Trabajo' => $this->nearestDay($year, 5, 1), + 'Batalla de Pichincha' => $this->nearestDay($year, 5, 24), + 'Primer Grito de la Independencia' => $this->nearestDay($year, 8, 10), + 'Independencia de Guayaquil' => $this->nearestDay($year, 10, 9), + 'Día de Los Difuntos' => $this->nearestDay($year, 11, 2), + 'Independencia de Cuenca' => $this->nearestDay($year, 11, 3), + 'Navidad' => $this->nearestDay($year, 12, 25), ]; } } \ 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 index aca8c20a5..41f564bb7 100644 --- a/tests/.pest/snapshots/Countries/EcuadorTest/it_can_calculate_ecuador_holidays.snap +++ b/tests/.pest/snapshots/Countries/EcuadorTest/it_can_calculate_ecuador_holidays.snap @@ -17,7 +17,7 @@ }, { "name": "D\u00eda del Trabajo", - "date": "2024-05-01" + "date": "2024-05-03" }, { "name": "Batalla de Pichincha", @@ -25,19 +25,19 @@ }, { "name": "Primer Grito de la Independencia", - "date": "2024-08-10" + "date": "2024-08-09" }, { "name": "Independencia de Guayaquil", - "date": "2024-10-09" + "date": "2024-10-11" }, { "name": "D\u00eda de Los Difuntos", - "date": "2024-11-02" + "date": "2024-11-01" }, { "name": "Independencia de Cuenca", - "date": "2024-11-03" + "date": "2024-11-04" }, { "name": "Navidad", From 883cd1404c0f8e3c2185d42fe915a53aca0c15a6 Mon Sep 17 00:00:00 2001 From: insoutt Date: Tue, 9 Apr 2024 14:18:59 -0500 Subject: [PATCH 03/14] Fix christmas holiday --- src/Countries/Ecuador.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Countries/Ecuador.php b/src/Countries/Ecuador.php index 36b7f418e..407352381 100644 --- a/src/Countries/Ecuador.php +++ b/src/Countries/Ecuador.php @@ -37,6 +37,17 @@ public function nearestDay(int $year, int $month, int $day) return $date; } + public function getChristmasHoliday(int $year) + { + $date = CarbonImmutable::createFromDate($year, 12, 25); + + if($year === 2022) { + return $date->addDay(); + } + + return $date; + } + /** @return array */ protected function variableHolidays(int $year): array { @@ -55,7 +66,7 @@ protected function variableHolidays(int $year): array 'Independencia de Guayaquil' => $this->nearestDay($year, 10, 9), 'Día de Los Difuntos' => $this->nearestDay($year, 11, 2), 'Independencia de Cuenca' => $this->nearestDay($year, 11, 3), - 'Navidad' => $this->nearestDay($year, 12, 25), + 'Navidad' => $this->getChristmasHoliday($year), ]; } } \ No newline at end of file From 486426a9e53cc4d9a7e6783830618141507bbee5 Mon Sep 17 00:00:00 2001 From: insoutt Date: Tue, 9 Apr 2024 15:29:51 -0500 Subject: [PATCH 04/14] Add return type --- src/Countries/Ecuador.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Countries/Ecuador.php b/src/Countries/Ecuador.php index 407352381..c847da67c 100644 --- a/src/Countries/Ecuador.php +++ b/src/Countries/Ecuador.php @@ -18,7 +18,7 @@ protected function allHolidays(int $year): array ], $this->variableHolidays($year)); } - public function nearestDay(int $year, int $month, int $day) + public function nearestDay(int $year, int $month, int $day): CarbonImmutable { $date = CarbonImmutable::createFromDate($year, $month, $day); @@ -37,7 +37,7 @@ public function nearestDay(int $year, int $month, int $day) return $date; } - public function getChristmasHoliday(int $year) + public function getChristmasHoliday(int $year): CarbonImmutable { $date = CarbonImmutable::createFromDate($year, 12, 25); From 79b35f0c901305123c3157445a9f733e6bf1e8a0 Mon Sep 17 00:00:00 2001 From: insoutt Date: Tue, 9 Apr 2024 16:48:04 -0500 Subject: [PATCH 05/14] Use observedChristmasDay --- src/Countries/Ecuador.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Countries/Ecuador.php b/src/Countries/Ecuador.php index c847da67c..9a985dc96 100644 --- a/src/Countries/Ecuador.php +++ b/src/Countries/Ecuador.php @@ -3,9 +3,12 @@ namespace Spatie\Holidays\Countries; use Carbon\CarbonImmutable; +use Spatie\Holidays\Concerns\Observable; class Ecuador extends Country { + use Observable; + public function countryCode(): string { return 'ec'; @@ -39,13 +42,11 @@ public function nearestDay(int $year, int $month, int $day): CarbonImmutable public function getChristmasHoliday(int $year): CarbonImmutable { - $date = CarbonImmutable::createFromDate($year, 12, 25); - if($year === 2022) { - return $date->addDay(); + return $this->observedChristmasDay($year); } - return $date; + return CarbonImmutable::createFromDate($year, 12, 25); } /** @return array */ From ec1ae3872c07c452b97b6c9e9206e219f7e54524 Mon Sep 17 00:00:00 2001 From: insoutt Date: Tue, 9 Apr 2024 17:05:59 -0500 Subject: [PATCH 06/14] Add translations --- lang/ecuador/es/holidays.json | 13 +++++++++++++ src/Countries/Ecuador.php | 32 ++++++++++++++++++++------------ tests/Countries/EcuadorTest.php | 2 +- 3 files changed, 34 insertions(+), 13 deletions(-) create mode 100644 lang/ecuador/es/holidays.json diff --git a/lang/ecuador/es/holidays.json b/lang/ecuador/es/holidays.json new file mode 100644 index 000000000..1c60a1f3e --- /dev/null +++ b/lang/ecuador/es/holidays.json @@ -0,0 +1,13 @@ +{ + "New Year's Day": "Año Nuevo", + "Holy Friday": "Viernes Santo", + "Carnival Monday": "Lunes de Carnaval", + "Carnival Tuesday": "Martes de Carnaval", + "Labor Day": "Día del Trabajo", + "Battle of Pichincha": "Batalla de Pichincha", + "Independence Day": "Primer Grito de la Independencia", + "Independence Of Guayaquil": "Independencia de Guayaquil", + "All Souls' Day": "Día de Los Difuntos", + "Independence Of Cuenca": "Independencia de Cuenca", + "Christmas": "Navidad" +} \ No newline at end of file diff --git a/src/Countries/Ecuador.php b/src/Countries/Ecuador.php index 9a985dc96..3d78b55b3 100644 --- a/src/Countries/Ecuador.php +++ b/src/Countries/Ecuador.php @@ -4,20 +4,28 @@ use Carbon\CarbonImmutable; use Spatie\Holidays\Concerns\Observable; +use Spatie\Holidays\Concerns\Translatable; +use Spatie\Holidays\Contracts\HasTranslations; -class Ecuador extends Country +class Ecuador extends Country implements HasTranslations { use Observable; + use Translatable; public function countryCode(): string { return 'ec'; } + public function defaultLocale(): string + { + return 'en'; + } + protected function allHolidays(int $year): array { return array_merge([ - 'Año Nuevo' => '01-01', + 'New Year\'s Day' => '01-01', ], $this->variableHolidays($year)); } @@ -58,16 +66,16 @@ protected function variableHolidays(int $year): array $carnivalTuesday = $ashWednesday->subDay(); return [ - 'Viernes Santo' => $easter->subDays(2), - 'Lunes de Carnaval' => $carnivalMonday, - 'Martes de Carnaval' => $carnivalTuesday, - 'Día del Trabajo' => $this->nearestDay($year, 5, 1), - 'Batalla de Pichincha' => $this->nearestDay($year, 5, 24), - 'Primer Grito de la Independencia' => $this->nearestDay($year, 8, 10), - 'Independencia de Guayaquil' => $this->nearestDay($year, 10, 9), - 'Día de Los Difuntos' => $this->nearestDay($year, 11, 2), - 'Independencia de Cuenca' => $this->nearestDay($year, 11, 3), - 'Navidad' => $this->getChristmasHoliday($year), + 'Holy Friday' => $easter->subDays(2), + 'Carnival Monday' => $carnivalMonday, + 'Carnival Tuesday' => $carnivalTuesday, + 'Labor Day' => $this->nearestDay($year, 5, 1), + 'Battle of Pichincha' => $this->nearestDay($year, 5, 24), + 'Independence Day' => $this->nearestDay($year, 8, 10), + 'Independence Of Guayaquil' => $this->nearestDay($year, 10, 9), + 'All Souls\' Day' => $this->nearestDay($year, 11, 2), + 'Independence Of Cuenca' => $this->nearestDay($year, 11, 3), + 'Christmas' => $this->getChristmasHoliday($year), ]; } } \ No newline at end of file diff --git a/tests/Countries/EcuadorTest.php b/tests/Countries/EcuadorTest.php index 4655d1738..e3151bf9d 100644 --- a/tests/Countries/EcuadorTest.php +++ b/tests/Countries/EcuadorTest.php @@ -8,7 +8,7 @@ it('can calculate ecuador holidays', function () { CarbonImmutable::setTestNow('2024-01-01'); - $holidays = Holidays::for(country: 'ec')->get(); + $holidays = Holidays::for(country: 'ec', locale: 'es')->get(); expect($holidays) ->toBeArray() From 57ca25498b2686c5cca13e5b41660da999d99ad1 Mon Sep 17 00:00:00 2001 From: Elvis Fernando Date: Wed, 10 Apr 2024 11:32:24 -0500 Subject: [PATCH 07/14] Update src/Countries/Ecuador.php Co-authored-by: Niels Vanpachtenbeke <10651054+Nielsvanpach@users.noreply.github.com> --- src/Countries/Ecuador.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Countries/Ecuador.php b/src/Countries/Ecuador.php index 3d78b55b3..bf638f570 100644 --- a/src/Countries/Ecuador.php +++ b/src/Countries/Ecuador.php @@ -19,7 +19,7 @@ public function countryCode(): string public function defaultLocale(): string { - return 'en'; + return 'es; } protected function allHolidays(int $year): array From ad1164d787ad16c711d6f4f29fbdaddff12e40ef Mon Sep 17 00:00:00 2001 From: Elvis Fernando Date: Wed, 10 Apr 2024 11:33:06 -0500 Subject: [PATCH 08/14] Update src/Countries/Ecuador.php Co-authored-by: Niels Vanpachtenbeke <10651054+Nielsvanpach@users.noreply.github.com> --- src/Countries/Ecuador.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Countries/Ecuador.php b/src/Countries/Ecuador.php index bf638f570..70ac05c36 100644 --- a/src/Countries/Ecuador.php +++ b/src/Countries/Ecuador.php @@ -62,8 +62,6 @@ protected function variableHolidays(int $year): array { $easter = $this->easter($year); $ashWednesday = $easter->subDays(46); - $carnivalMonday = $ashWednesday->subDays(2); - $carnivalTuesday = $ashWednesday->subDay(); return [ 'Holy Friday' => $easter->subDays(2), From 5b8d7c3e41e938c43c63414c04484e22233dcf6b Mon Sep 17 00:00:00 2001 From: Elvis Fernando Date: Wed, 10 Apr 2024 11:33:14 -0500 Subject: [PATCH 09/14] Update src/Countries/Ecuador.php Co-authored-by: Niels Vanpachtenbeke <10651054+Nielsvanpach@users.noreply.github.com> --- src/Countries/Ecuador.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Countries/Ecuador.php b/src/Countries/Ecuador.php index 70ac05c36..59dbe61d2 100644 --- a/src/Countries/Ecuador.php +++ b/src/Countries/Ecuador.php @@ -65,8 +65,8 @@ protected function variableHolidays(int $year): array return [ 'Holy Friday' => $easter->subDays(2), - 'Carnival Monday' => $carnivalMonday, - 'Carnival Tuesday' => $carnivalTuesday, + 'Carnival Monday' => $ashWednesday->subDays(2), + 'Carnival Tuesday' => $ashWednesday->subDay(), 'Labor Day' => $this->nearestDay($year, 5, 1), 'Battle of Pichincha' => $this->nearestDay($year, 5, 24), 'Independence Day' => $this->nearestDay($year, 8, 10), From 1fbcd52bb9c9da19b9066a8e61f4c1ad2c73e299 Mon Sep 17 00:00:00 2001 From: insoutt Date: Wed, 10 Apr 2024 11:48:32 -0500 Subject: [PATCH 10/14] Fix syntax --- src/Countries/Ecuador.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Countries/Ecuador.php b/src/Countries/Ecuador.php index 59dbe61d2..8c22dbe18 100644 --- a/src/Countries/Ecuador.php +++ b/src/Countries/Ecuador.php @@ -19,7 +19,7 @@ public function countryCode(): string public function defaultLocale(): string { - return 'es; + return 'es'; } protected function allHolidays(int $year): array From d693203c0a7695b1c2824afdf56bf8a6b421e8d1 Mon Sep 17 00:00:00 2001 From: insoutt Date: Wed, 10 Apr 2024 12:00:06 -0500 Subject: [PATCH 11/14] Move holiday to Monday, not Tuesday --- src/Countries/Ecuador.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Countries/Ecuador.php b/src/Countries/Ecuador.php index 8c22dbe18..f0017bf9c 100644 --- a/src/Countries/Ecuador.php +++ b/src/Countries/Ecuador.php @@ -51,7 +51,7 @@ public function nearestDay(int $year, int $month, int $day): CarbonImmutable public function getChristmasHoliday(int $year): CarbonImmutable { if($year === 2022) { - return $this->observedChristmasDay($year); + return $this->sundayToNextMonday('12-25', $year); } return CarbonImmutable::createFromDate($year, 12, 25); From a20aee16534ed76dd1e5ee3acc683b40fef3f7cf Mon Sep 17 00:00:00 2001 From: insoutt Date: Wed, 10 Apr 2024 12:31:28 -0500 Subject: [PATCH 12/14] Test translation --- src/Countries/Ecuador.php | 2 +- .../it_can_calculate_ecuador_holidays.snap | 22 ++++----- ...dor_holidays_with_spanish_translation.snap | 46 +++++++++++++++++++ tests/Countries/EcuadorTest.php | 13 ++++++ 4 files changed, 71 insertions(+), 12 deletions(-) create mode 100644 tests/.pest/snapshots/Countries/EcuadorTest/it_can_calculate_ecuador_holidays_with_spanish_translation.snap diff --git a/src/Countries/Ecuador.php b/src/Countries/Ecuador.php index f0017bf9c..e590d3aee 100644 --- a/src/Countries/Ecuador.php +++ b/src/Countries/Ecuador.php @@ -19,7 +19,7 @@ public function countryCode(): string public function defaultLocale(): string { - return 'es'; + return 'en'; } protected function allHolidays(int $year): array 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 index 41f564bb7..b542dfd1e 100644 --- a/tests/.pest/snapshots/Countries/EcuadorTest/it_can_calculate_ecuador_holidays.snap +++ b/tests/.pest/snapshots/Countries/EcuadorTest/it_can_calculate_ecuador_holidays.snap @@ -1,46 +1,46 @@ [ { - "name": "A\u00f1o Nuevo", + "name": "New Year's Day", "date": "2024-01-01" }, { - "name": "Lunes de Carnaval", + "name": "Carnival Monday", "date": "2024-02-12" }, { - "name": "Martes de Carnaval", + "name": "Carnival Tuesday", "date": "2024-02-13" }, { - "name": "Viernes Santo", + "name": "Holy Friday", "date": "2024-03-29" }, { - "name": "D\u00eda del Trabajo", + "name": "Labor Day", "date": "2024-05-03" }, { - "name": "Batalla de Pichincha", + "name": "Battle of Pichincha", "date": "2024-05-24" }, { - "name": "Primer Grito de la Independencia", + "name": "Independence Day", "date": "2024-08-09" }, { - "name": "Independencia de Guayaquil", + "name": "Independence Of Guayaquil", "date": "2024-10-11" }, { - "name": "D\u00eda de Los Difuntos", + "name": "All Souls' Day", "date": "2024-11-01" }, { - "name": "Independencia de Cuenca", + "name": "Independence Of Cuenca", "date": "2024-11-04" }, { - "name": "Navidad", + "name": "Christmas", "date": "2024-12-25" } ] \ No newline at end of file diff --git a/tests/.pest/snapshots/Countries/EcuadorTest/it_can_calculate_ecuador_holidays_with_spanish_translation.snap b/tests/.pest/snapshots/Countries/EcuadorTest/it_can_calculate_ecuador_holidays_with_spanish_translation.snap new file mode 100644 index 000000000..41f564bb7 --- /dev/null +++ b/tests/.pest/snapshots/Countries/EcuadorTest/it_can_calculate_ecuador_holidays_with_spanish_translation.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-03" + }, + { + "name": "Batalla de Pichincha", + "date": "2024-05-24" + }, + { + "name": "Primer Grito de la Independencia", + "date": "2024-08-09" + }, + { + "name": "Independencia de Guayaquil", + "date": "2024-10-11" + }, + { + "name": "D\u00eda de Los Difuntos", + "date": "2024-11-01" + }, + { + "name": "Independencia de Cuenca", + "date": "2024-11-04" + }, + { + "name": "Navidad", + "date": "2024-12-25" + } +] \ No newline at end of file diff --git a/tests/Countries/EcuadorTest.php b/tests/Countries/EcuadorTest.php index e3151bf9d..3abfed3af 100644 --- a/tests/Countries/EcuadorTest.php +++ b/tests/Countries/EcuadorTest.php @@ -8,6 +8,18 @@ it('can calculate ecuador holidays', function () { CarbonImmutable::setTestNow('2024-01-01'); + $holidays = Holidays::for(country: 'ec')->get(); + + expect($holidays) + ->toBeArray() + ->not()->toBeEmpty(); + + expect(formatDates($holidays))->toMatchSnapshot(); +}); + +it('can calculate ecuador holidays with spanish translation', function () { + CarbonImmutable::setTestNow('2024-01-01'); + $holidays = Holidays::for(country: 'ec', locale: 'es')->get(); expect($holidays) @@ -16,3 +28,4 @@ expect(formatDates($holidays))->toMatchSnapshot(); }); + From 3123eba1427cff7c1f17211104cd9b387436d87b Mon Sep 17 00:00:00 2001 From: insoutt Date: Wed, 10 Apr 2024 16:36:29 -0500 Subject: [PATCH 13/14] Set default lang to es --- src/Countries/Ecuador.php | 2 +- .../it_can_calculate_ecuador_holidays.snap | 22 +++++++++---------- ...dor_holidays_with_spanish_translation.snap | 22 +++++++++---------- tests/Countries/EcuadorTest.php | 4 ++-- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/Countries/Ecuador.php b/src/Countries/Ecuador.php index e590d3aee..f0017bf9c 100644 --- a/src/Countries/Ecuador.php +++ b/src/Countries/Ecuador.php @@ -19,7 +19,7 @@ public function countryCode(): string public function defaultLocale(): string { - return 'en'; + return 'es'; } protected function allHolidays(int $year): array 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 index b542dfd1e..41f564bb7 100644 --- a/tests/.pest/snapshots/Countries/EcuadorTest/it_can_calculate_ecuador_holidays.snap +++ b/tests/.pest/snapshots/Countries/EcuadorTest/it_can_calculate_ecuador_holidays.snap @@ -1,46 +1,46 @@ [ { - "name": "New Year's Day", + "name": "A\u00f1o Nuevo", "date": "2024-01-01" }, { - "name": "Carnival Monday", + "name": "Lunes de Carnaval", "date": "2024-02-12" }, { - "name": "Carnival Tuesday", + "name": "Martes de Carnaval", "date": "2024-02-13" }, { - "name": "Holy Friday", + "name": "Viernes Santo", "date": "2024-03-29" }, { - "name": "Labor Day", + "name": "D\u00eda del Trabajo", "date": "2024-05-03" }, { - "name": "Battle of Pichincha", + "name": "Batalla de Pichincha", "date": "2024-05-24" }, { - "name": "Independence Day", + "name": "Primer Grito de la Independencia", "date": "2024-08-09" }, { - "name": "Independence Of Guayaquil", + "name": "Independencia de Guayaquil", "date": "2024-10-11" }, { - "name": "All Souls' Day", + "name": "D\u00eda de Los Difuntos", "date": "2024-11-01" }, { - "name": "Independence Of Cuenca", + "name": "Independencia de Cuenca", "date": "2024-11-04" }, { - "name": "Christmas", + "name": "Navidad", "date": "2024-12-25" } ] \ No newline at end of file diff --git a/tests/.pest/snapshots/Countries/EcuadorTest/it_can_calculate_ecuador_holidays_with_spanish_translation.snap b/tests/.pest/snapshots/Countries/EcuadorTest/it_can_calculate_ecuador_holidays_with_spanish_translation.snap index 41f564bb7..b542dfd1e 100644 --- a/tests/.pest/snapshots/Countries/EcuadorTest/it_can_calculate_ecuador_holidays_with_spanish_translation.snap +++ b/tests/.pest/snapshots/Countries/EcuadorTest/it_can_calculate_ecuador_holidays_with_spanish_translation.snap @@ -1,46 +1,46 @@ [ { - "name": "A\u00f1o Nuevo", + "name": "New Year's Day", "date": "2024-01-01" }, { - "name": "Lunes de Carnaval", + "name": "Carnival Monday", "date": "2024-02-12" }, { - "name": "Martes de Carnaval", + "name": "Carnival Tuesday", "date": "2024-02-13" }, { - "name": "Viernes Santo", + "name": "Holy Friday", "date": "2024-03-29" }, { - "name": "D\u00eda del Trabajo", + "name": "Labor Day", "date": "2024-05-03" }, { - "name": "Batalla de Pichincha", + "name": "Battle of Pichincha", "date": "2024-05-24" }, { - "name": "Primer Grito de la Independencia", + "name": "Independence Day", "date": "2024-08-09" }, { - "name": "Independencia de Guayaquil", + "name": "Independence Of Guayaquil", "date": "2024-10-11" }, { - "name": "D\u00eda de Los Difuntos", + "name": "All Souls' Day", "date": "2024-11-01" }, { - "name": "Independencia de Cuenca", + "name": "Independence Of Cuenca", "date": "2024-11-04" }, { - "name": "Navidad", + "name": "Christmas", "date": "2024-12-25" } ] \ No newline at end of file diff --git a/tests/Countries/EcuadorTest.php b/tests/Countries/EcuadorTest.php index 3abfed3af..9de016443 100644 --- a/tests/Countries/EcuadorTest.php +++ b/tests/Countries/EcuadorTest.php @@ -17,10 +17,10 @@ expect(formatDates($holidays))->toMatchSnapshot(); }); -it('can calculate ecuador holidays with spanish translation', function () { +it('can calculate ecuador holidays with english translation', function () { CarbonImmutable::setTestNow('2024-01-01'); - $holidays = Holidays::for(country: 'ec', locale: 'es')->get(); + $holidays = Holidays::for(country: 'ec', locale: 'en')->get(); expect($holidays) ->toBeArray() From 62823d467396717a0f4d2ae7d6d6e8639aa9d1a5 Mon Sep 17 00:00:00 2001 From: insoutt Date: Wed, 10 Apr 2024 16:38:06 -0500 Subject: [PATCH 14/14] Rename snapshot --- ..._can_calculate_ecuador_holidays_with_english_translation.snap} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/.pest/snapshots/Countries/EcuadorTest/{it_can_calculate_ecuador_holidays_with_spanish_translation.snap => it_can_calculate_ecuador_holidays_with_english_translation.snap} (100%) diff --git a/tests/.pest/snapshots/Countries/EcuadorTest/it_can_calculate_ecuador_holidays_with_spanish_translation.snap b/tests/.pest/snapshots/Countries/EcuadorTest/it_can_calculate_ecuador_holidays_with_english_translation.snap similarity index 100% rename from tests/.pest/snapshots/Countries/EcuadorTest/it_can_calculate_ecuador_holidays_with_spanish_translation.snap rename to tests/.pest/snapshots/Countries/EcuadorTest/it_can_calculate_ecuador_holidays_with_english_translation.snap