-
-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Arkounay
authored
Feb 18, 2020
1 parent
dfaec2c
commit 1127c0d
Showing
24 changed files
with
1,103 additions
and
3 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,103 @@ | ||
<?php | ||
|
||
namespace Yasumi\Provider; | ||
|
||
use DateTime; | ||
use DateTimeZone; | ||
use Yasumi\Exception\InvalidDateException; | ||
use Yasumi\Exception\UnknownLocaleException; | ||
use Yasumi\Holiday; | ||
|
||
/** | ||
* Provider for all holidays in Luxembourg. | ||
*/ | ||
class Luxembourg extends AbstractProvider | ||
{ | ||
use CommonHolidays, ChristianHolidays; | ||
|
||
public const EUROPE_DAY_START_YEAR = 2019; | ||
|
||
/** | ||
* Code to identify this Holiday Provider. Typically this is the ISO3166 code corresponding to the respective | ||
* country or sub-region. | ||
*/ | ||
public const ID = 'LU'; | ||
|
||
/** | ||
* Initialize holidays for Luxembourg. | ||
* | ||
* @throws \Yasumi\Exception\InvalidDateException | ||
* @throws \InvalidArgumentException | ||
* @throws \Yasumi\Exception\UnknownLocaleException | ||
* @throws \Exception | ||
*/ | ||
public function initialize(): void | ||
{ | ||
$this->timezone = 'Europe/Luxembourg'; | ||
|
||
// Add common holidays | ||
$this->addHoliday($this->newYearsDay($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->calculateEuropeDay(); | ||
$this->addHoliday($this->ascensionDay($this->year, $this->timezone, $this->locale)); | ||
$this->addHoliday($this->pentecostMonday($this->year, $this->timezone, $this->locale)); | ||
$this->calculateNationalDay(); | ||
$this->addHoliday($this->assumptionOfMary($this->year, $this->timezone, $this->locale)); | ||
$this->addHoliday($this->allSaintsDay($this->year, $this->timezone, $this->locale)); | ||
$this->addHoliday($this->christmasDay($this->year, $this->timezone, $this->locale)); | ||
$this->addHoliday($this->secondChristmasDay($this->year, $this->timezone, $this->locale)); | ||
} | ||
|
||
/** | ||
* Europe Day. | ||
* | ||
* Europe Day is celebrated on 5 May by the Council of Europe and on 9 May by the European Union. | ||
* The first recognition of Europe Day was by the Council of Europe, introduced in 1964. | ||
* The European Union later started to celebrate its own European Day in commemoration of the 1950 | ||
* Schuman Declaration, leading it to be referred to by some as "Schuman Day". | ||
* Both days are celebrated by displaying the Flag of Europe. | ||
* | ||
* @link https://en.wikipedia.org/wiki/Europe_Day | ||
* | ||
* @throws InvalidDateException | ||
* @throws \InvalidArgumentException | ||
* @throws UnknownLocaleException | ||
* @throws \Exception | ||
*/ | ||
public function calculateEuropeDay(): void | ||
{ | ||
if ($this->year >= 2019) { | ||
$this->addHoliday(new Holiday('europeDay', [ | ||
'en_US' => 'Europe day', | ||
'fr_FR' => 'La Journée de l\'Europe', | ||
'lu' => 'La Journée de l\'Europe', | ||
], new DateTime("$this->year-5-9", new DateTimeZone($this->timezone)), $this->locale)); | ||
} | ||
} | ||
|
||
/** | ||
* Luxembourgish National Day. | ||
* | ||
* The Grand Duke's Official Birthday (French: Célébration publique de l'anniversaire du souverain), | ||
* also known as Luxembourgish National Day (French: Fête nationale luxembourgeoise, Luxembourgish: | ||
* Lëtzebuerger Nationalfeierdag), is celebrated as the annual national holiday of Luxembourg. | ||
* It is celebrated on 23 June, although this has never been the actual birthday of any ruler of Luxembourg. | ||
* When the monarch of Luxembourg is female, it is known as the Grand Duchess' Official Birthday. | ||
* | ||
* @link https://en.wikipedia.org/wiki/Grand_Duke%27s_Official_Birthday | ||
* | ||
* @throws InvalidDateException | ||
* @throws \InvalidArgumentException | ||
* @throws UnknownLocaleException | ||
* @throws \Exception | ||
*/ | ||
public function calculateNationalDay(): void | ||
{ | ||
$this->addHoliday(new Holiday('nationalDay', [ | ||
'en_US' => 'National day', | ||
'fr_FR' => 'La Fête nationale', | ||
'lu' => 'La Fête nationale', | ||
], new DateTime("$this->year-6-23", 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php declare(strict_types=1); | ||
/** | ||
* This file is part of the Yasumi package. | ||
* | ||
* Copyright (c) 2015 - 2019 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\Luxembourg; | ||
|
||
use DateTime; | ||
use Exception; | ||
use ReflectionException; | ||
use Yasumi\Holiday; | ||
use Yasumi\tests\YasumiTestCaseInterface; | ||
|
||
/** | ||
* Class for testing All Saints' Day in Luxembourg. | ||
*/ | ||
class AllSaintsDayTest extends LuxembourgBaseTestCase implements YasumiTestCaseInterface | ||
{ | ||
/** | ||
* The name of the holiday | ||
*/ | ||
public const HOLIDAY = 'allSaintsDay'; | ||
|
||
/** | ||
* Tests All Saints' Day. | ||
* | ||
* @dataProvider AllSaintsDayDataProvider | ||
* | ||
* @param int $year the year for which All Saints' Day needs to be tested | ||
* @param DateTime $expected the expected date | ||
* | ||
* @throws ReflectionException | ||
*/ | ||
public function testAllSaintsDay($year, $expected) | ||
{ | ||
$this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected); | ||
} | ||
|
||
/** | ||
* Tests translated name of All Saints' Day. | ||
* @throws ReflectionException | ||
*/ | ||
public function testTranslation(): void | ||
{ | ||
$this->assertTranslatedHolidayName( | ||
self::REGION, | ||
self::HOLIDAY, | ||
$this->generateRandomYear(), | ||
[self::LOCALE => 'Toussaint'] | ||
); | ||
} | ||
|
||
/** | ||
* Tests type of the holiday defined in this test. | ||
* @throws ReflectionException | ||
*/ | ||
public function testHolidayType(): void | ||
{ | ||
$this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL); | ||
} | ||
|
||
/** | ||
* Returns a list of random test dates used for assertion of All Saints' Day. | ||
* | ||
* @return array list of test dates for All Saints' Day | ||
* @throws Exception | ||
*/ | ||
public function AllSaintsDayDataProvider(): array | ||
{ | ||
return $this->generateRandomDates(11, 1, self::TIMEZONE); | ||
} | ||
} |
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 declare(strict_types=1); | ||
/** | ||
* This file is part of the Yasumi package. | ||
* | ||
* Copyright (c) 2015 - 2019 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\Luxembourg; | ||
|
||
use DateTime; | ||
use DateTimeZone; | ||
use Exception; | ||
use ReflectionException; | ||
use Yasumi\Holiday; | ||
use Yasumi\tests\YasumiTestCaseInterface; | ||
|
||
/** | ||
* Class for testing Ascension Day in Luxembourg. | ||
*/ | ||
class AscensionDayTest extends LuxembourgBaseTestCase implements YasumiTestCaseInterface | ||
{ | ||
/** | ||
* The name of the holiday | ||
*/ | ||
public const HOLIDAY = 'ascensionDay'; | ||
|
||
/** | ||
* Tests Ascension Day. | ||
* @throws Exception | ||
* @throws ReflectionException | ||
*/ | ||
public function testAscensionDay() | ||
{ | ||
$year = 1901; | ||
$this->assertHoliday( | ||
self::REGION, | ||
self::HOLIDAY, | ||
$year, | ||
new DateTime("$year-5-16", new DateTimeZone(self::TIMEZONE)) | ||
); | ||
} | ||
|
||
/** | ||
* Tests translated name of Ascension Day. | ||
* @throws ReflectionException | ||
*/ | ||
public function testTranslation(): void | ||
{ | ||
$this->assertTranslatedHolidayName( | ||
self::REGION, | ||
self::HOLIDAY, | ||
$this->generateRandomYear(), | ||
[self::LOCALE => 'Ascension'] | ||
); | ||
} | ||
|
||
/** | ||
* Tests type of the holiday defined in this test. | ||
* @throws ReflectionException | ||
*/ | ||
public function testHolidayType(): void | ||
{ | ||
$this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL); | ||
} | ||
} |
Oops, something went wrong.