From 92b18b677f81ceb84793e3816392527574c3590f Mon Sep 17 00:00:00 2001 From: Yannick Ihmels Date: Mon, 6 Mar 2023 12:56:49 +0100 Subject: [PATCH 1/8] Add International Womens Day to DE-MV --- src/Yasumi/Provider/Germany/MecklenburgWesternPomerania.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Yasumi/Provider/Germany/MecklenburgWesternPomerania.php b/src/Yasumi/Provider/Germany/MecklenburgWesternPomerania.php index 7809fbdf2..7d322b753 100644 --- a/src/Yasumi/Provider/Germany/MecklenburgWesternPomerania.php +++ b/src/Yasumi/Provider/Germany/MecklenburgWesternPomerania.php @@ -45,6 +45,10 @@ class MecklenburgWesternPomerania extends Germany public function initialize(): void { parent::initialize(); + + if ($this->year >= 2023) { + $this->addHoliday($this->internationalWomensDay($this->year, $this->timezone, $this->locale)); + } // Add custom Christian holidays $this->calculateReformationDay(); From b54ce70b7fed71e6a53aa736eac2f29af05a2fa2 Mon Sep 17 00:00:00 2001 From: Yannick Ihmels Date: Tue, 7 Mar 2023 09:02:23 +0100 Subject: [PATCH 2/8] Remove whitespace in empty line --- src/Yasumi/Provider/Germany/MecklenburgWesternPomerania.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Yasumi/Provider/Germany/MecklenburgWesternPomerania.php b/src/Yasumi/Provider/Germany/MecklenburgWesternPomerania.php index 7d322b753..3d4de0fa8 100644 --- a/src/Yasumi/Provider/Germany/MecklenburgWesternPomerania.php +++ b/src/Yasumi/Provider/Germany/MecklenburgWesternPomerania.php @@ -45,7 +45,7 @@ class MecklenburgWesternPomerania extends Germany public function initialize(): void { parent::initialize(); - + if ($this->year >= 2023) { $this->addHoliday($this->internationalWomensDay($this->year, $this->timezone, $this->locale)); } From a3693b290f8a6a16b1d6c5eddf41770626562350 Mon Sep 17 00:00:00 2001 From: Yannick Ihmels Date: Tue, 11 Jul 2023 08:58:15 +0200 Subject: [PATCH 3/8] Add test --- .../InternationalWomensDayTest.php | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 tests/Germany/MecklenburgWesternPomerania/InternationalWomensDayTest.php diff --git a/tests/Germany/MecklenburgWesternPomerania/InternationalWomensDayTest.php b/tests/Germany/MecklenburgWesternPomerania/InternationalWomensDayTest.php new file mode 100644 index 000000000..729cec0f4 --- /dev/null +++ b/tests/Germany/MecklenburgWesternPomerania/InternationalWomensDayTest.php @@ -0,0 +1,103 @@ + + */ + +namespace Yasumi\tests\Germany\MecklenburgWesternPomerania; + +use Yasumi\Holiday; +use Yasumi\tests\HolidayTestCase; + +/** + * Class containing tests for International Womens Day in Mecklenburg–Western Pomerania, Germany. + */ +class InternationalWomensDayTest extends MecklenburgWesternPomeraniaBaseTestCase implements HolidayTestCase +{ + /** + * The name of the holiday to be tested. + */ + public const HOLIDAY = 'internationalWomensDay'; + + /** + * The year in which the holiday was established. + */ + public const ESTABLISHMENT_YEAR = 2023; + + /** + * Test the holiday defined in this test upon establishment. + * + * @throws \Exception + */ + public function testHolidayOnEstablishment(): void + { + $this->assertHoliday( + self::REGION, + self::HOLIDAY, + self::ESTABLISHMENT_YEAR, + new \DateTime(self::ESTABLISHMENT_YEAR.'-03-08', new \DateTimeZone(self::TIMEZONE)) + ); + } + + /** + * Test the holiday defined in this test before establishment. + * + * @throws \Exception + */ + public function testHolidayBeforeEstablishment(): void + { + $this->assertNotHoliday( + self::REGION, + self::HOLIDAY, + $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1) + ); + } + + /** + * Test the holiday defined in this test after completion. + * + * @throws \Exception + */ + public function testHolidayAfterCompletion(): void + { + $this->assertNotHoliday(self::REGION, self::HOLIDAY, $this->generateRandomYear(1900, self::ESTABLISHMENT_YEAR - 1)); + } + + /** + * Tests the translated name of the holiday defined in this test. + * + * @throws \Exception + */ + public function testTranslation(): void + { + $this->assertTranslatedHolidayName( + self::REGION, + self::HOLIDAY, + $this->generateRandomYear(self::ESTABLISHMENT_YEAR, self::ESTABLISHMENT_YEAR), + [self::LOCALE => 'Internationaler Frauentag'] + ); + } + + /** + * Tests type of the holiday defined in this test. + * + * @throws \Exception + */ + public function testHolidayType(): void + { + $this->assertHolidayType( + self::REGION, + self::HOLIDAY, + $this->generateRandomYear(self::ESTABLISHMENT_YEAR, self::ESTABLISHMENT_YEAR), + Holiday::TYPE_OFFICIAL + ); + } +} From bd5d210f507468107f605e803c4c8fd5a1414ff0 Mon Sep 17 00:00:00 2001 From: Yannick Ihmels Date: Thu, 13 Jul 2023 21:04:51 +0200 Subject: [PATCH 4/8] Add source --- .../Provider/Germany/MecklenburgWesternPomerania.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Yasumi/Provider/Germany/MecklenburgWesternPomerania.php b/src/Yasumi/Provider/Germany/MecklenburgWesternPomerania.php index 3d4de0fa8..3ce4ba8e0 100644 --- a/src/Yasumi/Provider/Germany/MecklenburgWesternPomerania.php +++ b/src/Yasumi/Provider/Germany/MecklenburgWesternPomerania.php @@ -54,6 +54,14 @@ public function initialize(): void $this->calculateReformationDay(); } + public function getSources(): array + { + return [ + 'https://www.ndr.de/nachrichten/mecklenburg-vorpommern/Frauentag-in-MV-Landtag-beschliesst-neuen-Feiertag,frauentag370.html', + ...parent::getSources(), + ]; + } + /** * For the German state of Mecklenburg-Western Pomerania, Reformation Day was celebrated since 1517. * Note: In 2017 all German states will celebrate Reformation Day for its 500th anniversary. From b8d990233da329f557e9c97e6d5062eddd2ada33 Mon Sep 17 00:00:00 2001 From: Yannick Ihmels Date: Sat, 15 Jul 2023 22:05:28 +0200 Subject: [PATCH 5/8] Fix return type hint --- src/Yasumi/ProviderInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Yasumi/ProviderInterface.php b/src/Yasumi/ProviderInterface.php index 693aab7c2..7033b5a95 100644 --- a/src/Yasumi/ProviderInterface.php +++ b/src/Yasumi/ProviderInterface.php @@ -34,7 +34,7 @@ public function initialize(): void; * Returns a list of sources (i.e. references to websites, books, scientific papers, etc.) that are * used for determining the calculation logic of the providers' holidays. * - * @return array a list of external sources (empty when no sources are defined) + * @return list a list of external sources (empty when no sources are defined) */ public function getSources(): array; From 851127b42464d83672cce7be7e22a2758796ec1d Mon Sep 17 00:00:00 2001 From: Yannick Ihmels Date: Mon, 7 Aug 2023 18:31:06 +0200 Subject: [PATCH 6/8] Use array_merge() for now --- .../Provider/Germany/MecklenburgWesternPomerania.php | 8 ++++---- src/Yasumi/ProviderInterface.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Yasumi/Provider/Germany/MecklenburgWesternPomerania.php b/src/Yasumi/Provider/Germany/MecklenburgWesternPomerania.php index 3ce4ba8e0..812443d6d 100644 --- a/src/Yasumi/Provider/Germany/MecklenburgWesternPomerania.php +++ b/src/Yasumi/Provider/Germany/MecklenburgWesternPomerania.php @@ -56,10 +56,10 @@ public function initialize(): void public function getSources(): array { - return [ - 'https://www.ndr.de/nachrichten/mecklenburg-vorpommern/Frauentag-in-MV-Landtag-beschliesst-neuen-Feiertag,frauentag370.html', - ...parent::getSources(), - ]; + return array_merge( + ['https://www.ndr.de/nachrichten/mecklenburg-vorpommern/Frauentag-in-MV-Landtag-beschliesst-neuen-Feiertag,frauentag370.html'], + parent::getSources(), + ); } /** diff --git a/src/Yasumi/ProviderInterface.php b/src/Yasumi/ProviderInterface.php index 7033b5a95..693aab7c2 100644 --- a/src/Yasumi/ProviderInterface.php +++ b/src/Yasumi/ProviderInterface.php @@ -34,7 +34,7 @@ public function initialize(): void; * Returns a list of sources (i.e. references to websites, books, scientific papers, etc.) that are * used for determining the calculation logic of the providers' holidays. * - * @return list a list of external sources (empty when no sources are defined) + * @return array a list of external sources (empty when no sources are defined) */ public function getSources(): array; From 0b8694f5de4b0976b6779f4ea71c91b9d0be06f3 Mon Sep 17 00:00:00 2001 From: Yannick Ihmels Date: Tue, 10 Oct 2023 19:23:11 +0200 Subject: [PATCH 7/8] Add type hint to file --- src/Yasumi/Yasumi.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Yasumi/Yasumi.php b/src/Yasumi/Yasumi.php index c2c98af91..b91ee9b7e 100644 --- a/src/Yasumi/Yasumi.php +++ b/src/Yasumi/Yasumi.php @@ -215,6 +215,7 @@ public static function getProviders(): array \FilesystemIterator::SKIP_DOTS ), \RecursiveIteratorIterator::SELF_FIRST); + /** @var \SplFileInfo $file */ foreach ($filesIterator as $file) { if ($file->isDir()) { continue; From d1e1c6a3eaa5cdb83a9cdc2cab62a8664798d149 Mon Sep 17 00:00:00 2001 From: Yannick Ihmels Date: Sun, 15 Oct 2023 15:52:18 +0200 Subject: [PATCH 8/8] Fix test --- .../MecklenburgWesternPomeraniaTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Germany/MecklenburgWesternPomerania/MecklenburgWesternPomeraniaTest.php b/tests/Germany/MecklenburgWesternPomerania/MecklenburgWesternPomeraniaTest.php index 7a3f7b160..b6445d3fe 100644 --- a/tests/Germany/MecklenburgWesternPomerania/MecklenburgWesternPomeraniaTest.php +++ b/tests/Germany/MecklenburgWesternPomerania/MecklenburgWesternPomeraniaTest.php @@ -102,6 +102,6 @@ public function testOtherHolidays(): void */ public function testSources(): void { - $this->assertSources(self::REGION, 2); + $this->assertSources(self::REGION, 3); } }