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

Provider for holidays in Estonia #71

Merged
merged 7 commits into from
Dec 22, 2017
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
5 changes: 5 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@
<directory suffix="Test.php">./tests/Denmark</directory>
</testsuite>

<!-- Test Suite for holidays in Estonia -->
<testsuite name="Estonia">
<directory suffix="Test.php">./tests/Estonia</directory>
</testsuite>

<!-- Test Suite for holidays in Finland -->
<testsuite name="Finland">
<directory suffix="Test.php">./tests/Finland</directory>
Expand Down
113 changes: 113 additions & 0 deletions src/Yasumi/Provider/Estonia.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?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 <[email protected]>
*/

namespace Yasumi\Provider;

use Yasumi\Holiday;

/**
* Provider for all holidays in Estonia.
*
* @author Gedas Lukošius <[email protected]>
*/
class Estonia extends AbstractProvider
{
use CommonHolidays, ChristianHolidays;

const DECLARATION_OF_INDEPENDENCE_YEAR = 1918;

const VICTORY_DAY_START_YEAR = 1934;

const RESTORATION_OF_INDEPENDENCE_YEAR = 1991;

/**
* Code to identify this Holiday Provider. Typically this is the ISO3166 code corresponding to the respective
* country or sub-region.
*/
const ID = 'EE';

/**
* Initialize holidays for Estonia.
*
* @throws \InvalidArgumentException
*/
public function initialize()
{
$this->timezone = 'Europe/Tallinn';

// Official
$this->addHoliday($this->newYearsDay($this->year, $this->timezone, $this->locale));
$this->addIndependenceDay();
$this->addHoliday($this->goodFriday($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->easter($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->internationalWorkersDay($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->pentecost($this->year, $this->timezone, $this->locale));
$this->addVictoryDay();
$this->addHoliday($this->stJohnsDay($this->year, $this->timezone, $this->locale));
$this->addRestorationOfIndependenceDay();
$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));
}

/**
* @throws \InvalidArgumentException
*/
private function addIndependenceDay()
{
if ($this->year >= self::DECLARATION_OF_INDEPENDENCE_YEAR) {
$this->addHoliday(new Holiday(
'independenceDay',
[
'en_US' => 'Independence Day',
'et_EE' => 'Iseseisvuspäev'
],
new \DateTime("{$this->year}-02-24", new \DateTimeZone($this->timezone))
));
}
}

/**
* @throws \InvalidArgumentException
*/
private function addVictoryDay()
{
if ($this->year >= self::VICTORY_DAY_START_YEAR) {
$this->addHoliday(new Holiday(
'victoryDay',
[
'en_US' => 'Victory Day',
'et_EE' => 'Võidupüha'
],
new \DateTime("{$this->year}-06-23", new \DateTimeZone($this->timezone))
));
}
}

/**
* @throws \InvalidArgumentException
*/
private function addRestorationOfIndependenceDay()
{
if ($this->year >= self::RESTORATION_OF_INDEPENDENCE_YEAR) {
$this->addHoliday(new Holiday(
'restorationOfIndependenceDay',
[
'en_US' => 'Day of Restoration of Independence',
'et_EE' => 'Tasiseseisvumispäev'
],
new \DateTime("{$this->year}-08-20", new \DateTimeZone($this->timezone))
));
}
}
}
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/christmasDay.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
'en_US' => 'Christmas',
'en_ZA' => 'Christmas Day',
'es_ES' => 'Navidad',
'et_EE' => 'Esimene jõulupüha',
'fi_FI' => 'Joulupäivä',
'fr_BE' => 'Noël',
'fr_CH' => 'Noël',
Expand Down
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/christmasEve.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
'cy_GB' => 'Noswyl Nadolig',
'de_CH' => 'Heiliger Abend',
'en_US' => 'Christmas Eve',
'et_EE' => 'Jõululaupäev',
'fr_BE' => 'Réveillon de Noël',
'fr_CH' => 'Réveillon de Noël',
'it_CH' => 'Vigilia di Natale',
Expand Down
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/easter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
'el_GR' => 'Κυριακή του Πάσχα',
'en_IE' => 'Easter Sunday',
'en_US' => 'Easter Sunday',
'et_EE' => 'Ülestõusmispühade 1. püha',
'fi_FI' => 'Pääsiäispäivä',
'fr_BE' => 'Pâques',
'fr_CH' => 'Pâques',
Expand Down
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/goodFriday.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
'en_US' => 'Good Friday',
'en_ZA' => 'Good Friday',
'es_ES' => 'Viernes Santo',
'et_EE' => 'Suur Reede',
'fi_FI' => 'Pitkäperjantai',
'fr_BE' => 'Vendredi Saint',
'fr_CH' => 'Vendredi Saint',
Expand Down
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/internationalWorkersDay.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
'en_US' => 'International Workers\' Day',
'en_ZA' => 'Workers\' Day',
'es_ES' => 'Día del Trabajador',
'et_EE' => 'Kevadpüha',
'fi_FI' => 'Vappu',
'fr_BE' => 'Fête du Travail',
'fr_CH' => 'Fête du Travail',
Expand Down
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/newYearsDay.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
'en_US' => 'New Year\'s Day',
'en_ZA' => 'New Year\'s Day',
'es_ES' => 'Año Nuevo',
'et_EE' => 'Uusaasta',
'fi_FI' => 'Uudenvuodenpäivä',
'fr_BE' => 'Nouvel An',
'fr_CH' => 'Nouvel An',
Expand Down
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/pentecost.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
'el_GR' => 'Πεντηκοστή',
'en_IE' => 'Whitsunday',
'en_US' => 'Whitsunday',
'et_EE' => 'Nelipühade 1. püha',
'fi_FI' => 'Helluntaipäivä',
'fr_BE' => 'Pentecôte',
'fr_CH' => 'Pentecôte',
Expand Down
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/secondChristmasDay.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
'en_NZ' => 'Boxing Day',
'en_US' => 'Second Christmas Day',
'en_ZA' => 'Day of Goodwill',
'et_EE' => 'Teine Jõulupüha',
'fi_FI' => '2. joulupäivä',
'hu_HU' => 'Karácsony másnapja',
'lt_LT' => 'Kalėdos (antra diena)',
Expand Down
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/stJohnsDay.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
'el_GR' => 'Σύναξις Προφήτου Προδρόμου και Βαπτιστού Ιωάννου',
'en_US' => 'St. John\'s Day',
'es_ES' => 'Sant Joan',
'et_EE' => 'Jaanipäev',
'fi_FI' => 'Juhannuspäivä',
'lt_LT' => 'Rasos ir Joninių diena',
'lv_LV' => 'Jāņi',
Expand Down
70 changes: 70 additions & 0 deletions tests/Estonia/ChristmasDayTest.php
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 <[email protected]>
*/

namespace Yasumi\tests\Estonia;

use Yasumi\Holiday;
use Yasumi\tests\YasumiTestCaseInterface;

/**
* Class containing tests for Christmas day in Estonia.
*
* @author Gedas Lukošius <[email protected]>
*/
class ChristmasDayTest extends EstoniaBaseTestCase implements YasumiTestCaseInterface
{
/**
* The name of the holiday to be tested
*/
const HOLIDAY = 'christmasDay';

/**
* @return array
*/
public function holidayDataProvider()
{
return $this->generateRandomDates(12, 25, 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 => 'Esimene jõulupüha']
);
}

/**
* {@inheritdoc}
*/
public function testHolidayType()
{
$this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL);
}
}
70 changes: 70 additions & 0 deletions tests/Estonia/ChristmasEveDayTest.php
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 <[email protected]>
*/

namespace Yasumi\tests\Estonia;

use Yasumi\Holiday;
use Yasumi\tests\YasumiTestCaseInterface;

/**
* Class containing tests for Christmas Eve day in Estonia.
*
* @author Gedas Lukošius <[email protected]>
*/
class ChristmasEveDayTest extends EstoniaBaseTestCase implements YasumiTestCaseInterface
{
/**
* The name of the holiday to be tested
*/
const HOLIDAY = 'christmasEve';

/**
* @return array
*/
public function holidayDataProvider()
{
return $this->generateRandomDates(12, 24, 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 => 'Jõululaupäev']
);
}

/**
* {@inheritdoc}
*/
public function testHolidayType()
{
$this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL);
}
}
Loading