forked from azuyalabs/yasumi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2e9e914
commit 55fc857
Showing
3 changed files
with
113 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
/** | ||
* This file is part of the Yasumi package. | ||
* | ||
* Copyright (c) 2015 - 2016 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\Ireland; | ||
|
||
use DateTime; | ||
use DateTimeZone; | ||
use Yasumi\Holiday; | ||
use Yasumi\tests\YasumiTestCaseInterface; | ||
|
||
/** | ||
* Class containing tests for Christmas Day in Ireland. | ||
*/ | ||
class ChristmasDayTest extends IrelandBaseTestCase implements YasumiTestCaseInterface | ||
{ | ||
/** | ||
* The name of the holiday to be tested | ||
*/ | ||
const HOLIDAY = 'christmasDay'; | ||
|
||
/** | ||
* Tests the holiday defined in this test. | ||
* | ||
* @dataProvider HolidayDataProvider | ||
* | ||
* @param int $year the year for which the holiday defined in this test needs to be tested | ||
* @param \DateTime $expected the expected date | ||
*/ | ||
public function testHoliday($year, $expected) | ||
{ | ||
$date = new DateTime($expected, new DateTimeZone(self::TIMEZONE)); | ||
$this->assertHoliday(self::REGION, self::HOLIDAY, $year, $date); | ||
|
||
if (in_array($date->format('w'), [0, 6])) { | ||
$date->modify('next tuesday'); | ||
$this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date); | ||
} | ||
} | ||
|
||
/** | ||
* Returns a list of random test dates used for assertion of the holiday defined in this test | ||
* | ||
* @return array list of test dates for the holiday defined in this test | ||
*/ | ||
public function HolidayDataProvider() | ||
{ | ||
$data = []; | ||
|
||
for ($y = 0; $y < self::TEST_ITERATIONS; $y++) { | ||
$year = $this->generateRandomYear(); | ||
$date = new DateTime("$year-12-25", new DateTimeZone(self::TIMEZONE)); | ||
$data[] = [$year, $date->format('Y-m-d')]; | ||
} | ||
|
||
return $data; | ||
} | ||
|
||
/** | ||
* Tests translated name of the holiday defined in this test. | ||
*/ | ||
public function testTranslation() | ||
{ | ||
$this->assertTranslatedHolidayName(self::REGION, self::HOLIDAY, $this->generateRandomYear(), | ||
[self::LOCALE => 'Christmas Day']); | ||
$this->assertTranslatedHolidayName(self::REGION, self::HOLIDAY, $this->generateRandomYear(), | ||
['ga_IE' => 'Lá Nollag']); | ||
} | ||
|
||
/** | ||
* Tests type of the holiday defined in this test. | ||
*/ | ||
public function testHolidayType() | ||
{ | ||
$this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_NATIONAL); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters