From 01680ab75741f631ad3c6b136e05a1d5fd12e2fb Mon Sep 17 00:00:00 2001 From: Kanan Aghayev Date: Tue, 23 Jan 2024 00:59:12 +0400 Subject: [PATCH 1/3] Add Azerbaijan holidays --- src/Countries/Azerbaijan.php | 37 +++++++++++++++ ...it_can_calculate_azerbaijani_holidays.snap | 46 +++++++++++++++++++ tests/Countries/AzerbaijanTest.php | 18 ++++++++ 3 files changed, 101 insertions(+) create mode 100644 src/Countries/Azerbaijan.php create mode 100644 tests/.pest/snapshots/Countries/AzerbaijanTest/it_can_calculate_azerbaijani_holidays.snap create mode 100644 tests/Countries/AzerbaijanTest.php diff --git a/src/Countries/Azerbaijan.php b/src/Countries/Azerbaijan.php new file mode 100644 index 000000000..b92cd3b12 --- /dev/null +++ b/src/Countries/Azerbaijan.php @@ -0,0 +1,37 @@ + '01-01', + 'Beynəlxalq Qadınlar günü' => '03-08', + 'Novruz bayramı' => '03-20', + 'Faşizm üzərində qələbə günü' => '05-09', + 'Müstəqillik Günü' => '05-28', + 'Azərbaycan xalqının milli qurtuluş günü' => '06-15', + 'Azərbaycan Respublikasının Silahlı Qüvvələri günü' => '06-26', + 'Müstəqilliyin bərpası günü' => '10-18', + 'Zəfər Günü' => '11-08', + 'Azərbaycan Respublikasının Dövlət bayrağı günü' => '11-09', + 'Dünya azərbaycanlılarının həmrəyliyi günü' => '12-31', + ], $this->variableHolidays($year)); + } + + /** @return array */ + protected function variableHolidays(int $year): array + { + // does not change according to the standard + return []; + } +} diff --git a/tests/.pest/snapshots/Countries/AzerbaijanTest/it_can_calculate_azerbaijani_holidays.snap b/tests/.pest/snapshots/Countries/AzerbaijanTest/it_can_calculate_azerbaijani_holidays.snap new file mode 100644 index 000000000..cb0489f97 --- /dev/null +++ b/tests/.pest/snapshots/Countries/AzerbaijanTest/it_can_calculate_azerbaijani_holidays.snap @@ -0,0 +1,46 @@ +[ + { + "name": "Yeni il", + "date": "2024-01-01" + }, + { + "name": "Beyn\u0259lxalq Qad\u0131nlar g\u00fcn\u00fc", + "date": "2024-03-08" + }, + { + "name": "Novruz bayram\u0131", + "date": "2024-03-20" + }, + { + "name": "Fa\u015fizm \u00fcz\u0259rind\u0259 q\u0259l\u0259b\u0259 g\u00fcn\u00fc", + "date": "2024-05-09" + }, + { + "name": "M\u00fcst\u0259qillik G\u00fcn\u00fc", + "date": "2024-05-28" + }, + { + "name": "Az\u0259rbaycan xalq\u0131n\u0131n milli qurtulu\u015f g\u00fcn\u00fc", + "date": "2024-06-15" + }, + { + "name": "Az\u0259rbaycan Respublikas\u0131n\u0131n Silahl\u0131 Q\u00fcvv\u0259l\u0259ri g\u00fcn\u00fc", + "date": "2024-06-26" + }, + { + "name": "M\u00fcst\u0259qilliyin b\u0259rpas\u0131 g\u00fcn\u00fc", + "date": "2024-10-18" + }, + { + "name": "Z\u0259f\u0259r G\u00fcn\u00fc", + "date": "2024-11-08" + }, + { + "name": "Az\u0259rbaycan Respublikas\u0131n\u0131n D\u00f6vl\u0259t bayra\u011f\u0131 g\u00fcn\u00fc", + "date": "2024-11-09" + }, + { + "name": "D\u00fcnya az\u0259rbaycanl\u0131lar\u0131n\u0131n h\u0259mr\u0259yliyi g\u00fcn\u00fc", + "date": "2024-12-31" + } +] \ No newline at end of file diff --git a/tests/Countries/AzerbaijanTest.php b/tests/Countries/AzerbaijanTest.php new file mode 100644 index 000000000..0d6d629a4 --- /dev/null +++ b/tests/Countries/AzerbaijanTest.php @@ -0,0 +1,18 @@ +get(); + + expect($holidays) + ->toBeArray() + ->not()->toBeEmpty(); + + expect(formatDates($holidays))->toMatchSnapshot(); +}); From 45b8968d8177b0ff74170177154929d0fa65cd83 Mon Sep 17 00:00:00 2001 From: Kanan Aghayev Date: Thu, 25 Jan 2024 03:53:36 +0400 Subject: [PATCH 2/3] Added Azerbaijani holidays in English --- lang/azerbaijan/en/holidays.json | 13 ++++++ ...ulate_azerbaijani_holidays_in_english.snap | 46 +++++++++++++++++++ tests/Countries/AzerbaijanTest.php | 12 +++++ 3 files changed, 71 insertions(+) create mode 100644 lang/azerbaijan/en/holidays.json create mode 100644 tests/.pest/snapshots/Countries/AzerbaijanTest/it_can_calculate_azerbaijani_holidays_in_english.snap diff --git a/lang/azerbaijan/en/holidays.json b/lang/azerbaijan/en/holidays.json new file mode 100644 index 000000000..2fc0b49c3 --- /dev/null +++ b/lang/azerbaijan/en/holidays.json @@ -0,0 +1,13 @@ +{ + "Yeni il": "New year", + "Beynəlxalq Qadınlar günü": "International Women's Day", + "Novruz bayramı": "Novruz holiday", + "Faşizm üzərində qələbə günü": "Day of Victory over fascism", + "Müstəqillik Günü": "Independence Day", + "Azərbaycan xalqının milli qurtuluş günü": "National Salvation Day of the Azerbaijani people", + "Azərbaycan Respublikasının Silahlı Qüvvələri günü": "Day of Armed Forces of the Republic of Azerbaijan", + "Müstəqilliyin bərpası günü": "Day of Restoration of Independence", + "Zəfər Günü": "Victory Day", + "Azərbaycan Respublikasının Dövlət bayrağı günü": "National Flag Day of the Republic of Azerbaijan", + "Dünya azərbaycanlılarının həmrəyliyi günü": "World Azerbaijanis Solidarity Day" +} diff --git a/tests/.pest/snapshots/Countries/AzerbaijanTest/it_can_calculate_azerbaijani_holidays_in_english.snap b/tests/.pest/snapshots/Countries/AzerbaijanTest/it_can_calculate_azerbaijani_holidays_in_english.snap new file mode 100644 index 000000000..e1ef8359c --- /dev/null +++ b/tests/.pest/snapshots/Countries/AzerbaijanTest/it_can_calculate_azerbaijani_holidays_in_english.snap @@ -0,0 +1,46 @@ +[ + { + "name": "New year", + "date": "2024-01-01" + }, + { + "name": "International Women's Day", + "date": "2024-03-08" + }, + { + "name": "Novruz holiday", + "date": "2024-03-20" + }, + { + "name": "Day of Victory over fascism", + "date": "2024-05-09" + }, + { + "name": "Independence Day", + "date": "2024-05-28" + }, + { + "name": "National Salvation Day of the Azerbaijani people", + "date": "2024-06-15" + }, + { + "name": "Day of Armed Forces of the Republic of Azerbaijan", + "date": "2024-06-26" + }, + { + "name": "Day of Restoration of Independence", + "date": "2024-10-18" + }, + { + "name": "Victory Day", + "date": "2024-11-08" + }, + { + "name": "National Flag Day of the Republic of Azerbaijan", + "date": "2024-11-09" + }, + { + "name": "World Azerbaijanis Solidarity Day", + "date": "2024-12-31" + } +] \ No newline at end of file diff --git a/tests/Countries/AzerbaijanTest.php b/tests/Countries/AzerbaijanTest.php index 0d6d629a4..263ab724e 100644 --- a/tests/Countries/AzerbaijanTest.php +++ b/tests/Countries/AzerbaijanTest.php @@ -16,3 +16,15 @@ expect(formatDates($holidays))->toMatchSnapshot(); }); + +it('can calculate azerbaijani holidays in english', function () { + CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + + $holidays = Holidays::for(country: 'az',locale: 'en')->get(); + + expect($holidays) + ->toBeArray() + ->not()->toBeEmpty(); + + expect(formatDates($holidays))->toMatchSnapshot(); +}); From 59ccfa88329ff1c50a569b7905553cadafe07c9d Mon Sep 17 00:00:00 2001 From: Kanan Aghayev Date: Thu, 1 Feb 2024 23:43:39 +0400 Subject: [PATCH 3/3] update setTestNowAndTimezone to setTestNow --- tests/Countries/AzerbaijanTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Countries/AzerbaijanTest.php b/tests/Countries/AzerbaijanTest.php index 263ab724e..4de5efa5a 100644 --- a/tests/Countries/AzerbaijanTest.php +++ b/tests/Countries/AzerbaijanTest.php @@ -6,7 +6,7 @@ use Spatie\Holidays\Holidays; it('can calculate azerbaijani holidays', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'az')->get(); @@ -18,7 +18,7 @@ }); it('can calculate azerbaijani holidays in english', function () { - CarbonImmutable::setTestNowAndTimezone('2024-01-01'); + CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'az',locale: 'en')->get();