Skip to content

Commit

Permalink
Provider for holidays in South Korea (#156)
Browse files Browse the repository at this point in the history
* support Korean translations
* add provider for holidays in South Korea
* add tests for holidays in South Korea
* fix Hangul Day test logic
  • Loading branch information
blood72 authored and stelgenhof committed May 23, 2019
1 parent 56c693c commit e7a4e02
Show file tree
Hide file tree
Showing 29 changed files with 2,393 additions and 0 deletions.
5 changes: 5 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@
<directory suffix="Test.php">./tests/SouthAfrica</directory>
</testsuite>

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

<!-- Test Suite for holidays in Spain -->
<testsuite name="Spain">
<directory suffix="Test.php">./tests/Spain</directory>
Expand Down
518 changes: 518 additions & 0 deletions src/Yasumi/Provider/SouthKorea.php

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Yasumi/data/translations/christmasDay.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
'hu_HU' => 'Karácsony',
'it_CH' => 'Natale',
'it_IT' => 'Natale',
'ko_KR' => '기독탄신일',
'lt_LT' => 'Šv. Kalėdos',
'lv_LV' => 'Ziemassvētki',
'nb_NO' => 'Første juledag',
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 @@ -21,6 +21,7 @@
'fr_BE' => 'Réveillon de Noël',
'fr_CH' => 'Réveillon de Noël',
'it_CH' => 'Vigilia di Natale',
'ko_KR' => '크리스마스 이브',
'lt_LT' => 'Šv. Kūčios',
'lv_LV' => 'Ziemassvētku vakars',
'pt_PT' => 'Véspera de Natal',
Expand Down
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/dayAfterNewYearsDay.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
return [
'en_NZ' => 'Day after New Year\'s Day',
'en_US' => 'Day after New Year\'s Day',
'ko_KR' => '새해 연휴',
];
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/internationalWomensDay.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
return [
'de_DE' => 'Internationaler Frauentag',
'en_US' => 'International Women\'s Day',
'ko_KR' => '국제 여성의 날',
'ru_RU' => 'Международный женский день',
'ru_UA' => 'Международный женский день',
'uk_UA' => 'Міжнародний жіночий день',
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 @@ -32,6 +32,7 @@
'it_CH' => 'Festa dei lavoratori',
'it_IT' => 'Festa del Lavoro',
'ja_JP' => '労働の日',
'ko_KR' => '노동절',
'lt_LT' => 'Tarptautinė darbo diena',
'lv_LV' => 'Darba svētki',
'nb_NO' => 'Arbeidernes dag',
Expand Down
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/labourDay.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
'en_NZ' => 'Labour Day',
'en_US' => 'Labour Day',
'ja_JP' => '労働の日',
'ko_KR' => '노동절',
'nl_BE' => 'Dag van de arbeid',
'nl_NL' => 'Dag van de arbeid',
'sk_SK' => 'Sviatok práce',
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 @@ -38,6 +38,7 @@
'it_CH' => 'Capodanno',
'it_IT' => 'Capodanno',
'ja_JP' => '元日',
'ko_KR' => '새해',
'lt_LT' => 'Naujųjų metų diena',
'lv_LV' => 'Jaunais Gads',
'nb_NO' => 'Første nyttårsdag',
Expand Down
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/newYearsEve.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
return [
'da_DK' => 'Nytårsaften',
'en_US' => 'New Year\'s Eve',
'ko_KR' => '신년전야',
'lv_LV' => 'Vecgada vakars',
];
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/secondChristmasDay.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
'et_EE' => 'Teine Jõulupüha',
'fi_FI' => '2. joulupäivä',
'hu_HU' => 'Karácsony másnapja',
'ko_KR' => '성탄절 연휴',
'lt_LT' => 'Kalėdos (antra diena)',
'lv_LV' => 'Otrie Ziemassvētki',
'nb_NO' => 'Andre juledag',
Expand Down
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/summerTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
return [
'da_DK' => 'Sommertid starter',
'en_US' => 'Summertime',
'ko_KR' => '서머타임',
'nl_NL' => 'Zomertijd',
];
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/valentinesDay.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
'fr_CH' => 'Saint-Valentin',
'it_CH' => 'San Valentino',
'ja_JP' => 'バレンタイン·デー',
'ko_KR' => '발렌타인 데이',
'nl_BE' => 'Valentijnsdag',
'nl_NL' => 'Valentijnsdag',
'pl_PL' => 'Walentynki',
Expand Down
124 changes: 124 additions & 0 deletions tests/SouthKorea/ArborDayTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<?php

/**
* 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 <me@sachatelgenhof.com>
*/

namespace Yasumi\tests\SouthKorea;

use DateTime;
use DateTimeZone;
use Yasumi\Holiday;
use Yasumi\tests\YasumiTestCaseInterface;

/**
* Class for testing day after Arbor Day in South Korea.
*/
class ArborDayTest extends SouthKoreaBaseTestCase implements YasumiTestCaseInterface
{
/**
* The name of the holiday
*/
public const HOLIDAY = 'arborDay';

/**
* The year in which the holiday was first established
*/
public const ESTABLISHMENT_YEAR = 1949;

/**
* The year in which the holiday was removed
*/
public const REMOVED_YEAR = 2005;

/**
* Tests the holiday defined in this test.
* @throws \Exception
* @throws \ReflectionException
*/
public function testHoliday()
{
$year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR, self::REMOVED_YEAR);
if ($year === 1960) {
$this->assertNotHoliday(
self::REGION,
self::HOLIDAY,
$year
);
} else {
$this->assertHoliday(
self::REGION,
self::HOLIDAY,
$year,
new DateTime("$year-4-5", new DateTimeZone(self::TIMEZONE))
);
}
}

/**
* Tests the holiday defined in this test after removal.
* @throws \ReflectionException
*/
public function testHolidayAfterRemoval()
{
$this->assertNotHoliday(
self::REGION,
self::HOLIDAY,
$this->generateRandomYear(self::REMOVED_YEAR + 1)
);
}

/**
* Tests the holiday defined in this test before establishment.
* @throws \ReflectionException
*/
public function testHolidayBeforeEstablishment()
{
$this->assertNotHoliday(
self::REGION,
self::HOLIDAY,
$this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
);
}

/**
* Tests the translated name of the holiday defined in this test.
* @throws \ReflectionException
*/
public function testTranslation(): void
{
$year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR, self::REMOVED_YEAR);
if ($year !== 1960) {
$this->assertTranslatedHolidayName(
self::REGION,
self::HOLIDAY,
$year,
[self::LOCALE => '식목일']
);
}
}

/**
* Tests type of the holiday defined in this test.
* @throws \ReflectionException
*/
public function testHolidayType(): void
{
$year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR, self::REMOVED_YEAR);
if ($year !== 1960) {
$this->assertHolidayType(
self::REGION,
self::HOLIDAY,
$year,
Holiday::TYPE_OFFICIAL
);
}
}
}
110 changes: 110 additions & 0 deletions tests/SouthKorea/ArmedForcesDayTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<?php

