Skip to content

Commit

Permalink
feat(germany): Day of Liberation is celebrated in Berlin in 2025 too.
Browse files Browse the repository at this point in the history
Signed-off-by: Sacha Telgenhof <[email protected]>
  • Loading branch information
stelgenhof committed Oct 25, 2024
1 parent 3ee7774 commit 03d68a2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 17 deletions.
8 changes: 5 additions & 3 deletions src/Yasumi/Provider/Germany/Berlin.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public function initialize(): void
$this->addHoliday($this->internationalWomensDay($this->year, $this->timezone, $this->locale));
}

if (2020 === $this->year) {
$this->addHoliday($this->dayOfLiberation($this->timezone, $this->locale));
if (2020 === $this->year || 2025 === $this->year) {
$this->addHoliday($this->dayOfLiberation($this->year, $this->timezone, $this->locale));
}
}

Expand All @@ -68,6 +68,7 @@ public function initialize(): void
*
* @see https://de.wikipedia.org/wiki/Tag_der_Befreiung
*
* @param int $year the year in which Day of Liberation is celebrated
* @param string $timezone the timezone in which Day of Liberation is celebrated
* @param string $locale the locale for which Day of Liberation needs to be displayed in
* @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
Expand All @@ -78,14 +79,15 @@ public function initialize(): void
* @throws \Exception
*/
protected function dayOfLiberation(
int $year,
string $timezone,
string $locale,
string $type = Holiday::TYPE_OFFICIAL,
): Holiday {
return new Holiday(
'dayOfLiberation',
[],
new \DateTime('2020-05-08', DateTimeZoneFactory::getDateTimeZone($timezone)),
new \DateTime("{$year}-05-08", DateTimeZoneFactory::getDateTimeZone($timezone)),
$locale,
$type
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@
use Yasumi\tests\HolidayTestCase;

/**
* Class for testing Day of Liberation 2020 in Berlin (Germany).
* Class for testing Day of Liberation in Berlin (Germany).
*/
class DayOfLiberation2020Test extends BerlinBaseTestCase implements HolidayTestCase
class DayOfLiberationTest extends BerlinBaseTestCase implements HolidayTestCase
{
/**
* The name of the holiday to be tested.
*/
public const HOLIDAY = 'dayOfLiberation';

/**
* The year in which the holiday takes place.
* The years in which the holiday takes place.
*/
public const YEAR = 2020;
public static array $years = [2020, 2025];

/**
* Test the holiday defined in this test.
Expand All @@ -42,12 +42,14 @@ class DayOfLiberation2020Test extends BerlinBaseTestCase implements HolidayTestC
*/
public function testHolidayInYear(): void
{
$this->assertHoliday(
self::REGION,
self::HOLIDAY,
self::YEAR,
new \DateTime(self::YEAR . '-05-08', new \DateTimeZone(self::TIMEZONE))
);
foreach (self::$years as $year) {
$this->assertHoliday(
self::REGION,
self::HOLIDAY,
$year,
new \DateTime($year . '-05-08', new \DateTimeZone(self::TIMEZONE))
);
}
}

/**
Expand All @@ -57,10 +59,12 @@ public function testHolidayInYear(): void
*/
public function testHolidayBeforeYear(): void
{
reset(self::$years);

$this->assertNotHoliday(
self::REGION,
self::HOLIDAY,
$this->generateRandomYear(1000, self::YEAR - 1)
$this->generateRandomYear(1000, current(self::$years) - 1)
);
}

Expand All @@ -71,10 +75,12 @@ public function testHolidayBeforeYear(): void
*/
public function testHolidayAfterYear(): void
{
end(self::$years);

$this->assertNotHoliday(
self::REGION,
self::HOLIDAY,
$this->generateRandomYear(self::YEAR + 1)
$this->generateRandomYear(current(self::$years) + 1)
);
}

Expand All @@ -83,10 +89,12 @@ public function testHolidayAfterYear(): void
*/
public function testTranslation(): void
{
reset(self::$years);

$this->assertTranslatedHolidayName(
self::REGION,
self::HOLIDAY,
self::YEAR,
current(self::$years),
[self::LOCALE => 'Tag der Befreiung']
);
}
Expand All @@ -96,10 +104,12 @@ public function testTranslation(): void
*/
public function testHolidayType(): void
{
reset(self::$years);

$this->assertHolidayType(
self::REGION,
self::HOLIDAY,
self::YEAR,
current(self::$years),
Holiday::TYPE_OFFICIAL
);
}
Expand Down

0 comments on commit 03d68a2

Please sign in to comment.