Skip to content

Commit

Permalink
Feature/all souls day Lithuania
Browse files Browse the repository at this point in the history
  • Loading branch information
norkunas committed Jun 16, 2020
1 parent 94cca6b commit fe0c46f
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 1 deletion.
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);
}
}

0 comments on commit fe0c46f

Please sign in to comment.