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.
Fixed Brazilian Carnaval Day, added Ash Wednesday to Brazilian Holida…
…ys (azuyalabs#92) * Fixed Brazilian Carnaval Day, added Ash Wednesday to Brazilian Holidays and added/modified related unit tests.
- Loading branch information
1 parent
7305bdf
commit f61bf64
Showing
6 changed files
with
174 additions
and
17 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
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,64 @@ | ||
<?php | ||
/** | ||
* This file is part of the Yasumi package. | ||
* | ||
* Copyright (c) 2015 - 2018 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\Brazil; | ||
|
||
use DateTime; | ||
use DateTimeZone; | ||
use Yasumi\Holiday; | ||
use Yasumi\tests\YasumiTestCaseInterface; | ||
|
||
/** | ||
* Class for testing Ash Wednesday in the Brazil. | ||
*/ | ||
class AshWednesdayTest extends BrazilBaseTestCase implements YasumiTestCaseInterface | ||
{ | ||
/** | ||
* The name of the holiday | ||
*/ | ||
const HOLIDAY = 'ashWednesday'; | ||
|
||
/** | ||
* Tests the holiday defined in this test. | ||
*/ | ||
public function testHoliday() | ||
{ | ||
$year = 1999; | ||
$this->assertHoliday( | ||
self::REGION, | ||
self::HOLIDAY, | ||
$year, | ||
new DateTime("$year-2-17", new DateTimeZone(self::TIMEZONE)) | ||
); | ||
} | ||
|
||
/** | ||
* Tests translated name of Ash Wednesday. | ||
*/ | ||
public function testTranslation() | ||
{ | ||
$this->assertTranslatedHolidayName( | ||
self::REGION, | ||
self::HOLIDAY, | ||
$this->generateRandomYear(), | ||
[self::LOCALE => 'Quarta-feira de Cinzas'] | ||
); | ||
} | ||
|
||
/** | ||
* Tests type of the holiday defined in this test. | ||
*/ | ||
public function testHolidayType() | ||
{ | ||
$this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OBSERVANCE); | ||
} | ||
} |
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
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,77 @@ | ||
<?php | ||
/** | ||
* This file is part of the Yasumi package. | ||
* | ||
* Copyright (c) 2015 - 2018 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\Brazil; | ||
|
||
use DateInterval; | ||
use Yasumi\Holiday; | ||
use Yasumi\Provider\ChristianHolidays; | ||
use Yasumi\tests\YasumiTestCaseInterface; | ||
|
||
/** | ||
* Class for testing Carnaval Tuesday in Brazil. | ||
*/ | ||
class CarnavalTuesdayTest extends BrazilBaseTestCase implements YasumiTestCaseInterface | ||
{ | ||
use ChristianHolidays; | ||
|
||
/** | ||
* The name of the holiday | ||
*/ | ||
const HOLIDAY = 'carnavalTuesday'; | ||
|
||
/** | ||
* The year in which the holiday was first established | ||
*/ | ||
const ESTABLISHMENT_YEAR = 1700; | ||
|
||
/** | ||
* Tests Carnaval Tuesday on or after 1700. | ||
*/ | ||
public function testCarnavalTuesdayAfter1700() | ||
{ | ||
$year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR); | ||
$this->assertHoliday( | ||
self::REGION, | ||
self::HOLIDAY, | ||
$year, | ||
$this->calculateEaster($year, self::TIMEZONE)->sub(new DateInterval('P47D')) | ||
); | ||
} | ||
|
||
/** | ||
* Tests Carnaval Tuesday on or before 1700. | ||
*/ | ||
public function testCarnavalTuesdayBefore1700() | ||
{ | ||
$year = $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1); | ||
$this->assertNotHoliday(self::REGION, self::HOLIDAY, $year); | ||
} | ||
|
||
/** | ||
* Tests the translated name of the holiday defined in this test. | ||
*/ | ||
public function testTranslation() | ||
{ | ||
$year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR); | ||
$this->assertTranslatedHolidayName(self::REGION, self::HOLIDAY, $year, [self::LOCALE => 'Terça-feira de Carnaval']); | ||
} | ||
|
||
/** | ||
* Tests type of the holiday defined in this test. | ||
*/ | ||
public function testHolidayType() | ||
{ | ||
$year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR); | ||
$this->assertHolidayType(self::REGION, self::HOLIDAY, $year, Holiday::TYPE_OBSERVANCE); | ||
} | ||
} |