/**
* 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 <me@sachatelgenhof.com>
*/

namespace Yasumi\tests\SouthKorea;

use DateTime;
use DateTimeZone;
use Yasumi\Holiday;
use Yasumi\tests\YasumiTestCaseInterface;

/**
* Class for testing day after Armed Forces Day in South Korea.
*/
class ArmedForcesDayTest extends SouthKoreaBaseTestCase implements YasumiTestCaseInterface
{
/**
* The name of the holiday
*/
public const HOLIDAY = 'armedForcesDay';

/**
* The year in which the holiday was first established
*/
public const ESTABLISHMENT_YEAR = 1956;

/**
* The year in which the holiday was removed
*/
public const REMOVED_YEAR = 1990;

/**
* Tests the holiday defined in this test.
* @throws \Exception
* @throws \ReflectionException
*/
public function testHoliday()
{
$year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR, self::REMOVED_YEAR);
$this->assertHoliday(
self::REGION,
self::HOLIDAY,
$year,
new DateTime("$year-10-1", new DateTimeZone(self::TIMEZONE))
);
}

/**
* Tests the holiday defined in this test after removal.
* @throws \ReflectionException
*/
public function testHolidayAfterRemoval()
{
$this->assertNotHoliday(
self::REGION,
self::HOLIDAY,
$this->generateRandomYear(self::REMOVED_YEAR + 1)
);
}

/**
* Tests the holiday defined in this test before establishment.
* @throws \ReflectionException
*/
public function testHolidayBeforeEstablishment()
{
$this->assertNotHoliday(
self::REGION,
self::HOLIDAY,
$this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
);
}

/**
* Tests the translated name of the holiday defined in this test.
* @throws \ReflectionException
*/
public function testTranslation(): void
{
$this->assertTranslatedHolidayName(
self::REGION,
self::HOLIDAY,
$this->generateRandomYear(self::ESTABLISHMENT_YEAR, self::REMOVED_YEAR),
[self::LOCALE => '국군의 날']
);
}

/**
* Tests type of the holiday defined in this test.
* @throws \ReflectionException
*/
public function testHolidayType(): void
{
$this->assertHolidayType(
self::REGION,
self::HOLIDAY,
$this->generateRandomYear(self::ESTABLISHMENT_YEAR, self::REMOVED_YEAR),
Holiday::TYPE_OFFICIAL
);
}
}
Loading

0 comments on commit e7a4e02

Please sign in to comment.