Skip to content

Commit ad4dc5b

Browse files
committed
add test for labor day of korea.
Signed-off-by: barami <barams@gmail.com>
1 parent 9969465 commit ad4dc5b

1 file changed

Lines changed: 121 additions & 0 deletions

File tree

tests/SouthKorea/LabourDayTest.php

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
<?php
2+
3+
declare(strict_types = 1);
4+
5+
/**
6+
* This file is part of the 'Yasumi' package.
7+
*
8+
* The easy PHP Library for calculating holidays.
9+
*
10+
* Copyright (c) 2015 - 2026 AzuyaLabs
11+
*
12+
* For the full copyright and license information, please view the LICENSE
13+
* file that was distributed with this source code.
14+
*
15+
* @author Sacha Telgenhof <me at sachatelgenhof dot com>
16+
*/
17+
18+
use Yasumi\Holiday;
19+
use Yasumi\Provider\DateTimeZoneFactory;
20+
use Yasumi\tests\HolidayTestCase;
21+
use Yasumi\tests\SouthKorea\SouthKoreaBaseTestCase;
22+
23+
/**
24+
* Class for testing Labour Day in South Korea.
25+
*/
26+
class LabourDayTest extends SouthKoreaBaseTestCase implements HolidayTestCase
27+
{
28+
/**
29+
* The name of the holiday.
30+
*/
31+
public const HOLIDAY = 'labourDay';
32+
33+
/**
34+
* The year in which the holiday was first established.
35+
*/
36+
public const ESTABLISHMENT_YEAR = 2026;
37+
38+
/**
39+
* Tests the holiday defined in this test.
40+
*
41+
* @throws Exception
42+
*/
43+
public function testLabourDay(): void
44+
{
45+
// From 2026 onwards.
46+
$year = static::generateRandomYear(self::ESTABLISHMENT_YEAR);
47+
$this->assertHoliday(
48+
self::REGION,
49+
self::HOLIDAY,
50+
$year,
51+
new DateTime("{$year}-5-1", DateTimeZoneFactory::getDateTimeZone(self::TIMEZONE))
52+
);
53+
54+
// Before 2026
55+
$this->assertNotHoliday(
56+
self::REGION,
57+
self::HOLIDAY,
58+
static::generateRandomYear(null, self::ESTABLISHMENT_YEAR - 1),
59+
);
60+
}
61+
62+
/**
63+
* Tests the substitute holiday defined in this test.
64+
*
65+
* @throws Exception
66+
*/
67+
#[PHPUnit\Framework\Attributes\DataProvider('SubstituteHolidayDataProvider')]
68+
public function testSubstituteHoliday(int $year, string $expected): void
69+
{
70+
$this->assertSubstituteHoliday(
71+
self::REGION,
72+
self::HOLIDAY,
73+
$year,
74+
new DateTime($expected, DateTimeZoneFactory::getDateTimeZone(self::TIMEZONE))
75+
);
76+
}
77+
78+
/**
79+
* Tests translated name of the holiday defined in this test.
80+
*
81+
* @throws Exception
82+
*/
83+
public function testTranslation(): void
84+
{
85+
$this->assertTranslatedHolidayName(
86+
self::REGION,
87+
self::HOLIDAY,
88+
static::generateRandomYear(self::ESTABLISHMENT_YEAR),
89+
[self::LOCALE => '노동절']
90+
);
91+
}
92+
93+
/**
94+
* Tests type of the holiday defined in this test.
95+
*
96+
* @throws Exception
97+
*/
98+
public function testHolidayType(): void
99+
{
100+
$this->assertHolidayType(
101+
self::REGION,
102+
self::HOLIDAY,
103+
static::generateRandomYear(self::ESTABLISHMENT_YEAR),
104+
Holiday::TYPE_OFFICIAL
105+
);
106+
}
107+
108+
public static function SubstituteHolidayDataProvider(): array
109+
{
110+
return [
111+
[2027, '2027-05-03'],
112+
[2032, '2032-05-03'],
113+
[2033, '2033-05-02'],
114+
[2038, '2038-05-03'],
115+
[2038, '2038-05-03'],
116+
[2039, '2039-05-03'],
117+
[2044, '2044-05-02'],
118+
[2049, '2049-05-03'],
119+
];
120+
}
121+
}

0 commit comments

Comments
 (0)