-
-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Holiday Provider for Lithuania (#67)
- Loading branch information
1 parent
ccbd9fe
commit 847c9ae
Showing
28 changed files
with
1,313 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Yasumi package. | ||
* | ||
* Copyright (c) 2015 - 2017 AzuyaLabs | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @author Sacha Telgenhof <stelgenhof@gmail.com> | ||
*/ | ||
|
||
namespace Yasumi\Provider; | ||
|
||
use Yasumi\Holiday; | ||
|
||
/** | ||
* Provider for all holidays in Lithuania. | ||
* | ||
* @author Gedas Lukošius <gedas@lukosius.me> | ||
*/ | ||
class Lithuania extends AbstractProvider | ||
{ | ||
use CommonHolidays, ChristianHolidays; | ||
|
||
/** | ||
* Code to identify this Holiday Provider. Typically this is the ISO3166 code corresponding to the respective | ||
* country or sub-region. | ||
*/ | ||
const ID = 'LT'; | ||
|
||
/** | ||
* The year when The Act of Reinstating Independence of Lithuania was signed. | ||
*/ | ||
const RESTORATION_OF_THE_STATE_YEAR = 1918; | ||
|
||
/** | ||
* The year when The Act of the Re-Establishment of the State of Lithuania was signed. | ||
*/ | ||
const RESTORATION_OF_INDEPENDENCE_YEAR = 1990; | ||
|
||
/** | ||
* A year when Mindaugas was crowned as the only King of Lithuania. | ||
*/ | ||
const STATEHOOD_YEAR = 1253; | ||
|
||
/** | ||
* Initialize holidays for Lithuania. | ||
* | ||
* @throws \InvalidArgumentException | ||
*/ | ||
public function initialize() | ||
{ | ||
$this->timezone = 'Europe/Vilnius'; | ||
|
||
// Official | ||
$this->addHoliday($this->newYearsDay($this->year, $this->timezone, $this->locale)); | ||
$this->addRestorationOfTheStateDay(); | ||
$this->addRestorationOfIndependenceDay(); | ||
$this->addHoliday($this->easter($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->addHoliday($this->stJohnsDay($this->year, $this->timezone, $this->locale)); | ||
$this->addStatehoodDay(); | ||
$this->addHoliday($this->assumptionOfMary($this->year, $this->timezone, $this->locale)); | ||
$this->addHoliday($this->allSaintsDay($this->year, $this->timezone, $this->locale)); | ||
$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)); | ||
} | ||
|
||
/** | ||
* The Act of Reinstating Independence of Lithuania was signed on February 16, 1918. | ||
* | ||
* @throws \InvalidArgumentException | ||
*/ | ||
private function addRestorationOfTheStateDay() | ||
{ | ||
if ($this->year >= self::RESTORATION_OF_THE_STATE_YEAR) { | ||
$this->addHoliday(new Holiday( | ||
'restorationOfTheStateOfLithuaniaDay', | ||
[ | ||
'en_US' => 'Day of Restoration of the State of Lithuania', | ||
'lt_LT' => 'Lietuvos valstybės atkūrimo diena' | ||
], | ||
new \DateTime("{$this->year}-02-16", new \DateTimeZone($this->timezone)) | ||
)); | ||
} | ||
} | ||
|
||
/** | ||
* The Act of the Re-Establishment of the State of Lithuania was signed on March 11, 1990. | ||
* | ||
* @throws \InvalidArgumentException | ||
*/ | ||
private function addRestorationOfIndependenceDay() | ||
{ | ||
if ($this->year >= self::RESTORATION_OF_INDEPENDENCE_YEAR) { | ||
$this->addHoliday(new Holiday( | ||
'restorationOfIndependenceOfLithuaniaDay', | ||
[ | ||
'en_US' => 'Day of Restoration of Independence of Lithuania', | ||
'lt_LT' => 'Lietuvos nepriklausomybės atkūrimo diena' | ||
], | ||
new \DateTime("{$this->year}-03-11", new \DateTimeZone($this->timezone)) | ||
)); | ||
} | ||
} | ||
|
||
/** | ||
* Statehood Day is an annual public holiday in Lithuania celebrated on July 6 to commemorate | ||
* the coronation in 1253 of Mindaugas as the only King of Lithuania. | ||
* | ||
* @throws \InvalidArgumentException | ||
*/ | ||
private function addStatehoodDay() | ||
{ | ||
if ($this->year >= self::STATEHOOD_YEAR) { | ||
$this->addHoliday(new Holiday( | ||
'statehoodDay', | ||
[ | ||
'en_US' => 'Statehood Day (Lithuania)', | ||
'lt_LT' => 'Valstybės (Lietuvos karaliaus Mindaugo karūnavimo) diena' | ||
], | ||
new \DateTime("{$this->year}-07-06", new \DateTimeZone($this->timezone)), | ||
$this->locale | ||
)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Yasumi package. | ||
* | ||
* Copyright (c) 2015 - 2017 AzuyaLabs | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @author Sacha Telgenhof <stelgenhof@gmail.com> | ||
*/ | ||
|
||
namespace Yasumi\tests\Lithuania; | ||
|
||
use Yasumi\Holiday; | ||
use Yasumi\tests\YasumiTestCaseInterface; | ||
|
||
/** | ||
* Class containing tests for All Saints' Day in Lithuania. | ||
* | ||
* @author Gedas Lukošius <gedas@lukosius.me> | ||
*/ | ||
class AllSaintsDayTest extends LithuaniaBaseTestCase implements YasumiTestCaseInterface | ||
{ | ||
/** | ||
* The name of the holiday to be tested | ||
*/ | ||
const HOLIDAY = 'allSaintsDay'; | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function holidayDataProvider() | ||
{ | ||
return $this->generateRandomDates(11, 1, self::TIMEZONE); | ||
} | ||
|
||
/** | ||
* @dataProvider holidayDataProvider | ||
* | ||
* @param int $year | ||
* @param \DateTime $expected | ||
*/ | ||
public function testHoliday($year, \DateTime $expected) | ||
{ | ||
$this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function testTranslation() | ||
{ | ||
$this->assertTranslatedHolidayName( | ||
self::REGION, | ||
self::HOLIDAY, | ||
$this->generateRandomYear(), | ||
[self::LOCALE => 'Visų šventųjų diena (Vėlinės)'] | ||
); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function testHolidayType() | ||
{ | ||
$this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Yasumi package. | ||
* | ||
* Copyright (c) 2015 - 2017 AzuyaLabs | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @author Sacha Telgenhof <stelgenhof@gmail.com> | ||
*/ | ||
|
||
namespace Yasumi\tests\Lithuania; | ||
|
||
use Yasumi\Holiday; | ||
use Yasumi\tests\YasumiTestCaseInterface; | ||
|
||
/** | ||
* Class containing tests for Assumption of Mary day in Lithuania. | ||
* | ||
* @author Gedas Lukošius <gedas@lukosius.me> | ||
*/ | ||
class AssumptionOfMaryDayTest extends LithuaniaBaseTestCase implements YasumiTestCaseInterface | ||
{ | ||
/** | ||
* The name of the holiday to be tested | ||
*/ | ||
const HOLIDAY = 'assumptionOfMary'; | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function holidayDataProvider() | ||
{ | ||
return $this->generateRandomDates(8, 15, self::TIMEZONE); | ||
} | ||
|
||
/** | ||
* @dataProvider holidayDataProvider | ||
* | ||
* @param int $year | ||
* @param \DateTime $expected | ||
*/ | ||
public function testHoliday($year, \DateTime $expected) | ||
{ | ||
$this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function testTranslation() | ||
{ | ||
$this->assertTranslatedHolidayName( | ||
self::REGION, | ||
self::HOLIDAY, | ||
$this->generateRandomYear(), | ||
[self::LOCALE => 'Žolinė (Švč. Mergelės Marijos ėmimo į dangų diena)'] | ||
); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function testHolidayType() | ||
{ | ||
$this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL); | ||
} | ||
} |
Oops, something went wrong.