diff --git a/src/Countries/Spain.php b/src/Countries/Spain.php index 7815612e8..87c74b912 100644 --- a/src/Countries/Spain.php +++ b/src/Countries/Spain.php @@ -393,4 +393,116 @@ protected function regionHolidays2024(): array default => throw InvalidRegion::notFound($this->region), }; } + + protected function regionHolidays2025(): array + { + $sanJose = ['San José' => '03-19']; + $juevesSanto = ['Jueves Santo' => '04-17']; + $lunesPascua = ['Lunes de Pascua' => '04-21']; + $fiestaSacrificio = ['Fiesta del Sacrificio Eid al-Adha' => '06-07']; + $sanJuan = ['San Juan' => '06-24']; + $santiagoApostol = ['Santiago Apóstol' => '07-25']; + $inmaculadaConcepcion = ['Lunes siguiente a la Inmaculada Concepción' => '12-08']; + + return match ($this->region) { + // Andalucía + 'es-an' => [ + 'Día de Andalucía' => '02-28', + ] + $juevesSanto + $inmaculadaConcepcion, + + // Aragón + 'es-ar' => [ + 'San Jorge / Día de Aragón' => '04-23', + ] + $juevesSanto + $inmaculadaConcepcion, + + // Principado de Asturias + 'es-as' => [ + 'Día de Asturias' => '09-08', + ] + $juevesSanto + $inmaculadaConcepcion, + + // Cantabria + 'es-cb' => $juevesSanto + $lunesPascua + $santiagoApostol, + + // Ciudad Autónoma de Ceuta + 'es-ce' => [ + 'Nuestra Señora de África' => '08-05', + ] + $juevesSanto + $fiestaSacrificio, + + // Castilla y León + 'es-cl' => [ + 'Fiesta de Castilla y León' => '04-23', + ] + $juevesSanto + $inmaculadaConcepcion, + + // Castilla-La Mancha + 'es-cm' => [ + 'Corpus Christi' => '06-19', + 'Día de Castilla-La Mancha' => '05-31', + ] + $juevesSanto, + + // Canarias + 'es-cn' => [ + 'Día de Canarias' => '05-30', + ] + $juevesSanto, + + // Cataluña / Catalunya + 'es-ct' => [ + 'Fiesta Nacional de Cataluña' => '09-11', + 'San Esteban' => '12-26', + ] + $lunesPascua + $sanJuan, + + // Extremadura + 'es-ex' => [ + 'Día de Extremadura' => '09-08', + ] + $juevesSanto + $inmaculadaConcepcion, + + // Galicia + 'es-ga' => [ + 'Día de las Letras Gallegas' => '05-17', + 'Santiago Apóstol / Día de Galicia' => '07-25', + ] + $juevesSanto, + + // Islas Baleares / Illes Balears + 'es-ib' => [ + 'Día de les Illes Balears' => '03-01', + 'San Esteban' => '12-26', + ] + $juevesSanto + $lunesPascua, + + // Región de Murcia + 'es-mc' => [ + 'Día de la Región de Murcia' => '06-09' + ] + $sanJose + $juevesSanto + $inmaculadaConcepcion, + + // Comunidad de Madrid + 'es-md' => [ + 'Fiesta de la Comunidad de Madrid' => '05-02', + ] + $juevesSanto + $santiagoApostol, + + // Ciudad Autónoma de Melilla + 'es-ml' => $juevesSanto + $fiestaSacrificio + $inmaculadaConcepcion, + + // Comunidad Foral de Navarra / Nafarroako Foru Komunitatea + 'es-nc' => [ + 'Día de Navarra: San Francisco Javier' => '12-03', + ] + $juevesSanto + $lunesPascua + $santiagoApostol, + + // País Vasco / Euskal Herria + 'es-pv' => [ + 'Día del País Vasco / Euskadiko Eguna' => '10-25' + ] + $juevesSanto + $lunesPascua + $santiagoApostol, + + // La Rioja + 'es-ri' => [ + 'Lunes siguiente al Día de La Rioja' => '06-09', + ] + $juevesSanto + $lunesPascua, + + // Comunidad Valenciana / Comunitat Valenciana + 'es-vc' => [ + 'Día de la Comunidad Valenciana' => '10-09', + ] + $sanJose + $lunesPascua + $sanJuan, + + null => [], + default => throw InvalidRegion::notFound($this->region), + }; + } + } diff --git a/tests/.pest/snapshots/Countries/SpainTest/it_can_calculate_spanish_holidays_2022.snap b/tests/.pest/snapshots/Countries/SpainTest/it_can_calculate_spanish_holidays_2022.snap new file mode 100644 index 000000000..f1f10eaa6 --- /dev/null +++ b/tests/.pest/snapshots/Countries/SpainTest/it_can_calculate_spanish_holidays_2022.snap @@ -0,0 +1,42 @@ +[ + { + "name": "A\u00f1o Nuevo", + "date": "2022-01-01" + }, + { + "name": "Epifan\u00eda del Se\u00f1or", + "date": "2022-01-06" + }, + { + "name": "Viernes Santo", + "date": "2022-04-15" + }, + { + "name": "D\u00eda del Trabajador", + "date": "2022-05-01" + }, + { + "name": "Asunci\u00f3n de la Virgen", + "date": "2022-08-15" + }, + { + "name": "Fiesta Nacional de Espa\u00f1a", + "date": "2022-10-12" + }, + { + "name": "Todos los Santos", + "date": "2022-11-01" + }, + { + "name": "D\u00eda de la Constituci\u00f3n Espa\u00f1ola", + "date": "2022-12-06" + }, + { + "name": "Inmaculada Concepci\u00f3n", + "date": "2022-12-08" + }, + { + "name": "Navidad", + "date": "2022-12-25" + } +] \ No newline at end of file diff --git a/tests/.pest/snapshots/Countries/SpainTest/it_can_calculate_spanish_holidays_2023.snap b/tests/.pest/snapshots/Countries/SpainTest/it_can_calculate_spanish_holidays_2023.snap new file mode 100644 index 000000000..a88d29cf4 --- /dev/null +++ b/tests/.pest/snapshots/Countries/SpainTest/it_can_calculate_spanish_holidays_2023.snap @@ -0,0 +1,42 @@ +[ + { + "name": "A\u00f1o Nuevo", + "date": "2023-01-01" + }, + { + "name": "Epifan\u00eda del Se\u00f1or", + "date": "2023-01-06" + }, + { + "name": "Viernes Santo", + "date": "2023-04-07" + }, + { + "name": "D\u00eda del Trabajador", + "date": "2023-05-01" + }, + { + "name": "Asunci\u00f3n de la Virgen", + "date": "2023-08-15" + }, + { + "name": "Fiesta Nacional de Espa\u00f1a", + "date": "2023-10-12" + }, + { + "name": "Todos los Santos", + "date": "2023-11-01" + }, + { + "name": "D\u00eda de la Constituci\u00f3n Espa\u00f1ola", + "date": "2023-12-06" + }, + { + "name": "Inmaculada Concepci\u00f3n", + "date": "2023-12-08" + }, + { + "name": "Navidad", + "date": "2023-12-25" + } +] \ No newline at end of file diff --git a/tests/.pest/snapshots/Countries/SpainTest/it_can_calculate_spanish_holidays.snap b/tests/.pest/snapshots/Countries/SpainTest/it_can_calculate_spanish_holidays_2024.snap similarity index 100% rename from tests/.pest/snapshots/Countries/SpainTest/it_can_calculate_spanish_holidays.snap rename to tests/.pest/snapshots/Countries/SpainTest/it_can_calculate_spanish_holidays_2024.snap diff --git a/tests/.pest/snapshots/Countries/SpainTest/it_can_calculate_spanish_holidays_2025.snap b/tests/.pest/snapshots/Countries/SpainTest/it_can_calculate_spanish_holidays_2025.snap new file mode 100644 index 000000000..459e27019 --- /dev/null +++ b/tests/.pest/snapshots/Countries/SpainTest/it_can_calculate_spanish_holidays_2025.snap @@ -0,0 +1,42 @@ +[ + { + "name": "A\u00f1o Nuevo", + "date": "2025-01-01" + }, + { + "name": "Epifan\u00eda del Se\u00f1or", + "date": "2025-01-06" + }, + { + "name": "Viernes Santo", + "date": "2025-04-18" + }, + { + "name": "D\u00eda del Trabajador", + "date": "2025-05-01" + }, + { + "name": "Asunci\u00f3n de la Virgen", + "date": "2025-08-15" + }, + { + "name": "Fiesta Nacional de Espa\u00f1a", + "date": "2025-10-12" + }, + { + "name": "Todos los Santos", + "date": "2025-11-01" + }, + { + "name": "D\u00eda de la Constituci\u00f3n Espa\u00f1ola", + "date": "2025-12-06" + }, + { + "name": "Inmaculada Concepci\u00f3n", + "date": "2025-12-08" + }, + { + "name": "Navidad", + "date": "2025-12-25" + } +] \ No newline at end of file diff --git a/tests/.pest/snapshots/Countries/SpainTest/it_can_calculate_spanish_regional_holidays_2022.snap b/tests/.pest/snapshots/Countries/SpainTest/it_can_calculate_spanish_regional_holidays_2022.snap new file mode 100644 index 000000000..d55cf4340 --- /dev/null +++ b/tests/.pest/snapshots/Countries/SpainTest/it_can_calculate_spanish_regional_holidays_2022.snap @@ -0,0 +1,58 @@ +[ + { + "name": "A\u00f1o Nuevo", + "date": "2022-01-01" + }, + { + "name": "Epifan\u00eda del Se\u00f1or", + "date": "2022-01-06" + }, + { + "name": "Jueves Santo", + "date": "2022-04-14" + }, + { + "name": "Viernes Santo", + "date": "2022-04-15" + }, + { + "name": "Lunes siguiente a San Jorge, D\u00eda de Arag\u00f3n", + "date": "2022-04-23" + }, + { + "name": "D\u00eda del Trabajador", + "date": "2022-05-01" + }, + { + "name": "Lunes siguiente a la Fiesta del Trabajo", + "date": "2022-05-02" + }, + { + "name": "Asunci\u00f3n de la Virgen", + "date": "2022-08-15" + }, + { + "name": "Fiesta Nacional de Espa\u00f1a", + "date": "2022-10-12" + }, + { + "name": "Todos los Santos", + "date": "2022-11-01" + }, + { + "name": "D\u00eda de la Constituci\u00f3n Espa\u00f1ola", + "date": "2022-12-06" + }, + { + "name": "Inmaculada Concepci\u00f3n", + "date": "2022-12-08" + }, + { + "name": "Navidad", + "date": "2022-12-25" + }, + { + "name": "Lunes siguiente a Navidad", + "date": "2022-12-26" + } +] \ No newline at end of file diff --git a/tests/.pest/snapshots/Countries/SpainTest/it_can_calculate_spanish_regional_holidays_2023.snap b/tests/.pest/snapshots/Countries/SpainTest/it_can_calculate_spanish_regional_holidays_2023.snap new file mode 100644 index 000000000..88fcddd8e --- /dev/null +++ b/tests/.pest/snapshots/Countries/SpainTest/it_can_calculate_spanish_regional_holidays_2023.snap @@ -0,0 +1,54 @@ +[ + { + "name": "A\u00f1o Nuevo", + "date": "2023-01-01" + }, + { + "name": "Lunes siguiente a la Fiesta de A\u00f1o Nuevo", + "date": "2023-01-02" + }, + { + "name": "Epifan\u00eda del Se\u00f1or", + "date": "2023-01-06" + }, + { + "name": "Jueves Santo", + "date": "2023-04-06" + }, + { + "name": "Viernes Santo", + "date": "2023-04-07" + }, + { + "name": "Lunes siguiente a San Jorge, D\u00eda de Arag\u00f3n", + "date": "2023-04-24" + }, + { + "name": "D\u00eda del Trabajador", + "date": "2023-05-01" + }, + { + "name": "Asunci\u00f3n de la Virgen", + "date": "2023-08-15" + }, + { + "name": "Fiesta Nacional de Espa\u00f1a", + "date": "2023-10-12" + }, + { + "name": "Todos los Santos", + "date": "2023-11-01" + }, + { + "name": "D\u00eda de la Constituci\u00f3n Espa\u00f1ola", + "date": "2023-12-06" + }, + { + "name": "Inmaculada Concepci\u00f3n", + "date": "2023-12-08" + }, + { + "name": "Navidad", + "date": "2023-12-25" + } +] \ No newline at end of file diff --git a/tests/.pest/snapshots/Countries/SpainTest/it_can_calculate_spanish_regional_holidays.snap b/tests/.pest/snapshots/Countries/SpainTest/it_can_calculate_spanish_regional_holidays_2024.snap similarity index 100% rename from tests/.pest/snapshots/Countries/SpainTest/it_can_calculate_spanish_regional_holidays.snap rename to tests/.pest/snapshots/Countries/SpainTest/it_can_calculate_spanish_regional_holidays_2024.snap diff --git a/tests/.pest/snapshots/Countries/SpainTest/it_can_calculate_spanish_regional_holidays_2025.snap b/tests/.pest/snapshots/Countries/SpainTest/it_can_calculate_spanish_regional_holidays_2025.snap new file mode 100644 index 000000000..3b9838303 --- /dev/null +++ b/tests/.pest/snapshots/Countries/SpainTest/it_can_calculate_spanish_regional_holidays_2025.snap @@ -0,0 +1,58 @@ +[ + { + "name": "A\u00f1o Nuevo", + "date": "2025-01-01" + }, + { + "name": "Epifan\u00eda del Se\u00f1or", + "date": "2025-01-06" + }, + { + "name": "Viernes Santo", + "date": "2025-04-18" + }, + { + "name": "Lunes de Pascua", + "date": "2025-04-21" + }, + { + "name": "D\u00eda del Trabajador", + "date": "2025-05-01" + }, + { + "name": "San Juan", + "date": "2025-06-24" + }, + { + "name": "Asunci\u00f3n de la Virgen", + "date": "2025-08-15" + }, + { + "name": "Fiesta Nacional de Catalu\u00f1a", + "date": "2025-09-11" + }, + { + "name": "Fiesta Nacional de Espa\u00f1a", + "date": "2025-10-12" + }, + { + "name": "Todos los Santos", + "date": "2025-11-01" + }, + { + "name": "D\u00eda de la Constituci\u00f3n Espa\u00f1ola", + "date": "2025-12-06" + }, + { + "name": "Inmaculada Concepci\u00f3n", + "date": "2025-12-08" + }, + { + "name": "Navidad", + "date": "2025-12-25" + }, + { + "name": "San Esteban", + "date": "2025-12-26" + } +] \ No newline at end of file diff --git a/tests/Countries/SpainTest.php b/tests/Countries/SpainTest.php index 3c39a62e2..c5172a2bd 100644 --- a/tests/Countries/SpainTest.php +++ b/tests/Countries/SpainTest.php @@ -6,26 +6,118 @@ use Spatie\Holidays\Countries\Spain; use Spatie\Holidays\Holidays; -it('can calculate spanish holidays', function () { +// 2025 +it('can calculate spanish holidays 2025', function () { + CarbonImmutable::setTestNow('2025-01-01'); + + $holidays = Holidays::for(country: 'es')->get(); + + expect($holidays) + ->toBeArray() + ->not() + ->toBeEmpty() + ->and(formatDates($holidays)) + ->toMatchSnapshot(); + +}); + +it('can calculate spanish regional holidays 2025', function () { + CarbonImmutable::setTestNow('2025-01-01'); + + $holidays = Holidays::for(Spain::make('es-ct'))->get(); + + expect($holidays) + ->toBeArray() + ->not() + ->toBeEmpty() + ->and(formatDates($holidays)) + ->toMatchSnapshot(); + +}); + +// 2024 +it('can calculate spanish holidays 2024', function () { CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(country: 'es')->get(); expect($holidays) ->toBeArray() - ->not()->toBeEmpty(); + ->not() + ->toBeEmpty() + ->and(formatDates($holidays)) + ->toMatchSnapshot(); - expect(formatDates($holidays))->toMatchSnapshot(); }); -it('can calculate spanish regional holidays', function () { +it('can calculate spanish regional holidays 2024', function () { CarbonImmutable::setTestNow('2024-01-01'); $holidays = Holidays::for(Spain::make('es-ar'))->get(); expect($holidays) ->toBeArray() - ->not()->toBeEmpty(); + ->not() + ->toBeEmpty() + ->and(formatDates($holidays)) + ->toMatchSnapshot(); +}); + +// 2023 +it('can calculate spanish holidays 2023', function () { + CarbonImmutable::setTestNow('2023-01-01'); - expect(formatDates($holidays))->toMatchSnapshot(); + $holidays = Holidays::for(country: 'es')->get(); + + expect($holidays) + ->toBeArray() + ->not() + ->toBeEmpty() + ->and(formatDates($holidays)) + ->toMatchSnapshot(); }); + +it(/** + * @throws \JsonException + */ 'can calculate spanish regional holidays 2023', function () { + CarbonImmutable::setTestNow('2023-01-01'); + + $holidays = Holidays::for(Spain::make('es-ar'))->get(); + + expect($holidays) + ->toBeArray() + ->not() + ->toBeEmpty() + ->and(formatDates($holidays)) + ->toMatchSnapshot(); + +}); + +// 2022 +it('can calculate spanish holidays 2022', function () { + CarbonImmutable::setTestNow('2022-01-01'); + + $holidays = Holidays::for(country: 'es')->get(); + + expect($holidays) + ->toBeArray() + ->not() + ->toBeEmpty() + ->and(formatDates($holidays)) + ->toMatchSnapshot(); + +}); + +it('can calculate spanish regional holidays 2022', function () { + CarbonImmutable::setTestNow('2022-01-01'); + + $holidays = Holidays::for(Spain::make('es-ar'))->get(); + + expect($holidays) + ->toBeArray() + ->not() + ->toBeEmpty() + ->and(formatDates($holidays)) + ->toMatchSnapshot(); +}); +