From 1127c0dc2586455b4fa1cd9f91009ec17a4af888 Mon Sep 17 00:00:00 2001 From: Arkounay Date: Tue, 18 Feb 2020 16:30:11 +0100 Subject: [PATCH] Added Luxembourg Provider (#205) --- CHANGELOG.md | 1 + src/Yasumi/Provider/Luxembourg.php | 103 ++++++++++++++++++ src/Yasumi/data/translations/allSaintsDay.php | 1 + src/Yasumi/data/translations/ascensionDay.php | 1 + .../data/translations/assumptionOfMary.php | 1 + src/Yasumi/data/translations/christmasDay.php | 1 + src/Yasumi/data/translations/easterMonday.php | 1 + .../translations/internationalWorkersDay.php | 1 + src/Yasumi/data/translations/newYearsDay.php | 1 + .../data/translations/pentecostMonday.php | 7 +- .../data/translations/secondChristmasDay.php | 1 + tests/Luxembourg/AllSaintsDayTest.php | 79 ++++++++++++++ tests/Luxembourg/AscensionDayTest.php | 70 ++++++++++++ tests/Luxembourg/AssumptionOfMaryTest.php | 79 ++++++++++++++ tests/Luxembourg/ChristmasDayTest.php | 79 ++++++++++++++ tests/Luxembourg/EasterMondayTest.php | 70 ++++++++++++ tests/Luxembourg/EuropeDayTest.php | 93 ++++++++++++++++ .../InternationalWorkersDayTest.php | 79 ++++++++++++++ tests/Luxembourg/LuxembourgBaseTestCase.php | 39 +++++++ tests/Luxembourg/LuxembourgTest.php | 92 ++++++++++++++++ tests/Luxembourg/NationalDayTest.php | 79 ++++++++++++++ tests/Luxembourg/NewYearsDayTest.php | 79 ++++++++++++++ tests/Luxembourg/PentecostMondayTest.php | 70 ++++++++++++ tests/Luxembourg/SecondChristmasDayTest.php | 79 ++++++++++++++ 24 files changed, 1103 insertions(+), 3 deletions(-) create mode 100755 src/Yasumi/Provider/Luxembourg.php create mode 100644 tests/Luxembourg/AllSaintsDayTest.php create mode 100644 tests/Luxembourg/AscensionDayTest.php create mode 100644 tests/Luxembourg/AssumptionOfMaryTest.php create mode 100644 tests/Luxembourg/ChristmasDayTest.php create mode 100644 tests/Luxembourg/EasterMondayTest.php create mode 100644 tests/Luxembourg/EuropeDayTest.php create mode 100644 tests/Luxembourg/InternationalWorkersDayTest.php create mode 100644 tests/Luxembourg/LuxembourgBaseTestCase.php create mode 100644 tests/Luxembourg/LuxembourgTest.php create mode 100644 tests/Luxembourg/NationalDayTest.php create mode 100644 tests/Luxembourg/NewYearsDayTest.php create mode 100644 tests/Luxembourg/PentecostMondayTest.php create mode 100644 tests/Luxembourg/SecondChristmasDayTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 7821de4ca..0a6dd65c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/) and this - Remembrance Day for Homeland War Victims and Remembrance Day for the Victims of Vukovar and Skabrnja is a new official holiday since 2020 in Croatia. [\#203](https://github.com/azuyalabs/yasumi/pull/203) ([krukru](https://github.com/krukru)) ### Added +- Added Luxembourg Provider [\#205](https://github.com/azuyalabs/yasumi/pull/205) ([Arkounay](https://github.com/Arkounay)) - Catalan translations for holidays in Catalonia, Valencian Community, Balearic Islands and Aragon [\#189](https://github.com/azuyalabs/yasumi/pull/189) ([c960657](https://github.com/c960657)) - Added French translation for Second Christmas Day [\#188](https://github.com/azuyalabs/yasumi/pull/188) ([Arkounay](https://github.com/Arkounay)) - Additional Dates for Australia/Victoria:AFL Grand Final Friday [\#190](https://github.com/azuyalabs/yasumi/pull/190) ([brucealdridge](https://github.com/brucealdridge)) diff --git a/src/Yasumi/Provider/Luxembourg.php b/src/Yasumi/Provider/Luxembourg.php new file mode 100755 index 000000000..d6d179560 --- /dev/null +++ b/src/Yasumi/Provider/Luxembourg.php @@ -0,0 +1,103 @@ +timezone = 'Europe/Luxembourg'; + + // Add common holidays + $this->addHoliday($this->newYearsDay($this->year, $this->timezone, $this->locale)); + $this->addHoliday($this->easterMonday($this->year, $this->timezone, $this->locale)); + $this->addHoliday($this->internationalWorkersDay($this->year, $this->timezone, $this->locale)); + $this->calculateEuropeDay(); + $this->addHoliday($this->ascensionDay($this->year, $this->timezone, $this->locale)); + $this->addHoliday($this->pentecostMonday($this->year, $this->timezone, $this->locale)); + $this->calculateNationalDay(); + $this->addHoliday($this->assumptionOfMary($this->year, $this->timezone, $this->locale)); + $this->addHoliday($this->allSaintsDay($this->year, $this->timezone, $this->locale)); + $this->addHoliday($this->christmasDay($this->year, $this->timezone, $this->locale)); + $this->addHoliday($this->secondChristmasDay($this->year, $this->timezone, $this->locale)); + } + + /** + * Europe Day. + * + * Europe Day is celebrated on 5 May by the Council of Europe and on 9 May by the European Union. + * The first recognition of Europe Day was by the Council of Europe, introduced in 1964. + * The European Union later started to celebrate its own European Day in commemoration of the 1950 + * Schuman Declaration, leading it to be referred to by some as "Schuman Day". + * Both days are celebrated by displaying the Flag of Europe. + * + * @link https://en.wikipedia.org/wiki/Europe_Day + * + * @throws InvalidDateException + * @throws \InvalidArgumentException + * @throws UnknownLocaleException + * @throws \Exception + */ + public function calculateEuropeDay(): void + { + if ($this->year >= 2019) { + $this->addHoliday(new Holiday('europeDay', [ + 'en_US' => 'Europe day', + 'fr_FR' => 'La Journée de l\'Europe', + 'lu' => 'La Journée de l\'Europe', + ], new DateTime("$this->year-5-9", new DateTimeZone($this->timezone)), $this->locale)); + } + } + + /** + * Luxembourgish National Day. + * + * The Grand Duke's Official Birthday (French: Célébration publique de l'anniversaire du souverain), + * also known as Luxembourgish National Day (French: Fête nationale luxembourgeoise, Luxembourgish: + * Lëtzebuerger Nationalfeierdag), is celebrated as the annual national holiday of Luxembourg. + * It is celebrated on 23 June, although this has never been the actual birthday of any ruler of Luxembourg. + * When the monarch of Luxembourg is female, it is known as the Grand Duchess' Official Birthday. + * + * @link https://en.wikipedia.org/wiki/Grand_Duke%27s_Official_Birthday + * + * @throws InvalidDateException + * @throws \InvalidArgumentException + * @throws UnknownLocaleException + * @throws \Exception + */ + public function calculateNationalDay(): void + { + $this->addHoliday(new Holiday('nationalDay', [ + 'en_US' => 'National day', + 'fr_FR' => 'La Fête nationale', + 'lu' => 'La Fête nationale', + ], new DateTime("$this->year-6-23", new DateTimeZone($this->timezone)), $this->locale)); + } +} diff --git a/src/Yasumi/data/translations/allSaintsDay.php b/src/Yasumi/data/translations/allSaintsDay.php index 84a4aba10..f5e6fc5c3 100755 --- a/src/Yasumi/data/translations/allSaintsDay.php +++ b/src/Yasumi/data/translations/allSaintsDay.php @@ -26,6 +26,7 @@ 'it' => 'Festa di Tutti i Santi', 'it_CH' => 'Ognissanti', 'lt' => 'Visų šventųjų diena (Vėlinės)', + 'lu' => 'Toussaint', 'nl' => 'Allerheiligen', 'pl' => 'Uroczystość Wszystkich Świętych', 'pt' => 'Dia de todos os Santos', diff --git a/src/Yasumi/data/translations/ascensionDay.php b/src/Yasumi/data/translations/ascensionDay.php index ecf9ff78e..ee10b670d 100644 --- a/src/Yasumi/data/translations/ascensionDay.php +++ b/src/Yasumi/data/translations/ascensionDay.php @@ -21,6 +21,7 @@ 'fi' => 'Helatorstai', 'fr' => 'Ascension', 'it' => 'Ascensione', + 'lu' => 'Ascension', 'nb' => 'Kristi himmelfartsdag', 'nl' => 'Hemelvaart', 'sv' => 'Kristi himmelsfärdsdag', diff --git a/src/Yasumi/data/translations/assumptionOfMary.php b/src/Yasumi/data/translations/assumptionOfMary.php index b18af1ceb..e61d5895c 100755 --- a/src/Yasumi/data/translations/assumptionOfMary.php +++ b/src/Yasumi/data/translations/assumptionOfMary.php @@ -23,6 +23,7 @@ 'it' => 'Assunzione di Maria Vergine', 'it_CH' => 'Assunzione', 'lt' => 'Žolinė (Švč. Mergelės Marijos ėmimo į dangų diena)', + 'lu' => 'Assomption', 'nl' => 'Onze Lieve Vrouw hemelvaart', 'pl' => 'Wniebowzięcie Najświętszej Marii Panny', 'pt' => 'Assunção de Nossa Senhora', diff --git a/src/Yasumi/data/translations/christmasDay.php b/src/Yasumi/data/translations/christmasDay.php index e9130bbaf..9c4ffcf0e 100755 --- a/src/Yasumi/data/translations/christmasDay.php +++ b/src/Yasumi/data/translations/christmasDay.php @@ -33,6 +33,7 @@ 'it' => 'Natale', 'ko' => '기독탄신일', 'lt' => 'Šv. Kalėdos', + 'lu' => 'Noël', 'lv' => 'Ziemassvētki', 'nb' => 'første juledag', 'nl' => 'eerste kerstdag', diff --git a/src/Yasumi/data/translations/easterMonday.php b/src/Yasumi/data/translations/easterMonday.php index a4603bb46..be4f3adb8 100644 --- a/src/Yasumi/data/translations/easterMonday.php +++ b/src/Yasumi/data/translations/easterMonday.php @@ -29,6 +29,7 @@ 'it' => 'Lunedì dell’Angelo', 'it_CH' => 'Lunedi di Pasqua', 'lt' => 'Antroji Velykų diena', + 'lu' => 'Lundi de Pâques', 'lv' => 'Otrās Lieldienas', 'nb' => 'andre påskedag', 'nl_BE' => 'paasmaandag', diff --git a/src/Yasumi/data/translations/internationalWorkersDay.php b/src/Yasumi/data/translations/internationalWorkersDay.php index b3ef5a30a..7cc183d3a 100755 --- a/src/Yasumi/data/translations/internationalWorkersDay.php +++ b/src/Yasumi/data/translations/internationalWorkersDay.php @@ -33,6 +33,7 @@ 'ja' => '労働の日', 'ko' => '노동절', 'lt' => 'Tarptautinė darbo diena', + 'lu' => 'Fête du Travail', 'lv' => 'Darba svētki', 'nb' => 'arbeidernes dag', 'nl' => 'Dag van de arbeid', diff --git a/src/Yasumi/data/translations/newYearsDay.php b/src/Yasumi/data/translations/newYearsDay.php index 5cfa6dc96..495d8e4c5 100755 --- a/src/Yasumi/data/translations/newYearsDay.php +++ b/src/Yasumi/data/translations/newYearsDay.php @@ -34,6 +34,7 @@ 'ja' => '元日', 'ko' => '새해', 'lt' => 'Naujųjų metų diena', + 'lu' => 'Jour de l\'An', 'lv' => 'Jaunais Gads', 'nb' => 'første nyttårsdag', 'nl' => 'Nieuwjaar', diff --git a/src/Yasumi/data/translations/pentecostMonday.php b/src/Yasumi/data/translations/pentecostMonday.php index 4c83c14f4..1f3dd85b8 100755 --- a/src/Yasumi/data/translations/pentecostMonday.php +++ b/src/Yasumi/data/translations/pentecostMonday.php @@ -21,8 +21,9 @@ 'ga' => 'Luan Cincíse', 'hu' => 'Pünkösdhétfő', 'it' => 'Lunedi di Pentecoste', - 'nb' => 'andre pinsedag', - 'nl' => 'tweede pinksterdag', - 'nl_BE' => 'pinkstermaandag', + 'lu' => 'Lundi de Pentecôte', + 'nb' => 'Andre pinsedag', + 'nl' => 'Tweede pinksterdag', + 'nl_BE' => 'Pinkstermaandag', 'ro' => 'A doua zi de Rusalii', ]; diff --git a/src/Yasumi/data/translations/secondChristmasDay.php b/src/Yasumi/data/translations/secondChristmasDay.php index 763cb84c1..e080bfb7e 100755 --- a/src/Yasumi/data/translations/secondChristmasDay.php +++ b/src/Yasumi/data/translations/secondChristmasDay.php @@ -27,6 +27,7 @@ 'hu' => 'Karácsony másnapja', 'ko' => '성탄절 연휴', 'lt' => 'Kalėdos (antra diena)', + 'lu' => 'Lendemain de Noël', 'lv' => 'Otrie Ziemassvētki', 'nb' => 'andre juledag', 'nl' => 'tweede kerstdag', diff --git a/tests/Luxembourg/AllSaintsDayTest.php b/tests/Luxembourg/AllSaintsDayTest.php new file mode 100644 index 000000000..719868284 --- /dev/null +++ b/tests/Luxembourg/AllSaintsDayTest.php @@ -0,0 +1,79 @@ + + */ + +namespace Yasumi\tests\Luxembourg; + +use DateTime; +use Exception; +use ReflectionException; +use Yasumi\Holiday; +use Yasumi\tests\YasumiTestCaseInterface; + +/** + * Class for testing All Saints' Day in Luxembourg. + */ +class AllSaintsDayTest extends LuxembourgBaseTestCase implements YasumiTestCaseInterface +{ + /** + * The name of the holiday + */ + public const HOLIDAY = 'allSaintsDay'; + + /** + * Tests All Saints' Day. + * + * @dataProvider AllSaintsDayDataProvider + * + * @param int $year the year for which All Saints' Day needs to be tested + * @param DateTime $expected the expected date + * + * @throws ReflectionException + */ + public function testAllSaintsDay($year, $expected) + { + $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected); + } + + /** + * Tests translated name of All Saints' Day. + * @throws ReflectionException + */ + public function testTranslation(): void + { + $this->assertTranslatedHolidayName( + self::REGION, + self::HOLIDAY, + $this->generateRandomYear(), + [self::LOCALE => 'Toussaint'] + ); + } + + /** + * Tests type of the holiday defined in this test. + * @throws ReflectionException + */ + public function testHolidayType(): void + { + $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL); + } + + /** + * Returns a list of random test dates used for assertion of All Saints' Day. + * + * @return array list of test dates for All Saints' Day + * @throws Exception + */ + public function AllSaintsDayDataProvider(): array + { + return $this->generateRandomDates(11, 1, self::TIMEZONE); + } +} diff --git a/tests/Luxembourg/AscensionDayTest.php b/tests/Luxembourg/AscensionDayTest.php new file mode 100644 index 000000000..8fdbf386e --- /dev/null +++ b/tests/Luxembourg/AscensionDayTest.php @@ -0,0 +1,70 @@ + + */ + +namespace Yasumi\tests\Luxembourg; + +use DateTime; +use DateTimeZone; +use Exception; +use ReflectionException; +use Yasumi\Holiday; +use Yasumi\tests\YasumiTestCaseInterface; + +/** + * Class for testing Ascension Day in Luxembourg. + */ +class AscensionDayTest extends LuxembourgBaseTestCase implements YasumiTestCaseInterface +{ + /** + * The name of the holiday + */ + public const HOLIDAY = 'ascensionDay'; + + /** + * Tests Ascension Day. + * @throws Exception + * @throws ReflectionException + */ + public function testAscensionDay() + { + $year = 1901; + $this->assertHoliday( + self::REGION, + self::HOLIDAY, + $year, + new DateTime("$year-5-16", new DateTimeZone(self::TIMEZONE)) + ); + } + + /** + * Tests translated name of Ascension Day. + * @throws ReflectionException + */ + public function testTranslation(): void + { + $this->assertTranslatedHolidayName( + self::REGION, + self::HOLIDAY, + $this->generateRandomYear(), + [self::LOCALE => 'Ascension'] + ); + } + + /** + * Tests type of the holiday defined in this test. + * @throws ReflectionException + */ + public function testHolidayType(): void + { + $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL); + } +} diff --git a/tests/Luxembourg/AssumptionOfMaryTest.php b/tests/Luxembourg/AssumptionOfMaryTest.php new file mode 100644 index 000000000..277483f6e --- /dev/null +++ b/tests/Luxembourg/AssumptionOfMaryTest.php @@ -0,0 +1,79 @@ + + */ + +namespace Yasumi\tests\Luxembourg; + +use DateTime; +use Exception; +use ReflectionException; +use Yasumi\Holiday; +use Yasumi\tests\YasumiTestCaseInterface; + +/** + * Class for testing the day of the Assumption of Mary in Luxembourg. + */ +class AssumptionOfMaryTest extends LuxembourgBaseTestCase implements YasumiTestCaseInterface +{ + /** + * The name of the holiday to be tested + */ + public const HOLIDAY = 'assumptionOfMary'; + + /** + * Tests the holiday defined in this test. + * + * @dataProvider HolidayDataProvider + * + * @param int $year the year for which the holiday defined in this test needs to be tested + * @param DateTime $expected the expected date + * + * @throws ReflectionException + */ + public function testHoliday($year, $expected) + { + $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected); + } + + /** + * Returns a list of random test dates used for assertion of the holiday defined in this test + * + * @return array list of test dates for the holiday defined in this test + * @throws Exception + */ + public function HolidayDataProvider(): array + { + return $this->generateRandomDates(8, 15, self::TIMEZONE); + } + + /** + * Tests the translated name of the holiday defined in this test. + * @throws ReflectionException + */ + public function testTranslation(): void + { + $this->assertTranslatedHolidayName( + self::REGION, + self::HOLIDAY, + $this->generateRandomYear(), + [self::LOCALE => 'Assomption'] + ); + } + + /** + * Tests type of the holiday defined in this test. + * @throws ReflectionException + */ + public function testHolidayType(): void + { + $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL); + } +} diff --git a/tests/Luxembourg/ChristmasDayTest.php b/tests/Luxembourg/ChristmasDayTest.php new file mode 100644 index 000000000..1b242dca9 --- /dev/null +++ b/tests/Luxembourg/ChristmasDayTest.php @@ -0,0 +1,79 @@ + + */ + +namespace Yasumi\tests\Luxembourg; + +use DateTime; +use Exception; +use ReflectionException; +use Yasumi\Holiday; +use Yasumi\tests\YasumiTestCaseInterface; + +/** + * Class for testing Christmas in Luxembourg. + */ +class ChristmasDayTest extends LuxembourgBaseTestCase implements YasumiTestCaseInterface +{ + /** + * The name of the holiday + */ + public const HOLIDAY = 'christmasDay'; + + /** + * Tests Christmas Day. + * + * @dataProvider ChristmasDayDataProvider + * + * @param int $year the year for which Christmas Day needs to be tested + * @param DateTime $expected the expected date + * + * @throws ReflectionException + */ + public function testChristmasDay($year, $expected) + { + $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected); + } + + /** + * Returns a list of random test dates used for assertion of Christmas Day. + * + * @return array list of test dates for Christmas Day + * @throws Exception + */ + public function ChristmasDayDataProvider(): array + { + return $this->generateRandomDates(12, 25, self::TIMEZONE); + } + + /** + * Tests translated name of Christmas Day. + * @throws ReflectionException + */ + public function testTranslation(): void + { + $this->assertTranslatedHolidayName( + self::REGION, + self::HOLIDAY, + $this->generateRandomYear(), + [self::LOCALE => 'Noël'] + ); + } + + /** + * Tests type of the holiday defined in this test. + * @throws ReflectionException + */ + public function testHolidayType(): void + { + $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL); + } +} diff --git a/tests/Luxembourg/EasterMondayTest.php b/tests/Luxembourg/EasterMondayTest.php new file mode 100644 index 000000000..a9e5b3bb8 --- /dev/null +++ b/tests/Luxembourg/EasterMondayTest.php @@ -0,0 +1,70 @@ + + */ + +namespace Yasumi\tests\Luxembourg; + +use DateTime; +use DateTimeZone; +use Exception; +use ReflectionException; +use Yasumi\Holiday; +use Yasumi\tests\YasumiTestCaseInterface; + +/** + * Class containing tests for Easter Monday in Luxembourg. + */ +class EasterMondayTest extends LuxembourgBaseTestCase implements YasumiTestCaseInterface +{ + /** + * The name of the holiday + */ + public const HOLIDAY = 'easterMonday'; + + /** + * Tests Easter Monday. + * @throws Exception + * @throws ReflectionException + */ + public function testEasterMonday() + { + $year = 2016; + $this->assertHoliday( + self::REGION, + self::HOLIDAY, + $year, + new DateTime("$year-3-28", new DateTimeZone(self::TIMEZONE)) + ); + } + + /** + * Tests translated name of Easter Monday. + * @throws ReflectionException + */ + public function testTranslation(): void + { + $this->assertTranslatedHolidayName( + self::REGION, + self::HOLIDAY, + $this->generateRandomYear(), + [self::LOCALE => 'Lundi de Pâques'] + ); + } + + /** + * Tests type of the holiday defined in this test. + * @throws ReflectionException + */ + public function testHolidayType(): void + { + $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL); + } +} diff --git a/tests/Luxembourg/EuropeDayTest.php b/tests/Luxembourg/EuropeDayTest.php new file mode 100644 index 000000000..3836f8f67 --- /dev/null +++ b/tests/Luxembourg/EuropeDayTest.php @@ -0,0 +1,93 @@ + + */ + +namespace Yasumi\tests\Luxembourg; + +use DateTime; +use DateTimeZone; +use Exception; +use ReflectionException; +use Yasumi\Holiday; +use Yasumi\tests\YasumiTestCaseInterface; + +/** + * Class containing tests for Europe Day in Luxembourg. + */ +class EuropeDayTest extends LuxembourgBaseTestCase implements YasumiTestCaseInterface +{ + /** + * The name of the holiday + */ + public const HOLIDAY = 'europeDay'; + + /** + * The year in which the holiday was first established + */ + public const ESTABLISHMENT_YEAR = 2019; + + /** + * Tests Europe Day on or after 2019. + * @throws Exception + * @throws ReflectionException + */ + public function testEuropeDayOnAfter2019() + { + $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR); + $this->assertHoliday( + self::REGION, + self::HOLIDAY, + $year, + new DateTime("$year-5-9", new DateTimeZone(self::TIMEZONE)) + ); + } + + /** + * Tests Europe Day before 2019. + * @throws ReflectionException + */ + public function testEuropeDayBefore2019() + { + $this->assertNotHoliday( + self::REGION, + self::HOLIDAY, + $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1) + ); + } + + /** + * Tests translated name of Europe Day. + * @throws ReflectionException + */ + public function testTranslation(): void + { + $this->assertTranslatedHolidayName( + self::REGION, + self::HOLIDAY, + $this->generateRandomYear(self::ESTABLISHMENT_YEAR), + [self::LOCALE => 'La Journée de l\'Europe'] + ); + } + + /** + * Tests type of the holiday defined in this test. + * @throws ReflectionException + */ + public function testHolidayType(): void + { + $this->assertHolidayType( + self::REGION, + self::HOLIDAY, + $this->generateRandomYear(self::ESTABLISHMENT_YEAR), + Holiday::TYPE_OFFICIAL + ); + } +} diff --git a/tests/Luxembourg/InternationalWorkersDayTest.php b/tests/Luxembourg/InternationalWorkersDayTest.php new file mode 100644 index 000000000..735de22c2 --- /dev/null +++ b/tests/Luxembourg/InternationalWorkersDayTest.php @@ -0,0 +1,79 @@ + + */ + +namespace Yasumi\tests\Luxembourg; + +use DateTime; +use Exception; +use ReflectionException; +use Yasumi\Holiday; +use Yasumi\tests\YasumiTestCaseInterface; + +/** + * Class containing tests for International Workers' Day (i.e. Labour Day) in Luxembourg. + */ +class InternationalWorkersDayTest extends LuxembourgBaseTestCase implements YasumiTestCaseInterface +{ + /** + * The name of the holiday + */ + public const HOLIDAY = 'internationalWorkersDay'; + + /** + * Tests International Workers' Day. + * + * @dataProvider InternationalWorkersDayDataProvider + * + * @param int $year the year for which International Workers' Day needs to be tested + * @param DateTime $expected the expected date + * + * @throws ReflectionException + */ + public function testInternationalWorkersDay($year, $expected) + { + $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected); + } + + /** + * Tests translated name of International Workers' Day. + * @throws ReflectionException + */ + public function testTranslation(): void + { + $this->assertTranslatedHolidayName( + self::REGION, + self::HOLIDAY, + $this->generateRandomYear(), + [self::LOCALE => 'Fête du Travail'] + ); + } + + /** + * Tests type of the holiday defined in this test. + * @throws ReflectionException + */ + public function testHolidayType(): void + { + $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL); + } + + /** + * Returns a list of random test dates used for assertion of International Workers' Day. + * + * @return array list of test dates for International Workers' Day + * @throws Exception + */ + public function InternationalWorkersDayDataProvider(): array + { + return $this->generateRandomDates(5, 1, self::TIMEZONE); + } +} diff --git a/tests/Luxembourg/LuxembourgBaseTestCase.php b/tests/Luxembourg/LuxembourgBaseTestCase.php new file mode 100644 index 000000000..12474f1f8 --- /dev/null +++ b/tests/Luxembourg/LuxembourgBaseTestCase.php @@ -0,0 +1,39 @@ + + */ + +namespace Yasumi\tests\Luxembourg; + +use PHPUnit\Framework\TestCase; +use Yasumi\tests\YasumiBase; + +/** + * Base class for test cases of the France holiday provider. + */ +abstract class LuxembourgBaseTestCase extends TestCase +{ + use YasumiBase; + + /** + * Country (name) to be tested + */ + public const REGION = 'Luxembourg'; + + /** + * Timezone in which this provider has holidays defined + */ + public const TIMEZONE = 'Europe/Luxembourg'; + + /** + * Locale that is considered common for this provider + */ + public const LOCALE = 'lu'; +} diff --git a/tests/Luxembourg/LuxembourgTest.php b/tests/Luxembourg/LuxembourgTest.php new file mode 100644 index 000000000..ab5727d76 --- /dev/null +++ b/tests/Luxembourg/LuxembourgTest.php @@ -0,0 +1,92 @@ + + */ + +namespace Yasumi\tests\Luxembourg; + +use ReflectionException; +use Yasumi\Holiday; +use Yasumi\Provider\Luxembourg; + +/** + * Class for testing holidays in Luxembourg. + */ +class LuxembourgTest extends LuxembourgBaseTestCase +{ + /** + * @var int year random year number used for all tests in this Test Case + */ + protected $year; + + /** + * Tests if all official holidays in Luxembourg are defined by the provider class + * @throws ReflectionException + */ + public function testOfficialHolidays(): void + { + $holidays = [ + 'newYearsDay', + 'easterMonday', + 'internationalWorkersDay', + 'ascensionDay', + 'pentecostMonday', + 'nationalDay', + 'assumptionOfMary', + 'allSaintsDay', + 'christmasDay', + 'secondChristmasDay', + ]; + + $year = $this->generateRandomYear(); + + if ($year >= Luxembourg::EUROPE_DAY_START_YEAR) { + $holidays[] = 'europeDay'; + } + + $this->assertDefinedHolidays($holidays, self::REGION, $year, Holiday::TYPE_OFFICIAL); + } + + /** + * Tests if all observed holidays in Luxembourg are defined by the provider class + * @throws ReflectionException + */ + public function testObservedHolidays(): void + { + $this->assertDefinedHolidays([], self::REGION, $this->generateRandomYear(), Holiday::TYPE_OBSERVANCE); + } + + /** + * Tests if all seasonal holidays in Luxembourg are defined by the provider class + * @throws ReflectionException + */ + public function testSeasonalHolidays(): void + { + $this->assertDefinedHolidays([], self::REGION, $this->generateRandomYear(), Holiday::TYPE_SEASON); + } + + /** + * Tests if all bank holidays in Luxembourg are defined by the provider class + * @throws ReflectionException + */ + public function testBankHolidays(): void + { + $this->assertDefinedHolidays([], self::REGION, $this->generateRandomYear(), Holiday::TYPE_BANK); + } + + /** + * Tests if all other holidays in Luxembourg are defined by the provider class + * @throws ReflectionException + */ + public function testOtherHolidays(): void + { + $this->assertDefinedHolidays([], self::REGION, $this->generateRandomYear(), Holiday::TYPE_OTHER); + } +} diff --git a/tests/Luxembourg/NationalDayTest.php b/tests/Luxembourg/NationalDayTest.php new file mode 100644 index 000000000..4103f8787 --- /dev/null +++ b/tests/Luxembourg/NationalDayTest.php @@ -0,0 +1,79 @@ + + */ + +namespace Yasumi\tests\Luxembourg; + +use DateTime; +use Exception; +use ReflectionException; +use Yasumi\Holiday; +use Yasumi\tests\YasumiTestCaseInterface; + +/** + * Class for testing the National Day of Luxembourg. + */ +class NationalDayTest extends LuxembourgBaseTestCase implements YasumiTestCaseInterface +{ + /** + * The name of the holiday to be tested + */ + public const HOLIDAY = 'nationalDay'; + + /** + * Tests the holiday defined in this test. + * + * @dataProvider HolidayDataProvider + * + * @param int $year the year for which the holiday defined in this test needs to be tested + * @param DateTime $expected the expected date + * + * @throws ReflectionException + */ + public function testHoliday($year, $expected) + { + $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected); + } + + /** + * Returns a list of random test dates used for assertion of the holiday defined in this test + * + * @return array list of test dates for the holiday defined in this test + * @throws Exception + */ + public function HolidayDataProvider(): array + { + return $this->generateRandomDates(6, 23, self::TIMEZONE); + } + + /** + * Tests the translated name of the holiday defined in this test. + * @throws ReflectionException + */ + public function testTranslation(): void + { + $this->assertTranslatedHolidayName( + self::REGION, + self::HOLIDAY, + $this->generateRandomYear(), + [self::LOCALE => 'La Fête nationale'] + ); + } + + /** + * Tests type of the holiday defined in this test. + * @throws ReflectionException + */ + public function testHolidayType(): void + { + $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL); + } +} diff --git a/tests/Luxembourg/NewYearsDayTest.php b/tests/Luxembourg/NewYearsDayTest.php new file mode 100644 index 000000000..97d3cbf5f --- /dev/null +++ b/tests/Luxembourg/NewYearsDayTest.php @@ -0,0 +1,79 @@ + + */ + +namespace Yasumi\tests\Luxembourg; + +use DateTime; +use Exception; +use ReflectionException; +use Yasumi\Holiday; +use Yasumi\tests\YasumiTestCaseInterface; + +/** + * Class containing tests for New Years Day in France. + */ +class NewYearsDayTest extends LuxembourgBaseTestCase implements YasumiTestCaseInterface +{ + /** + * The name of the holiday + */ + public const HOLIDAY = 'newYearsDay'; + + /** + * Tests New Years Day. + * + * @dataProvider NewYearsDayDataProvider + * + * @param int $year the year for which New Years Day needs to be tested + * @param DateTime $expected the expected date + * + * @throws ReflectionException + */ + public function testNewYearsDay($year, $expected) + { + $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected); + } + + /** + * Tests translated name of New Years Day. + * @throws ReflectionException + */ + public function testTranslation(): void + { + $this->assertTranslatedHolidayName( + self::REGION, + self::HOLIDAY, + $this->generateRandomYear(), + [self::LOCALE => 'Jour de l\'An'] + ); + } + + /** + * Tests type of the holiday defined in this test. + * @throws ReflectionException + */ + public function testHolidayType(): void + { + $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL); + } + + /** + * Returns a list of random test dates used for assertion of New Years Day. + * + * @return array list of test dates for New Years Day + * @throws Exception + */ + public function NewYearsDayDataProvider(): array + { + return $this->generateRandomDates(1, 1, self::TIMEZONE); + } +} diff --git a/tests/Luxembourg/PentecostMondayTest.php b/tests/Luxembourg/PentecostMondayTest.php new file mode 100644 index 000000000..7a86a32a2 --- /dev/null +++ b/tests/Luxembourg/PentecostMondayTest.php @@ -0,0 +1,70 @@ + + */ + +namespace Yasumi\tests\Luxembourg; + +use DateTime; +use DateTimeZone; +use Exception; +use ReflectionException; +use Yasumi\Holiday; +use Yasumi\tests\YasumiTestCaseInterface; + +/** + * Class for testing Pentecost Monday in Luxembourg. + */ +class PentecostMondayTest extends LuxembourgBaseTestCase implements YasumiTestCaseInterface +{ + /** + * The name of the holiday + */ + public const HOLIDAY = 'pentecostMonday'; + + /** + * Tests Pentecost Monday. + * @throws Exception + * @throws ReflectionException + */ + public function testPentecostMonday() + { + $year = 1977; + $this->assertHoliday( + self::REGION, + self::HOLIDAY, + $year, + new DateTime("$year-5-30", new DateTimeZone(self::TIMEZONE)) + ); + } + + /** + * Tests translated name of Pentecost Monday. + * @throws ReflectionException + */ + public function testTranslation(): void + { + $this->assertTranslatedHolidayName( + self::REGION, + self::HOLIDAY, + $this->generateRandomYear(), + [self::LOCALE => 'Lundi de Pentecôte'] + ); + } + + /** + * Tests type of the holiday defined in this test. + * @throws ReflectionException + */ + public function testHolidayType(): void + { + $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL); + } +} diff --git a/tests/Luxembourg/SecondChristmasDayTest.php b/tests/Luxembourg/SecondChristmasDayTest.php new file mode 100644 index 000000000..297f0831c --- /dev/null +++ b/tests/Luxembourg/SecondChristmasDayTest.php @@ -0,0 +1,79 @@ + + */ + +namespace Yasumi\tests\Luxembourg; + +use DateTime; +use Exception; +use ReflectionException; +use Yasumi\Holiday; +use Yasumi\tests\YasumiTestCaseInterface; + +/** + * Class for testing the Second Christmas Day in Luxembourg. + */ +class SecondChristmasDayTest extends LuxembourgBaseTestCase implements YasumiTestCaseInterface +{ + /** + * The name of the holiday to be tested + */ + public const HOLIDAY = 'secondChristmasDay'; + + /** + * Tests the holiday defined in this test. + * + * @dataProvider HolidayDataProvider + * + * @param int $year the year for which the holiday defined in this test needs to be tested + * @param DateTime $expected the expected date + * + * @throws ReflectionException + */ + public function testHoliday($year, $expected) + { + $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected); + } + + /** + * Returns a list of random test dates used for assertion of the holiday defined in this test + * + * @return array list of test dates for the holiday defined in this test + * @throws Exception + */ + public function HolidayDataProvider(): array + { + return $this->generateRandomDates(12, 26, self::TIMEZONE); + } + + /** + * Tests the translated name of the holiday defined in this test. + * @throws ReflectionException + */ + public function testTranslation(): void + { + $this->assertTranslatedHolidayName( + self::REGION, + self::HOLIDAY, + $this->generateRandomYear(), + [self::LOCALE => 'Lendemain de Noël'] + ); + } + + /** + * Tests type of the holiday defined in this test. + * @throws ReflectionException + */ + public function testHolidayType(): void + { + $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL); + } +}