Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/pentecost germany #225

Merged
merged 4 commits into from
Oct 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -53,6 +53,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);
}
}