Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/all souls day Lithuania #227

Merged
merged 1 commit into from
Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion src/Yasumi/Provider/Brazil.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
));
Expand Down
24 changes: 24 additions & 0 deletions src/Yasumi/Provider/Lithuania.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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));
Expand Down Expand Up @@ -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
));
}
}
}
19 changes: 19 additions & 0 deletions src/Yasumi/data/translations/allSoulsDay.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php declare(strict_types=1);

/**
* This file is part of the Yasumi package.
*
* Copyright (c) 2015 - 2020 AzuyaLabs
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Sacha Telgenhof <[email protected]>
*/

// Translations for All Souls' Day
return [
'en' => 'All Souls’ Day',
'lt' => 'Vėlinės',
'pt' => 'Dia de Finados',
];
87 changes: 87 additions & 0 deletions tests/Lithuania/AllSoulsDayTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php declare(strict_types=1);

/**
* This file is part of the Yasumi package.
*
* Copyright (c) 2015 - 2020 AzuyaLabs
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Sacha Telgenhof <[email protected]>
*/

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 <[email protected]>
*/
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);
}
}