-
-
Notifications
You must be signed in to change notification settings - Fork 159
/
Copy pathPortugalDayTest.php
118 lines (104 loc) · 3.68 KB
/
PortugalDayTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
declare(strict_types=1);
/*
* This file is part of the Yasumi package.
*
* Copyright (c) 2015 - 2021 AzuyaLabs
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Sacha Telgenhof <me@sachatelgenhof.com>
*/
namespace Yasumi\tests\Portugal;
use DateTime;
use DateTimeZone;
use Exception;
use ReflectionException;
use Yasumi\Holiday;
use Yasumi\Provider\Portugal;
use Yasumi\tests\HolidayTestCase;
/**
* Class for testing Portugal Day in Portugal.
*/
class PortugalDayTest extends PortugalBaseTestCase implements HolidayTestCase
{
/**
* The year in which the holiday was abolished.
*/
public const ESTABLISHMENT_YEAR_BEFORE = 1932;
/**
* The year in which the holiday was restored.
*/
public const ESTABLISHMENT_YEAR_AFTER = 1974;
/**
* The name of the holiday to be tested.
*/
public const HOLIDAY = 'portugalDay';
/**
* Tests the holiday defined in this test before it was abolished.
*
* @throws ReflectionException
* @throws Exception
*
* @see Portugal::calculatePortugalDay()
*/
public function testHolidayBeforeAbolishment(): void
{
$year = $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR_BEFORE);
$expected = new DateTime("$year-06-10", new DateTimeZone(self::TIMEZONE));
$this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* Tests the holiday defined in this test after it was restored.
*
* @throws ReflectionException
* @throws Exception
*
* @see Portugal::calculatePortugalDay()
*/
public function testHolidayAfterRestoration(): void
{
$year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR_AFTER);
$expected = new DateTime("$year-06-10", new DateTimeZone(self::TIMEZONE));
$this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* Tests that the holiday defined in this test does not exist during the period that it was abolished.
*
* @throws ReflectionException
*
* @see Portugal::calculatePortugalDay()
*/
public function testNotHolidayDuringAbolishment(): void
{
$year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR_BEFORE + 1, self::ESTABLISHMENT_YEAR_AFTER - 1);
$this->assertNotHoliday(self::REGION, self::HOLIDAY, $year);
$this->assertNotHoliday(self::REGION, self::HOLIDAY, self::ESTABLISHMENT_YEAR_BEFORE + 1);
$this->assertNotHoliday(self::REGION, self::HOLIDAY, self::ESTABLISHMENT_YEAR_AFTER - 1);
}
/**
* Tests the translated name of the holiday defined in this test.
*
* @throws ReflectionException
*/
public function testTranslation(): void
{
$year = $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR_BEFORE);
$this->assertTranslatedHolidayName(self::REGION, self::HOLIDAY, $year, [self::LOCALE => 'Dia de Portugal']);
$year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR_AFTER);
$this->assertTranslatedHolidayName(self::REGION, self::HOLIDAY, $year, [self::LOCALE => 'Dia de Portugal']);
}
/**
* Tests type of the holiday defined in this test.
*
* @throws ReflectionException
*/
public function testHolidayType(): void
{
$year = $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR_BEFORE);
$this->assertHolidayType(self::REGION, self::HOLIDAY, $year, Holiday::TYPE_OFFICIAL);
$year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR_AFTER);
$this->assertHolidayType(self::REGION, self::HOLIDAY, $year, Holiday::TYPE_OFFICIAL);
}
}