-
-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial code for the Bulgaria provider
Signed-off-by: Sacha Telgenhof <[email protected]>
- Loading branch information
1 parent
004ce27
commit 655016d
Showing
5 changed files
with
252 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
/** | ||
* This file is part of the 'Yasumi' package. | ||
* | ||
* The easy PHP Library for calculating holidays. | ||
* | ||
* Copyright (c) 2015 - 2024 AzuyaLabs | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @author Sacha Telgenhof <me at sachatelgenhof dot com> | ||
*/ | ||
|
||
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', | ||
]; | ||
} | ||
} |
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,32 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
/** | ||
* This file is part of the 'Yasumi' package. | ||
* | ||
* The easy PHP Library for calculating holidays. | ||
* | ||
* Copyright (c) 2015 - 2024 AzuyaLabs | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @author Sacha Telgenhof <me at sachatelgenhof dot com> | ||
*/ | ||
|
||
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'; | ||
} |
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,72 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
/** | ||
* This file is part of the 'Yasumi' package. | ||
* | ||
* The easy PHP Library for calculating holidays. | ||
* | ||
* Copyright (c) 2015 - 2024 AzuyaLabs | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @author Sacha Telgenhof <me at sachatelgenhof dot com> | ||
*/ | ||
|
||
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); | ||
} | ||
} |
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,54 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
/** | ||
* This file is part of the 'Yasumi' package. | ||
* | ||
* The easy PHP Library for calculating holidays. | ||
* | ||
* Copyright (c) 2015 - 2024 AzuyaLabs | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @author Sacha Telgenhof <me at sachatelgenhof dot com> | ||
*/ | ||
|
||
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); | ||
} | ||
} |