generated from spatie/package-skeleton-php
-
-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from KiritoXD01/main
Added Dominican Republic holidays
- Loading branch information
Showing
3 changed files
with
86 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,29 @@ | ||
<?php | ||
|
||
namespace Spatie\Holidays\Countries; | ||
|
||
use Carbon\CarbonImmutable; | ||
|
||
class DominicanRepublic extends Country | ||
{ | ||
public function countryCode(): string | ||
{ | ||
return 'do'; | ||
} | ||
|
||
/** @return array<string, CarbonImmutable | string> */ | ||
protected function allHolidays(int $year): array | ||
{ | ||
return [ | ||
'Año Nuevo' => '01-01', | ||
'Día de la Altagracia' => '01-21', | ||
'Día de Duarte' => '01-26', | ||
'Día de la Independencia' => '02-27', | ||
'Día del Trabajo' => '05-01', | ||
'Día de la Restauración' => '08-16', | ||
'Día de las Mercedes' => '09-24', | ||
'Día de la Constitución' => '11-06', | ||
'Navidad' => '12-25', | ||
]; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...apshots/Countries/DominicanRepublicTest/it_can_calculate_dominican_republic_holidays.snap
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,38 @@ | ||
[ | ||
{ | ||
"name": "A\u00f1o Nuevo", | ||
"date": "2024-01-01" | ||
}, | ||
{ | ||
"name": "D\u00eda de la Altagracia", | ||
"date": "2024-01-21" | ||
}, | ||
{ | ||
"name": "D\u00eda de Duarte", | ||
"date": "2024-01-26" | ||
}, | ||
{ | ||
"name": "D\u00eda de la Independencia", | ||
"date": "2024-02-27" | ||
}, | ||
{ | ||
"name": "D\u00eda del Trabajo", | ||
"date": "2024-05-01" | ||
}, | ||
{ | ||
"name": "D\u00eda de la Restauraci\u00f3n", | ||
"date": "2024-08-16" | ||
}, | ||
{ | ||
"name": "D\u00eda de las Mercedes", | ||
"date": "2024-09-24" | ||
}, | ||
{ | ||
"name": "D\u00eda de la Constituci\u00f3n", | ||
"date": "2024-11-06" | ||
}, | ||
{ | ||
"name": "Navidad", | ||
"date": "2024-12-25" | ||
} | ||
] |
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,19 @@ | ||
<?php | ||
|
||
namespace Spatie\Holidays\Tests\Countries; | ||
|
||
use Carbon\CarbonImmutable; | ||
use Spatie\Holidays\Holidays; | ||
|
||
it('can calculate dominican republic holidays', function () { | ||
CarbonImmutable::setTestNowAndTimezone('2024-01-01'); | ||
|
||
$holidays = Holidays::for(country: 'do')->get(); | ||
|
||
expect($holidays) | ||
->toBeArray() | ||
->not()->toBeEmpty(); | ||
|
||
expect(formatDates($holidays))->toMatchSnapshot(); | ||
}); | ||
|