From 7f6eddf83152f2431e3c3f308acc5698e48114e5 Mon Sep 17 00:00:00 2001 From: KyleKatarn Date: Tue, 21 Sep 2021 09:48:17 +0200 Subject: [PATCH] Add unit test --- tests/Cmixin/BusinessDayTest.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/Cmixin/BusinessDayTest.php b/tests/Cmixin/BusinessDayTest.php index 817c114..016ff6d 100644 --- a/tests/Cmixin/BusinessDayTest.php +++ b/tests/Cmixin/BusinessDayTest.php @@ -212,6 +212,22 @@ public function testMultipleIfRule() self::assertFalse($carbon::parse('2025-06-23')->isHoliday()); } + public function testIfRuleWithHijriCalendar() + { + $carbon = static::CARBON_CLASS; + $carbon::resetHolidays(); + $carbon::setHolidays('custom', [ + 'hari-raya-puasa' => '= 1 Shawwal if sunday then next monday', + ]); + $carbon::setHolidaysRegion('custom'); + $year = static function (int $year) use ($carbon) { + return array_map('strval', $carbon::getYearHolidays($year)); + }; + + self::assertSame(['hari-raya-puasa' => '2020-05-25 00:00:00'], $year(2020)); + self::assertSame(['hari-raya-puasa' => '2021-05-13 00:00:00'], $year(2021)); + } + public function testCaseInsensitivity() { $carbon = static::CARBON_CLASS;