Skip to content

Commit 03d68a2

Browse files
committed
feat(germany): Day of Liberation is celebrated in Berlin in 2025 too.
Signed-off-by: Sacha Telgenhof <[email protected]>
1 parent 3ee7774 commit 03d68a2

File tree

2 files changed

+29
-17
lines changed

2 files changed

+29
-17
lines changed

src/Yasumi/Provider/Germany/Berlin.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ public function initialize(): void
5555
$this->addHoliday($this->internationalWomensDay($this->year, $this->timezone, $this->locale));
5656
}
5757

58-
if (2020 === $this->year) {
59-
$this->addHoliday($this->dayOfLiberation($this->timezone, $this->locale));
58+
if (2020 === $this->year || 2025 === $this->year) {
59+
$this->addHoliday($this->dayOfLiberation($this->year, $this->timezone, $this->locale));
6060
}
6161
}
6262

@@ -68,6 +68,7 @@ public function initialize(): void
6868
*
6969
* @see https://de.wikipedia.org/wiki/Tag_der_Befreiung
7070
*
71+
* @param int $year the year in which Day of Liberation is celebrated
7172
* @param string $timezone the timezone in which Day of Liberation is celebrated
7273
* @param string $locale the locale for which Day of Liberation needs to be displayed in
7374
* @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
@@ -78,14 +79,15 @@ public function initialize(): void
7879
* @throws \Exception
7980
*/
8081
protected function dayOfLiberation(
82+
int $year,
8183
string $timezone,
8284
string $locale,
8385
string $type = Holiday::TYPE_OFFICIAL,
8486
): Holiday {
8587
return new Holiday(
8688
'dayOfLiberation',
8789
[],
88-
new \DateTime('2020-05-08', DateTimeZoneFactory::getDateTimeZone($timezone)),
90+
new \DateTime("{$year}-05-08", DateTimeZoneFactory::getDateTimeZone($timezone)),
8991
$locale,
9092
$type
9193
);

tests/Germany/Berlin/DayOfLiberation2020Test.php tests/Germany/Berlin/DayOfLiberationTest.php

+24-14
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@
2121
use Yasumi\tests\HolidayTestCase;
2222

2323
/**
24-
* Class for testing Day of Liberation 2020 in Berlin (Germany).
24+
* Class for testing Day of Liberation in Berlin (Germany).
2525
*/
26-
class DayOfLiberation2020Test extends BerlinBaseTestCase implements HolidayTestCase
26+
class DayOfLiberationTest extends BerlinBaseTestCase implements HolidayTestCase
2727
{
2828
/**
2929
* The name of the holiday to be tested.
3030
*/
3131
public const HOLIDAY = 'dayOfLiberation';
3232

3333
/**
34-
* The year in which the holiday takes place.
34+
* The years in which the holiday takes place.
3535
*/
36-
public const YEAR = 2020;
36+
public static array $years = [2020, 2025];
3737

3838
/**
3939
* Test the holiday defined in this test.
@@ -42,12 +42,14 @@ class DayOfLiberation2020Test extends BerlinBaseTestCase implements HolidayTestC
4242
*/
4343
public function testHolidayInYear(): void
4444
{
45-
$this->assertHoliday(
46-
self::REGION,
47-
self::HOLIDAY,
48-
self::YEAR,
49-
new \DateTime(self::YEAR . '-05-08', new \DateTimeZone(self::TIMEZONE))
50-
);
45+
foreach (self::$years as $year) {
46+
$this->assertHoliday(
47+
self::REGION,
48+
self::HOLIDAY,
49+
$year,
50+
new \DateTime($year . '-05-08', new \DateTimeZone(self::TIMEZONE))
51+
);
52+
}
5153
}
5254

5355
/**
@@ -57,10 +59,12 @@ public function testHolidayInYear(): void
5759
*/
5860
public function testHolidayBeforeYear(): void
5961
{
62+
reset(self::$years);
63+
6064
$this->assertNotHoliday(
6165
self::REGION,
6266
self::HOLIDAY,
63-
$this->generateRandomYear(1000, self::YEAR - 1)
67+
$this->generateRandomYear(1000, current(self::$years) - 1)
6468
);
6569
}
6670

@@ -71,10 +75,12 @@ public function testHolidayBeforeYear(): void
7175
*/
7276
public function testHolidayAfterYear(): void
7377
{
78+
end(self::$years);
79+
7480
$this->assertNotHoliday(
7581
self::REGION,
7682
self::HOLIDAY,
77-
$this->generateRandomYear(self::YEAR + 1)
83+
$this->generateRandomYear(current(self::$years) + 1)
7884
);
7985
}
8086

@@ -83,10 +89,12 @@ public function testHolidayAfterYear(): void
8389
*/
8490
public function testTranslation(): void
8591
{
92+
reset(self::$years);
93+
8694
$this->assertTranslatedHolidayName(
8795
self::REGION,
8896
self::HOLIDAY,
89-
self::YEAR,
97+
current(self::$years),
9098
[self::LOCALE => 'Tag der Befreiung']
9199
);
92100
}
@@ -96,10 +104,12 @@ public function testTranslation(): void
96104
*/
97105
public function testHolidayType(): void
98106
{
107+
reset(self::$years);
108+
99109
$this->assertHolidayType(
100110
self::REGION,
101111
self::HOLIDAY,
102-
self::YEAR,
112+
current(self::$years),
103113
Holiday::TYPE_OFFICIAL
104114
);
105115
}

0 commit comments

Comments
 (0)