Skip to content

Commit

Permalink
Feature/pentecost germany (#225)
Browse files Browse the repository at this point in the history
Add Pentecost to Germany.php
  • Loading branch information
Patrick-Root authored and stelgenhof committed Jan 13, 2021
1 parent 3fc78c2 commit d4262c3
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/) and this
## [Unreleased]

### Added
- Added Pentecost (Sunday) to Germany [\#225](https://github.com/azuyalabs/yasumi/pull/225)

### Changed

Expand Down
1 change: 1 addition & 0 deletions src/Yasumi/Provider/Germany.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function initialize(): void
$this->addHoliday($this->easterMonday($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->goodFriday($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->addHoliday($this->pentecostMonday($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->secondChristmasDay($this->year, $this->timezone, $this->locale));

Expand Down
75 changes: 75 additions & 0 deletions tests/Germany/PentecostTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php declare(strict_types=1);
/**
* This file is part of the Yasumi package.
*
* Copyright (c) 2015 - 2020 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\Germany;

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

/**
* Class for testing Pentecost in Germany.
*/
class PentecostTest extends GermanyBaseTestCase implements YasumiTestCaseInterface
{
/**
* The name of the holiday
*/
public const HOLIDAY = 'pentecost';

/**
* Tests the holiday defined in this test.
* @throws Exception
* @throws ReflectionException
*/
public function testHoliday()
{
$year = $this->generateRandomYear();
$time_stamp = \strtotime(
$year . '-03-21' . \easter_days($year) . ' day + 49 day'
);
$date = \date('Y-m-d', $time_stamp);

$this->assertHoliday(
self::REGION,
self::HOLIDAY,
$year,
new DateTime($date, new DateTimeZone(self::TIMEZONE))
);
}

/**
* 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::LOCALE => 'Pfingstsonntag']
);
}

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

0 comments on commit d4262c3

Please sign in to comment.