diff --git a/CHANGELOG.md b/CHANGELOG.md index 62d681ff9..c532cc0d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/) and this ## [Unreleased] ### Added +- Added All Souls Day to Lithuania [\#227](https://github.com/azuyalabs/yasumi/pull/227) - Added New Years Eve to Germany [\#226](https://github.com/azuyalabs/yasumi/pull/226) - Added Canada Provider [\#215](https://github.com/azuyalabs/yasumi/pull/215) ([lux](https://github.com/lux)) - Added Luxembourg Provider [\#205](https://github.com/azuyalabs/yasumi/pull/205) ([Arkounay](https://github.com/Arkounay)) diff --git a/src/Yasumi/Provider/Brazil.php b/src/Yasumi/Provider/Brazil.php index 849691df7..cf673bc90 100644 --- a/src/Yasumi/Provider/Brazil.php +++ b/src/Yasumi/Provider/Brazil.php @@ -149,7 +149,7 @@ public function initialize(): void if ($this->year >= 1300) { $this->addHoliday(new Holiday( 'allSoulsDay', - ['pt' => 'Dia de Finados'], + [], new DateTime("$this->year-11-02", DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale )); diff --git a/src/Yasumi/Provider/Lithuania.php b/src/Yasumi/Provider/Lithuania.php index 5e22074d5..50d9ab11e 100644 --- a/src/Yasumi/Provider/Lithuania.php +++ b/src/Yasumi/Provider/Lithuania.php @@ -45,6 +45,11 @@ class Lithuania extends AbstractProvider */ public const STATEHOOD_YEAR = 1253; + /** + * The year when All Souls Day became a holiday + */ + public const ALL_SOULS_DAY = 2020; + /** * Initialize holidays for Lithuania. * @@ -66,6 +71,7 @@ public function initialize(): void $this->addStatehoodDay(); $this->addHoliday($this->assumptionOfMary($this->year, $this->timezone, $this->locale)); $this->addHoliday($this->allSaintsDay($this->year, $this->timezone, $this->locale)); + $this->addAllSoulsDay(); $this->addHoliday($this->christmasEve($this->year, $this->timezone, $this->locale, Holiday::TYPE_OFFICIAL)); $this->addHoliday($this->christmasDay($this->year, $this->timezone, $this->locale)); $this->addHoliday($this->secondChristmasDay($this->year, $this->timezone, $this->locale)); @@ -119,4 +125,22 @@ private function addStatehoodDay(): void ], new \DateTime("{$this->year}-07-06", new \DateTimeZone($this->timezone)), $this->locale)); } } + + /** + * All Souls Day, also known as the Commemoration of All the Faithful Departed and the Day of the Dead. + * + * @throws \InvalidArgumentException + * @throws \Exception + */ + private function addAllSoulsDay(): void + { + if ($this->year >= self::ALL_SOULS_DAY) { + $this->addHoliday(new Holiday( + 'allSoulsDay', + [], + new \DateTime("$this->year-11-02", DateTimeZoneFactory::getDateTimeZone($this->timezone)), + $this->locale + )); + } + } } diff --git a/src/Yasumi/data/translations/allSoulsDay.php b/src/Yasumi/data/translations/allSoulsDay.php new file mode 100644 index 000000000..ea4d511c2 --- /dev/null +++ b/src/Yasumi/data/translations/allSoulsDay.php @@ -0,0 +1,19 @@ + + */ + +// Translations for All Souls' Day +return [ + 'en' => 'All Souls’ Day', + 'lt' => 'Vėlinės', + 'pt' => 'Dia de Finados', +]; diff --git a/tests/Lithuania/AllSoulsDayTest.php b/tests/Lithuania/AllSoulsDayTest.php new file mode 100644 index 000000000..900cec508 --- /dev/null +++ b/tests/Lithuania/AllSoulsDayTest.php @@ -0,0 +1,87 @@ + + */ + +namespace Yasumi\tests\Lithuania; + +use DateTime; +use DateTimeZone; +use Exception; +use ReflectionException; +use Yasumi\Holiday; +use Yasumi\Provider\Lithuania; +use Yasumi\tests\YasumiTestCaseInterface; + +/** + * Class containing tests for All Souls' Day in Lithuania. + * + * @author Tomas Norkūnas + */ +class AllSoulsDayTest extends LithuaniaBaseTestCase implements YasumiTestCaseInterface +{ + /** + * The name of the holiday to be tested + */ + public const HOLIDAY = 'allSoulsDay'; + + /** + * @throws ReflectionException + */ + public function testHolidayBeforeAnnounce(): void + { + $this->assertNotHoliday( + self::REGION, + self::HOLIDAY, + $this->generateRandomYear(1000, Lithuania::ALL_SOULS_DAY - 1) + ); + } + + /** + * Test if holiday is defined after restoration + * @throws Exception + * @throws ReflectionException + */ + public function testHolidayAfterAnnounce(): void + { + $year = $this->generateRandomYear(Lithuania::ALL_SOULS_DAY); + + $this->assertHoliday( + self::REGION, + self::HOLIDAY, + $year, + new DateTime("{$year}-11-02", new DateTimeZone(self::TIMEZONE)) + ); + } + + /** + * {@inheritdoc} + * @throws ReflectionException + */ + public function testTranslation(): void + { + $this->assertTranslatedHolidayName( + self::REGION, + self::HOLIDAY, + $this->generateRandomYear(), + [self::LOCALE => 'Vėlinės'] + ); + } + + /** + * {@inheritdoc} + * @throws ReflectionException + */ + public function testHolidayType(): void + { + $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL); + } +}