diff --git a/src/Yasumi/Provider/Brazil.php b/src/Yasumi/Provider/Brazil.php index a3626b3b2..192423ae1 100644 --- a/src/Yasumi/Provider/Brazil.php +++ b/src/Yasumi/Provider/Brazil.php @@ -50,6 +50,7 @@ public function initialize() $this->addHoliday($this->easter($this->year, $this->timezone, $this->locale, Holiday::TYPE_OBSERVANCE)); $this->addHoliday($this->corpusChristi($this->year, $this->timezone, $this->locale, Holiday::TYPE_OBSERVANCE)); $this->addHoliday($this->goodFriday($this->year, $this->timezone, $this->locale)); + $this->addHoliday($this->ashWednesday($this->year, $this->timezone, $this->locale, Holiday::TYPE_OBSERVANCE)); /** * Carnaval @@ -60,13 +61,25 @@ public function initialize() * @link https://en.wikipedia.org/wiki/Brazilian_Carnival */ if ($this->year >= 1700) { + $easter = $this->calculateEaster($this->year, $this->timezone); + + $carnavalMonday = clone $easter; $this->addHoliday(new Holiday( - 'carnavalDay', - ['pt_BR' => 'Carnaval'], - $this->calculateEaster($this->year, $this->timezone)->sub(new DateInterval('P51D')), - $this->locale, - Holiday::TYPE_OBSERVANCE - )); + 'carnavalMonday', + ['pt_BR' => 'Segunda-feira de Carnaval'], + $carnavalMonday->sub(new DateInterval('P48D')), + $this->locale, + Holiday::TYPE_OBSERVANCE + )); + + $carnavalTuesday = clone $easter; + $this->addHoliday(new Holiday( + 'carnavalTuesday', + ['pt_BR' => 'Terça-feira de Carnaval'], + $carnavalTuesday->sub(new DateInterval('P47D')), + $this->locale, + Holiday::TYPE_OBSERVANCE + )); } /** diff --git a/src/Yasumi/data/translations/ashWednesday.php b/src/Yasumi/data/translations/ashWednesday.php index a0cbb4a00..9eb9d3f01 100644 --- a/src/Yasumi/data/translations/ashWednesday.php +++ b/src/Yasumi/data/translations/ashWednesday.php @@ -20,4 +20,5 @@ 'it_CH' => 'Mercoledi delle Ceneri', 'nl_BE' => 'Aswoensdag', 'nl_NL' => 'Aswoensdag', + 'pt_BR' => 'Quarta-feira de Cinzas', ]; diff --git a/tests/Brazil/AshWednesdayTest.php b/tests/Brazil/AshWednesdayTest.php new file mode 100644 index 000000000..617b93121 --- /dev/null +++ b/tests/Brazil/AshWednesdayTest.php @@ -0,0 +1,64 @@ + + */ + +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); + } +} diff --git a/tests/Brazil/BrazilTest.php b/tests/Brazil/BrazilTest.php index 0991ea04b..59a1148c4 100644 --- a/tests/Brazil/BrazilTest.php +++ b/tests/Brazil/BrazilTest.php @@ -48,9 +48,11 @@ public function testOfficialHolidays() public function testObservedHolidays() { $this->assertDefinedHolidays([ - 'carnavalDay', + 'carnavalMonday', + 'carnavalTuesday', 'easter', - 'corpusChristi' + 'corpusChristi', + 'ashWednesday', ], self::REGION, $this->year, Holiday::TYPE_OBSERVANCE); } diff --git a/tests/Brazil/CarnavalDayTest.php b/tests/Brazil/CarnavalMondayTest.php similarity index 78% rename from tests/Brazil/CarnavalDayTest.php rename to tests/Brazil/CarnavalMondayTest.php index 9ea5231c0..730abd13f 100644 --- a/tests/Brazil/CarnavalDayTest.php +++ b/tests/Brazil/CarnavalMondayTest.php @@ -18,16 +18,16 @@ use Yasumi\tests\YasumiTestCaseInterface; /** - * Class for testing Carnaval in Brazil. + * Class for testing Carnaval Monday in Brazil. */ -class CarnavalDayTest extends BrazilBaseTestCase implements YasumiTestCaseInterface +class CarnavalMondayTest extends BrazilBaseTestCase implements YasumiTestCaseInterface { use ChristianHolidays; /** * The name of the holiday */ - const HOLIDAY = 'carnavalDay'; + const HOLIDAY = 'carnavalMonday'; /** * The year in which the holiday was first established @@ -35,23 +35,23 @@ class CarnavalDayTest extends BrazilBaseTestCase implements YasumiTestCaseInterf const ESTABLISHMENT_YEAR = 1700; /** - * Tests Carnaval on or after 1700. + * Tests Carnaval Monday on or after 1700. */ - public function testCarnavalAfter1700() + public function testCarnavalMondayAfter1700() { $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR); $this->assertHoliday( self::REGION, self::HOLIDAY, $year, - $this->calculateEaster($year, self::TIMEZONE)->sub(new DateInterval('P51D')) + $this->calculateEaster($year, self::TIMEZONE)->sub(new DateInterval('P48D')) ); } /** - * Tests Carnaval on or before 1700. + * Tests Carnaval Monday on or before 1700. */ - public function testCarnavalBefore1700() + public function testCarnavalMondayBefore1700() { $year = $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1); $this->assertNotHoliday(self::REGION, self::HOLIDAY, $year); @@ -63,7 +63,7 @@ public function testCarnavalBefore1700() public function testTranslation() { $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR); - $this->assertTranslatedHolidayName(self::REGION, self::HOLIDAY, $year, [self::LOCALE => 'Carnaval']); + $this->assertTranslatedHolidayName(self::REGION, self::HOLIDAY, $year, [self::LOCALE => 'Segunda-feira de Carnaval']); } /** diff --git a/tests/Brazil/CarnavalTuesdayTest.php b/tests/Brazil/CarnavalTuesdayTest.php new file mode 100644 index 000000000..3da8b1c0a --- /dev/null +++ b/tests/Brazil/CarnavalTuesdayTest.php @@ -0,0 +1,77 @@ + + */ + +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); + } +}