Skip to content

Commit

Permalink
Add Liberation Day
Browse files Browse the repository at this point in the history
Signed-off-by: Sacha Telgenhof <[email protected]>
  • Loading branch information
stelgenhof committed Nov 1, 2024
1 parent bf19eab commit 5e84d12
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 19 deletions.
13 changes: 6 additions & 7 deletions src/Yasumi/Provider/Bulgaria.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,12 @@ public function initialize(): void
// '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));

if ($this->year >= 1990) {
$this->addHoliday(new Holiday('liberationDay', [
'bg' => 'Ден на Освобождението на България от османско иго',
], new \DateTime("{$this->year}-03-03", DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale));
}
}

public function getSources(): array
Expand Down
19 changes: 8 additions & 11 deletions tests/Bulgaria/BulgariaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,15 @@ protected function setUp(): void

public function testOfficialHolidays(): void
{
$this->assertDefinedHolidays([
$holidays = [
'newYearsDay',
// 'dayAfterNewYearsDay',
// 'internationalWorkersDay',
// 'secondLabourDay',
// 'christmasDay',
// 'easter',
// 'allSaintsDay',
// 'statehoodDay',
// 'independenceDay',
// 'orthodoxChristmasDay',
], self::REGION, $this->year, Holiday::TYPE_OFFICIAL);
];

if ($this->year >= 1990) {
$holidays[] = 'liberationDay';
}

$this->assertDefinedHolidays($holidays, self::REGION, $this->year, Holiday::TYPE_OFFICIAL);
}

public function testObservedHolidays(): void
Expand Down
67 changes: 67 additions & 0 deletions tests/Bulgaria/LiberationDayTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?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 LiberationDayTest extends BulgariaBaseTestCase implements HolidayTestCase
{
public const HOLIDAY = 'liberationDay';

private const ESTABLISHMENT_YEAR = 1990;

public function testHoliday(): void
{
$year = self::ESTABLISHMENT_YEAR;
$this->assertHoliday(
self::REGION,
self::HOLIDAY,
$year,
new \DateTime("{$year}-03-03", new \DateTimeZone(self::TIMEZONE))
);
}

public function testNotHoliday(): void
{
$this->assertNotHoliday(self::REGION, self::HOLIDAY, self::ESTABLISHMENT_YEAR - 1);
}

/**
* @return array<array<int, \DateTime>>
*/
public function HolidayDataProvider(): array
{
return $this->generateRandomDates(3, 3, self::TIMEZONE, null, 2000);
}

public function testTranslation(): void
{
$this->assertTranslatedHolidayName(
self::REGION,
self::HOLIDAY,
$this->generateRandomYear(self::ESTABLISHMENT_YEAR),
[self::LOCALE => 'Ден на Освобождението на България от османско иго']
);
}

public function testHolidayType(): void
{
$this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(self::ESTABLISHMENT_YEAR), Holiday::TYPE_OFFICIAL);
}
}
5 changes: 4 additions & 1 deletion tests/Bulgaria/NewYearsDayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ class NewYearsDayTest extends BulgariaBaseTestCase implements HolidayTestCase
/**
* @dataProvider HolidayDataProvider
*/
public function testHoliday(int $year, \DateTimeInterface $expected): void
public function testHoliday(int $year, \DateTime $expected): void
{
$this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}

/**
* @return array<array<int, \DateTime>>
*/
public function HolidayDataProvider(): array
{
return $this->generateRandomDates(1, 1, self::TIMEZONE);
Expand Down

0 comments on commit 5e84d12

Please sign in to comment.