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

Suspended holidays in Portugal 2013-2015 #163

Merged
merged 4 commits into from
Aug 29, 2019
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 @@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Fixed
- Late Summer Bank Holiday in 1968 and 1969 in United Kingdom [\#161](https://github.com/azuyalabs/yasumi/pull/161) ([c960657](https://github.com/c960657))
- Fixed one-off exceptions for May Day Bank Holiday in 1995 and 2020 and Spring Bank Holiday in 2002 and 2012 (United Kingdom) [\#160](https://github.com/azuyalabs/yasumi/pull/160) ([c960657](https://github.com/c960657))
- Fixed revoked holidays in Portugal in 2013-2015 [\#163](https://github.com/azuyalabs/yasumi/pull/163) ([c960657](https://github.com/c960657))

### Removed

Expand Down
4 changes: 2 additions & 2 deletions src/Yasumi/Provider/Brazil.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function initialize(): void
$carnavalMonday->sub(new DateInterval('P48D')),
$this->locale,
Holiday::TYPE_OBSERVANCE
));
));

$carnavalTuesday = clone $easter;
$this->addHoliday(new Holiday(
Expand All @@ -80,7 +80,7 @@ public function initialize(): void
$carnavalTuesday->sub(new DateInterval('P47D')),
$this->locale,
Holiday::TYPE_OBSERVANCE
));
));
}

