Skip to content

Commit

Permalink
freeze test time
Browse files Browse the repository at this point in the history
  • Loading branch information
Nielsvanpach committed Jan 12, 2024
1 parent a2be944 commit 6a00a9f
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
{
"name": "Nieuwjaar",
"date": "01-01-2023"
},
{
"name": "Paasmaandag",
"date": "04-09-2023"
},
{
"name": "Dag van de Arbeid",
"date": "05-01-2023"
},
{
"name": "OH Hemelvaart",
"date": "05-17-2023"
},
{
"name": "Pinkstermaandag",
"date": "05-28-2023"
},
{
"name": "Nationale Feestdag",
"date": "07-21-2023"
},
{
"name": "OLV Hemelvaart",
"date": "08-15-2023"
},
{
"name": "Allerheiligen",
"date": "11-01-2023"
},
{
"name": "Wapenstilstand",
"date": "11-11-2023"
},
{
"name": "Kerstmis",
"date": "12-25-2023"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
{
"name": "Nieuwjaar",
"date": "01-01-2023"
},
{
"name": "Paasmaandag",
"date": "04-09-2023"
},
{
"name": "Dag van de Arbeid",
"date": "05-01-2023"
},
{
"name": "OH Hemelvaart",
"date": "05-17-2023"
},
{
"name": "Pinkstermaandag",
"date": "05-28-2023"
},
{
"name": "Nationale Feestdag",
"date": "07-21-2023"
},
{
"name": "OLV Hemelvaart",
"date": "08-15-2023"
},
{
"name": "Allerheiligen",
"date": "11-01-2023"
},
{
"name": "Wapenstilstand",
"date": "11-11-2023"
},
{
"name": "Kerstmis",
"date": "12-25-2023"
}
]
25 changes: 22 additions & 3 deletions tests/HolidaysTest.php
Original file line number Diff line number Diff line change
@@ -1,33 +1,52 @@
<?php

use Carbon\CarbonImmutable;
use Spatie\Holidays\Exceptions\HolidaysException;
use Spatie\Holidays\Holidays;

it('can get all holidays of the current year', function () {
CarbonImmutable::setTestNow('2024-01-01');

$holidays = Holidays::all();

expect($holidays)->toMatchSnapshot();
});

it('can get all holidays of another year', function () {
it('can get all holidays of 2022', function () {
$holidays = Holidays::new()
->year(2022)
->get();

expect($holidays)->toMatchSnapshot();
});

it('can get all holidays of 2023', function () {
$holidays = Holidays::new()
->year(2023)
->get();

expect($holidays)->toMatchSnapshot();
});

it('can get all holidays of 2025', function () {
$holidays = Holidays::new()
->year(2023)
->get();

expect($holidays)->toMatchSnapshot();
});

it('can get all holidays of another year and a specific country', function () {
$holidays = Holidays::new()
->year(2022)
->year(2023)
->country('BE')
->get();

expect($holidays)->toMatchSnapshot();
});

it('cannot get all holidays of an unknown country code', function () {
dd(Holidays::new()->country('unknown')->get());
Holidays::new()->country('unknown')->get();
})->throws(HolidaysException::class, 'Country code `unknown` is not supported');

it('cannot get holidays for years before 1970', function () {
Expand Down

0 comments on commit 6a00a9f

Please sign in to comment.