diff --git a/src/Yasumi/Provider/Bulgaria.php b/src/Yasumi/Provider/Bulgaria.php new file mode 100644 index 000000000..30b9e866d --- /dev/null +++ b/src/Yasumi/Provider/Bulgaria.php @@ -0,0 +1,93 @@ + + */ + +namespace Yasumi\Provider; + +use Yasumi\Holiday; + +class Bulgaria extends AbstractProvider +{ + use CommonHolidays; + use ChristianHolidays; + + public const ID = 'BG'; + + public function initialize(): void + { + $this->timezone = 'Europe/Sofia'; + + // // Add common holidays + $this->addHoliday($this->newYearsDay($this->year, $this->timezone, $this->locale)); + // $this->addHoliday($this->internationalWorkersDay($this->year, $this->timezone, $this->locale)); + // + // // Add Catholic holidays + // $this->addHoliday($this->easter($this->year, $this->timezone, $this->locale)); + // $this->addHoliday($this->allSaintsDay($this->year, $this->timezone, $this->locale)); + // $this->addHoliday($this->christmasDay($this->year, $this->timezone, $this->locale)); + // + // // Add Orthodox holidays + // + // $this->addHoliday(new Holiday('orthodoxChristmasDay', [ + // 'en' => 'Orthodox Christmas Day', + // 'bs_Latn' => 'Pravoslavni Božić', + // ], new \DateTime("{$this->year}-01-07", DateTimeZoneFactory::getDateTimeZone($this->timezone)))); + // + // /* + // * Independence Day + // */ + // if ($this->year >= 1992) { + // $this->addHoliday(new Holiday('independenceDay', [ + // 'en' => 'Independence Day', + // 'bs_Latn' => 'Dan Nezavisnosti', + // ], new \DateTime("{$this->year}-3-1", DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale)); + // } + // + // /* + // * Bulgarian Statehood Day + // */ + // if ($this->year >= 1943) { + // $this->addHoliday(new Holiday('statehoodDay', [ + // 'en' => 'Statehood Day', + // 'bs_Latn' => 'Dan državnosti', + // ], new \DateTime("{$this->year}-11-25", DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale)); + // } + // + // /* + // * Day after New Years Day + // */ + // $this->addHoliday(new Holiday('dayAfterNewYearsDay', [ + // 'en' => 'Day after New Year’s Day', + // 'bs_Latn' => 'Nova godina - drugi dan', + // ], new \DateTime("{$this->year}-01-02", DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale)); + // + // /* + // * Second Labour day + // */ + // $this->addHoliday(new Holiday('secondLabourDay', [ + // 'en' => 'Second Labour Day', + // 'bs_Latn' => 'Praznik rada - drugi dan', + // ], new \DateTime("{$this->year}-05-02", DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale)); + } + + public function getSources(): array + { + return [ + 'https://en.wikipedia.org/wiki/Public_holidays_in_Bulgaria', + 'https://bg.wikipedia.org/wiki/%D0%9E%D1%84%D0%B8%D1%86%D0%B8%D0%B0%D0%BB%D0%BD%D0%B8_%D0%BF%D1%80%D0%B0%D0%B7%D0%BD%D0%B8%D1%86%D0%B8_%D0%B2_%D0%91%D1%8A%D0%BB%D0%B3%D0%B0%D1%80%D0%B8%D1%8F', + ]; + } +} diff --git a/src/Yasumi/data/translations/newYearsDay.php b/src/Yasumi/data/translations/newYearsDay.php index 36694372d..a7fe66f27 100644 --- a/src/Yasumi/data/translations/newYearsDay.php +++ b/src/Yasumi/data/translations/newYearsDay.php @@ -18,6 +18,7 @@ // Translations for New Year's Day return [ 'bs_Latn' => 'Nova godina', + 'bg' => 'Нова година', 'ca' => 'Cap d’any', 'cs' => 'Nový rok', 'cy' => 'Dydd Calan', diff --git a/tests/Bulgaria/BulgariaBaseTestCase.php b/tests/Bulgaria/BulgariaBaseTestCase.php new file mode 100644 index 000000000..6cd208810 --- /dev/null +++ b/tests/Bulgaria/BulgariaBaseTestCase.php @@ -0,0 +1,32 @@ + + */ + +namespace Yasumi\tests\Bulgaria; + +use PHPUnit\Framework\TestCase; +use Yasumi\tests\YasumiBase; + +abstract class BulgariaBaseTestCase extends TestCase +{ + use YasumiBase; + + public const REGION = 'Bulgaria'; + + public const TIMEZONE = 'Europe/Sofia'; + + public const LOCALE = 'bg_BG'; +} diff --git a/tests/Bulgaria/BulgariaTest.php b/tests/Bulgaria/BulgariaTest.php new file mode 100644 index 000000000..257da2df9 --- /dev/null +++ b/tests/Bulgaria/BulgariaTest.php @@ -0,0 +1,72 @@ + + */ + +namespace Yasumi\tests\Bulgaria; + +use Yasumi\Holiday; +use Yasumi\tests\ProviderTestCase; + +class BulgariaTest extends BulgariaBaseTestCase implements ProviderTestCase +{ + protected int $year; + + protected function setUp(): void + { + $this->year = $this->generateRandomYear(); + } + + public function testOfficialHolidays(): void + { + $this->assertDefinedHolidays([ + 'newYearsDay', + // 'dayAfterNewYearsDay', + // 'internationalWorkersDay', + // 'secondLabourDay', + // 'christmasDay', + // 'easter', + // 'allSaintsDay', + // 'statehoodDay', + // 'independenceDay', + // 'orthodoxChristmasDay', + ], self::REGION, $this->year, Holiday::TYPE_OFFICIAL); + } + + public function testObservedHolidays(): void + { + $this->assertDefinedHolidays([], self::REGION, $this->year, Holiday::TYPE_OBSERVANCE); + } + + public function testSeasonalHolidays(): void + { + $this->assertDefinedHolidays([], self::REGION, $this->year, Holiday::TYPE_SEASON); + } + + public function testBankHolidays(): void + { + $this->assertDefinedHolidays([], self::REGION, $this->year, Holiday::TYPE_BANK); + } + + public function testOtherHolidays(): void + { + $this->assertDefinedHolidays([], self::REGION, $this->year, Holiday::TYPE_OTHER); + } + + public function testSources(): void + { + $this->assertSources(self::REGION, 2); + } +} diff --git a/tests/Bulgaria/NewYearsDayTest.php b/tests/Bulgaria/NewYearsDayTest.php new file mode 100644 index 000000000..3577d9e0b --- /dev/null +++ b/tests/Bulgaria/NewYearsDayTest.php @@ -0,0 +1,54 @@ + + */ + +namespace Yasumi\tests\Bulgaria; + +use Yasumi\Holiday; +use Yasumi\tests\HolidayTestCase; + +class NewYearsDayTest extends BulgariaBaseTestCase implements HolidayTestCase +{ + public const HOLIDAY = 'newYearsDay'; + + /** + * @dataProvider HolidayDataProvider + */ + public function testHoliday(int $year, \DateTimeInterface $expected): void + { + $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected); + } + + public function HolidayDataProvider(): array + { + return $this->generateRandomDates(1, 1, self::TIMEZONE); + } + + public function testTranslation(): void + { + $this->assertTranslatedHolidayName( + self::REGION, + self::HOLIDAY, + $this->generateRandomYear(), + [self::LOCALE => 'Нова година'] + ); + } + + public function testHolidayType(): void + { + $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL); + } +}