/**
Expand Down
14 changes: 9 additions & 5 deletions src/Yasumi/Provider/Portugal.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private function calculateCarnationRevolutionDay(): void
*/
private function calculateCorpusChristi(): void
{
if ($this->year <= 2013 || $this->year >= 2016) {
if ($this->year <= 2012 || $this->year >= 2016) {
$this->addHoliday($this->corpusChristi($this->year, $this->timezone, $this->locale));
}
}
Expand Down Expand Up @@ -153,6 +153,8 @@ private function calculatePortugalDay(): void
* presented itself as the only one that had a programme that was capable of returning to the country its lost
* status and place Portugal on the way of progress.
*
* The holiday was revoked in 2013 due to government deliberation. It was restored in 2016.
*
* @link https://en.wikipedia.org/wiki/5_October_1910_revolution
*
* @throws \Yasumi\Exception\InvalidDateException
Expand All @@ -162,7 +164,7 @@ private function calculatePortugalDay(): void
*/
private function calculatePortugueseRepublicDay(): void
{
if ($this->year >= 1910) {
if ($this->year >= 1910 && $this->year <= 2012 || $this->year >= 2016) {
$this->addHoliday(new Holiday(
'portugueseRepublic',
['pt_PT' => 'Implantação da República Portuguesa'],
Expand All @@ -173,7 +175,7 @@ private function calculatePortugueseRepublicDay(): void
}

/**
* In Portugal, between 2013 andd 2015 (inclusive) this holiday did not happen due to government deliberation.
* In Portugal, between 2013 and 2015 (inclusive) this holiday did not happen due to government deliberation.
* It was restored in 2016.
*
* @throws \Yasumi\Exception\InvalidDateException
Expand All @@ -183,7 +185,7 @@ private function calculatePortugueseRepublicDay(): void
*/
private function calculateAllSaintsDay(): void
{
if ($this->year <= 2013 || $this->year >= 2016) {
if ($this->year <= 2012 || $this->year >= 2016) {
$this->addHoliday($this->allSaintsDay($this->year, $this->timezone, $this->locale));
}
}
Expand All @@ -205,6 +207,8 @@ private function calculateAllSaintsDay(): void
* and elsewhere, as the Acclamation War. The war established the House of Braganza as Portugal's new ruling
* dynasty, replacing the House of Habsburg. This ended the so-called Iberian Union.
*
* The holiday was revoked in 2013 due to government deliberation. It was restored in 2016.
*
* @link https://pt.wikipedia.org/wiki/Restauração_da_Independência (portuguese link)
* @link https://pt.wikipedia.org/wiki/Guerra_da_Restauração (english link)
*
Expand All @@ -216,7 +220,7 @@ private function calculateAllSaintsDay(): void
private function calculateRestorationOfIndependenceDay(): void
{
// The Wikipedia article mentions that this has been a holiday since the second of half of the XIX century.
if (($this->year >= 1850 && $this->year <= 2013) || $this->year >= 2016) {
if (($this->year >= 1850 && $this->year <= 2012) || $this->year >= 2016) {
$this->addHoliday(new Holiday(
'restorationOfIndependence',
['pt_PT' => 'Restauração da Independência'],
Expand Down
10 changes: 5 additions & 5 deletions tests/Portugal/AllSaintsDayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ class AllSaintsDayTest extends PortugalBaseTestCase implements YasumiTestCaseInt
public const HOLIDAY = 'allSaintsDay';

/**
* Holiday was abolished by the portuguese government in 2014.
* Holiday was abolished by the portuguese government in 2013.
*/
public const HOLIDAY_YEAR_ABOLISHED = 2014;
public const HOLIDAY_YEAR_ABOLISHED = 2013;

/**
* Holiday was restored by the portuguese government in 2016.
Expand All @@ -50,18 +50,18 @@ public function testHoliday()
$expected = new DateTime("$year-11-01", new DateTimeZone(self::TIMEZONE));
$this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);

$year = 2013;
$year = 2012;
$expected = new DateTime("$year-11-01", new DateTimeZone(self::TIMEZONE));
$this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}

/**
* Test that the holiday did not happen in 2014 and 2015.
* Test that the holiday did not happen in 2013-2015.
* @throws \ReflectionException
*/
public function testNotHoliday()
{
$year = $this->generateRandomYear(2014, 2015);
$year = $this->generateRandomYear(2013, 2015);
$this->assertNotHoliday(self::REGION, self::HOLIDAY, $year);
}

Expand Down
6 changes: 3 additions & 3 deletions tests/Portugal/CorpusChristiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class CorpusChristiTest extends PortugalBaseTestCase implements YasumiTestCaseIn
/**
* Holiday was abolished by the portuguese government in 2014.
*/
public const HOLIDAY_YEAR_ABOLISHED = 2014;
public const HOLIDAY_YEAR_ABOLISHED = 2013;

/**
* Holiday was restored by the portuguese government in 2016.
Expand All @@ -50,12 +50,12 @@ public function testHoliday()
}

/**
* Test that the holiday did not happen in 2014 and 2015.
* Test that the holiday did not happen in 2013-2015.
* @throws \ReflectionException
*/
public function testNotHoliday()
{
$year = $this->generateRandomYear(2014, 2015);
$year = $this->generateRandomYear(2013, 2015);
$this->assertNotHoliday(self::REGION, self::HOLIDAY, $year);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Portugal/PortugalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function testOtherHolidays(): void
{
$holidays = [];

if ($this->year <= 2013 || $this->year >= 2016) {
if ($this->year <= 2012 || $this->year >= 2016) {
$holidays[] = 'corpusChristi';
}

Expand Down
40 changes: 40 additions & 0 deletions tests/Portugal/PortugueseRepublicDayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,51 @@ class PortugueseRepublicDayTest extends PortugalBaseTestCase implements YasumiTe
*/
public const ESTABLISHMENT_YEAR = 1910;

/**
* Holiday was abolished by the portuguese government in 2013.
*/
public const HOLIDAY_YEAR_ABOLISHED = 2013;

/**
* Holiday was restored by the portuguese government in 2016.
*/
public const HOLIDAY_YEAR_RESTORED = 2016;

/**
* The name of the holiday to be tested
*/
public const HOLIDAY = 'portugueseRepublic';

/**
* Test that the holiday if in effect in 2016 and later dates.
* @throws \ReflectionException
* @throws \Exception
* @throws \ReflectionException
* @throws \Exception
*/
public function testHolidayOnAfterRestoration()
{
$year = self::HOLIDAY_YEAR_RESTORED;

$expected = new DateTime("$year-10-05", new DateTimeZone(self::TIMEZONE));
$this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);

$year = $this->generateRandomYear(self::HOLIDAY_YEAR_RESTORED);

$expected = new DateTime("$year-10-05", new DateTimeZone(self::TIMEZONE));
$this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}

/**
* Test that the holiday did not happen in 2013-2015.
* @throws \ReflectionException
*/
public function testNotHolidayDuringAbolishment()
{
$year = $this->generateRandomYear(2013, 2015);
$this->assertNotHoliday(self::REGION, self::HOLIDAY, $year);
}

/**
* Tests the holiday defined in this test on or after establishment.
* @throws \ReflectionException
Expand Down
10 changes: 5 additions & 5 deletions tests/Portugal/RestorationOfIndependenceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ class RestorationOfIndependenceTest extends PortugalBaseTestCase implements Yasu
public const ESTABLISHMENT_YEAR = 1850;

/**
* Holiday was abolished by the portuguese government in 2014.
* Holiday was abolished by the portuguese government in 2013.
*/
public const HOLIDAY_YEAR_ABOLISHED = 2014;
public const HOLIDAY_YEAR_ABOLISHED = 2013;

/**
* Holiday was restored by the portuguese government in 2016.
Expand All @@ -56,7 +56,7 @@ public function testHolidayOnAfterEstablishment()
$expected = new DateTime("$year-12-01", new DateTimeZone(self::TIMEZONE));
$this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);

$year = 1850;
$year = self::ESTABLISHMENT_YEAR;
$expected = new DateTime("$year-12-01", new DateTimeZone(self::TIMEZONE));
$this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
Expand All @@ -82,12 +82,12 @@ public function testHolidayOnAfterRestoration()
}

/**
* Test that the holiday did not happen in 2014 and 2015.
* Test that the holiday did not happen in 2013-2015.
* @throws \ReflectionException
*/
public function testNotHolidayDuringAbolishment()
{
$year = $this->generateRandomYear(2014, 2015);
$year = $this->generateRandomYear(2013, 2015);
$this->assertNotHoliday(self::REGION, self::HOLIDAY, $year);
}

Expand Down