diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 000000000..c45bebdb6
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1,8 @@
+# These are supported funding model platforms
+
+github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
+patreon: # Replace with a single Patreon username
+open_collective: # Replace with a single Open Collective username
+ko_fi: # Replace with a single Ko-fi username
+tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
+custom: https://www.buymeacoffee.com/sachatelgenhof
diff --git a/.gitignore b/.gitignore
index 4cea87f52..84c417656 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,4 @@ vendor
composer.lock
.php_cs.cache
bin/_*
+.phpunit.result.cache
diff --git a/.php_cs b/.php_cs
index 8a3e9dce8..231c3b0a2 100644
--- a/.php_cs
+++ b/.php_cs
@@ -1,4 +1,4 @@
-in(__DIR__);
return PhpCsFixer\Config::create()->setRiskyAllowed(true)->setRules([
- '@PSR2' => true,
- 'native_function_invocation' => true
- ])->setFinder($finder);
\ No newline at end of file
+ '@PSR2' => true,
+ 'array_syntax' => ['syntax' => 'short'],
+ 'native_function_invocation' => true,
+ 'ordered_imports' => ['sortAlgorithm' => 'alpha'],
+ 'no_unused_imports' => true,
+ 'single_quote' => true,
+ 'space_after_semicolon' => true,
+ 'trailing_comma_in_multiline_array' => true
+ ])->setLineEnding("\n")->setFinder($finder);
\ No newline at end of file
diff --git a/.styleci.yml b/.styleci.yml
index b46b01df6..b508228b0 100644
--- a/.styleci.yml
+++ b/.styleci.yml
@@ -1 +1,12 @@
-preset: psr2
\ No newline at end of file
+preset: psr2
+
+risky: true
+
+enabled:
+ - short_array_syntax
+ - native_function_invocation
+ - alpha_ordered_imports
+ - no_unused_imports
+ - single_quote
+ - space_after_semicolon
+ - trailing_comma_in_multiline_array
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index c206d55c4..288d5033c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,6 +4,7 @@ php:
- 7.1
- 7.2
- 7.3
+ - 7.4snapshot
- nightly
dist: trusty
@@ -22,13 +23,15 @@ before_script:
- composer install --no-interaction
script:
- - if [[ $PHPSTAN = 1 ]]; then composer require --dev phpstan/phpstan:^0.10 && vendor/bin/phpstan analyse -l 5 src; fi
+ - if [[ $PHPSTAN = 1 ]]; then composer require --dev phpstan/phpstan:^0.11 && vendor/bin/phpstan analyse -l 5 src; fi
- ./vendor/bin/phpunit
- phpenv config-rm xdebug.ini || return 0
- ./vendor/bin/php-cs-fixer --diff --dry-run -v fix
matrix:
allow_failures:
+ - php: 7.1
+ - php: 7.4snapshot
- php: hhvm
- php: nightly
@@ -39,5 +42,7 @@ matrix:
env: PHPSTAN=1
- php: 7.3
env: PHPSTAN=1
+ - php: 7.4snapshot
+ env: PHPSTAN=1
- php: hhvm
env: HHVM=true
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 24ebb2705..201ddcfc8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,7 +1,7 @@
# Change Log
All notable changes to this project will be documented in this file.
-The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org).
+The format is based on [Keep a Changelog](https://keepachangelog.com/) and this project adheres to [Semantic Versioning](https://semver.org).
## [Unreleased]
@@ -14,17 +14,86 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Removed
+## [2.2.0] - 2019-10-06
+
+### Added
+- Holiday providers for England, Wales, Scotland and Northern Ireland [\#166](https://github.com/azuyalabs/yasumi/pull/166) ([c960657](https://github.com/c960657))
+- Holiday Provider for South Korea. [\#156](https://github.com/azuyalabs/yasumi/pull/156) ([blood72](https://github.com/blood72))
+- Translation for the Easter holiday for the 'fr_FR' locale [\#146](https://github.com/azuyalabs/yasumi/pull/146) ([pioc92](https://github.com/pioc92))
+- Translation for the Pentecost holiday for the 'fr_FR' locale [\#145](https://github.com/azuyalabs/yasumi/pull/145) ([pioc92](https://github.com/pioc92))
+- Late Summer Bank Holiday in United Kingdom prior to 1965 [\#161](https://github.com/azuyalabs/yasumi/pull/161) ([c960657](https://github.com/c960657))
+- Observance holidays for Sweden [\#172](https://github.com/azuyalabs/yasumi/pull/172) ([c960657](https://github.com/c960657))
+- Special subclass of Holiday for substitute holidays [\#162](https://github.com/azuyalabs/yasumi/pull/162) ([c960657](https://github.com/c960657))
+- Added additional code style fixers and aligning StyleCI settings with PHP-CS.
+- Included extra requirement for some PHP Extensions in the composer file.
+
+### Changed
+- Updated the translation for the All Saints holiday for the 'fr_FR' locale [\#152](https://github.com/azuyalabs/yasumi/pull/152) ([pioc92](https://github.com/pioc92))
+- Updated the translation for the Armistice holiday for the 'fr_FR' locale [\#154](https://github.com/azuyalabs/yasumi/pull/154) ([pioc92](https://github.com/pioc92))
+- Updated the translation for the Victory in Europe holiday for the 'fr_FR' locale [\#153](https://github.com/azuyalabs/yasumi/pull/153) ([pioc92](https://github.com/pioc92))
+- Updated the translation for the Assumption of Mary holiday for the 'fr_FR' locale [\#155](https://github.com/azuyalabs/yasumi/pull/155) ([pioc92](https://github.com/pioc92))
+- Updated the translation for Christmas Day for the 'nl_NL' locale [\#160](https://github.com/azuyalabs/yasumi/pull/160) ([pioc92](https://github.com/pioc92))
+- Reordered arguments to Yoda style.
+- Replaced null checks by appropriate instance / type checks.
+- Moved default method values to method body as parameters should be nullable.
+- Applying the use of strict types. Strict typing allows for improved readability, maintainability, and less prone to bugs and security vulnerabilities.
+- PHP 7.1 is allowed to fail for Travis-CI due to the fact PHPUnit 8 requires PHP >= 7.2. PHP 7.1 support will be dropped in Yasumi once 7.1 has reached its end of life (December 2019).
+- Code using class imports rather than Fully Qualified Class names.
+- Upgraded to PHPUnit 8.
+- Replaced the standard 'InvalidArgumentException' when an invalid year or holiday provider are given by a new exception for each of these two situations separately ('InvalidYearException' and 'ProviderNotFoundException'). This allows you to better distinguish which exception may occur when instantiating the Yasumi class. [\#95](https://github.com/azuyalabs/yasumi/pull/95) ([qneyrat](https://github.com/qneyrat))
+- Refactored the AbstractProvider::count method to use the newly added SubstituteHoliday class.
+- Fallback support added to getName() to allow e.g. fallback from 'de_AT' to 'de'. [\#176](https://github.com/azuyalabs/yasumi/pull/176) ([c960657](https://github.com/c960657))
+
+### Fixed
+- Late Summer Bank Holiday in 1968 and 1969 in United Kingdom [\#161](https://github.com/azuyalabs/yasumi/pull/161) ([c960657](https://github.com/c960657))
+- Fixed one-off exceptions for May Day Bank Holiday in 1995 and 2020 and Spring Bank Holiday in 2002 and 2012 (United Kingdom) [\#160](https://github.com/azuyalabs/yasumi/pull/160) ([c960657](https://github.com/c960657))
+- Fixed revoked holidays in Portugal in 2013-2015 [\#163](https://github.com/azuyalabs/yasumi/pull/163) ([c960657](https://github.com/c960657))
+- Fixed spelling issues in the Danish translation for Second Christmas Day. [\#167](https://github.com/azuyalabs/yasumi/pull/167) ([c960657](https://github.com/c960657))
+- Corpus Christi is official in Poland [\#168](https://github.com/azuyalabs/yasumi/pull/168) ([c960657](https://github.com/c960657))
+- Liberation Day is official in the Netherlands [\#169](https://github.com/azuyalabs/yasumi/pull/169) ([c960657](https://github.com/c960657))
+- Typos in Easter Monday and Republic Day for the 'it_IT' locale [\#171](https://github.com/azuyalabs/yasumi/pull/171) ([c960657](https://github.com/c960657))
+- Corrected the name of the Emperors Birthday function and variable.
+- Good Friday is not official in Brazil [\#174](https://github.com/azuyalabs/yasumi/pull/174) ([c960657](https://github.com/c960657))
+
+### Removed
+- Unused constants.
+
+
+## [2.1.0] - 2019-03-29
+
+### Added
+- As the Japanese Emperor will abdicate the throne on May 1st 2019, the holiday of the Emporers Birthday will change to February 23rd from 2020 (No holiday in 2019). In addition, Coronation Day and the Enthronement Proclamation Ceremony will be extra holidays in 2019. [\#130](https://github.com/azuyalabs/yasumi/pull/130) ([cookie-maker](https://github.com/cookie-maker))
+- International Women's Day is an official holiday since 2019 in Berlin (Germany). [#133](https://github.com/azuyalabs/yasumi/pull/133) ([huehnerhose](https://github.com/huehnerhose))
+
+### Changed
+- Japanese Health And Sports Day will be renamed to Sports Day from 2020. [\#129](https://github.com/azuyalabs/yasumi/pull/129) ([cookie-maker](https://github.com/cookie-maker))
+- Dutch spelling for Easter/Pentecost/Christmas to use lower case. [\#128](https://github.com/azuyalabs/yasumi/pull/128) ([c960657](https://github.com/c960657))
+- Refactored the Netherlands Holiday provider by moving the calculation of individual holidays to private methods. This will reduce the complexity of the initialize method.
+- Visibility of internal class functions to 'private'. These are to be used within the class only and should not be public.
+
+### Fixed
+- "Bridge Day" for Japan takes two days in 2019. Currently the code only allows for 1 bridge day at a maximum. [\#141](https://github.com/azuyalabs/yasumi/pull/141) ([cookie-maker](https://github.com/cookie-maker))
+- Tests for Bremen, Lower Saxony and Schleswig Holstein (Germany) also celebrated Reformation Day in 2017. The unit tests were failing as it didn't account for that.
+- Changed the USA Provider to check all holidays for potential substitute holidays, not just New Year's Day, Independence Day, and Christmas Day. [\#140](https://github.com/azuyalabs/yasumi/pull/140) ([jagers](https://github.com/jagers))
+- Adjusted tests for the 'next' and 'previous' methods to avoid actually exceeding the year boundaries.
+- Deprecation warning for the package mikey179/vfStream. Composer 2.0 requires package names to not contain any upper case characters. [\#135](https://github.com/azuyalabs/yasumi/pull/135) ([IceShack](https://github.com/IceShack))
+- Incorrect comment about weekends in India [\#126](https://github.com/azuyalabs/yasumi/pull/126) ([c960657](https://github.com/c960657))
+- Correction to the test of New Year's day in the United Kingdom. It has been identified as a Bank Holiday only since 1975 (not from 1974).
+
+### Removed
+- Duplicate definition of newYearsDay [\#125](https://github.com/azuyalabs/yasumi/pull/125) ([c960657](https://github.com/c960657))
+
+
## [2.0.0] - 2019-01-11
### Added
- New filter to select holidays that happen on a given date [\#119](https://github.com/azuyalabs/yasumi/pull/119) ([cruxicheiros](https://github.com/cruxicheiros))
- Holiday Providers for all Australian states and territories. [\#112](https://github.com/azuyalabs/yasumi/pull/112) ([Milamber33](https://github.com/Milamber33))
- Holiday Provider for Bosnia. [\#94](https://github.com/azuyalabs/yasumi/pull/94) ([TheAdnan](https://github.com/TheAdnan))
-- Added Reformation Day as offical holiday since 2018 in Lower Saxony (Germany). [#115](https://github.com/azuyalabs/yasumi/issues/115) ([Taxcamp](https://github.com/Taxcamp))
-- Added Reformation Day as offical holiday since 2018 in Schleswig-Holstein (Germany). [#106](https://github.com/azuyalabs/yasumi/pull/106) ([HenningCash](https://github.com/HenningCash))
-- Added Reformation Day as offical holiday since 2018 in Hamburg (Germany). [#108](https://github.com/azuyalabs/yasumi/pull/108) ([HenningCash](https://github.com/HenningCash))
-- Added Reformation Day as offical holiday since 2018 in Bremen (Germany). [#116](https://github.com/azuyalabs/yasumi/issues/116) ([TalonTR](https://github.com/TalonTR))
-- Added International Women's Day as official holidy since 2019 in Berlin (Germany). [#133](https://github.com/azuyalabs/yasumi/pull/133) ([huehnerhose](https://github.com/huehnerhose))
+- Added Reformation Day as official holiday since 2018 in Lower Saxony (Germany). [#115](https://github.com/azuyalabs/yasumi/issues/115) ([Taxcamp](https://github.com/Taxcamp))
+- Added Reformation Day as official holiday since 2018 in Schleswig-Holstein (Germany). [#106](https://github.com/azuyalabs/yasumi/pull/106) ([HenningCash](https://github.com/HenningCash))
+- Added Reformation Day as official holiday since 2018 in Hamburg (Germany). [#108](https://github.com/azuyalabs/yasumi/pull/108) ([HenningCash](https://github.com/HenningCash))
+- Added Reformation Day as official holiday since 2018 in Bremen (Germany). [#116](https://github.com/azuyalabs/yasumi/issues/116) ([TalonTR](https://github.com/TalonTR))
- The (observed) holidays Lukkeloven, Constitution Day, New Year's Eve and Labour Day, as well as summertime and wintertime are included for Denmark [\#104](https://github.com/azuyalabs/yasumi/pull/104) ([c960657](https://github.com/c960657))
### Changed
@@ -85,7 +154,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
## [1.7.0] - 2017-12-11
### Added
-- All filters implement the [Countable](http://php.net/manual/en/class.countable.php) interface allowing you to use the ->count() method. [\#77](https://github.com/azuyalabs/yasumi/issues/77)
+- All filters implement the [Countable](https://php.net/manual/en/class.countable.php) interface allowing you to use the ->count() method. [\#77](https://github.com/azuyalabs/yasumi/issues/77)
- Holiday Provider for Latvia. [\#70](https://github.com/azuyalabs/yasumi/pull/70) ([lukosius](https://github.com/lukosius))
- Holiday Provider for Lithuania. [\#67](https://github.com/azuyalabs/yasumi/pull/67) ([lukosius](https://github.com/lukosius))
- Sometimes it is more convenient to be able to create a Yasumi instance by ISO3166 code rather than Yasumi's Holiday Provider name. A new function `createByISO3166_2` has been added to allow for that. [\#62](https://github.com/azuyalabs/yasumi/pull/62) ([huehnerhose](https://github.com/huehnerhose))
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
index 4bc9e7d97..cb48dfbfe 100644
--- a/CODE_OF_CONDUCT.md
+++ b/CODE_OF_CONDUCT.md
@@ -40,7 +40,7 @@ Project maintainers who do not follow or enforce the Code of Conduct in good fai
## Attribution
-This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
+This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [https://contributor-covenant.org/version/1/4][version]
-[homepage]: http://contributor-covenant.org
-[version]: http://contributor-covenant.org/version/1/4/
+[homepage]: https://contributor-covenant.org
+[version]: https://contributor-covenant.org/version/1/4/
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index c8df34d53..882e2db80 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -13,7 +13,7 @@ When contributing there are a few guidelines we'd like you to keep in mind:
$ composer format
```
- This will check/correct all the code for the PSR-2 Coding Standard using the wonderful [php-cs-fixer](http://cs.sensiolabs.org/) .
+ This will check/correct all the code for the PSR-2 Coding Standard using the wonderful [php-cs-fixer](https://cs.symfony.com).
- **Add unit tests!** - Your Pull Request won't be accepted if it doesn't have tests:
@@ -30,7 +30,7 @@ When contributing there are a few guidelines we'd like you to keep in mind:
- **One pull request per feature** - If you want to contribute more than one thing, send multiple pull requests.
-- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
+- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#_changing_multiple) before submitting.
## Running Tests
@@ -43,4 +43,4 @@ or alternatively run with:
``` bash
$ vendor/bin/phpunit
-```
\ No newline at end of file
+```
diff --git a/README.md b/README.md
index 0e34142c5..b6c365558 100644
--- a/README.md
+++ b/README.md
@@ -7,14 +7,6 @@
[![StyleCI](https://styleci.io/repos/32797151/shield?branch=master)](https://styleci.io/repos/32797151)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/azuyalabs/yasumi/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/azuyalabs/yasumi/?branch=master)
-Important!
------------
-Yasumi version 2.0 has been released with support for PHP 7 only. As of January 2019 support for PHP 5 has ended.
-
-For the previous code base (1.8.0) a separate support branch has been created that will only receive the most critical bug fixes (for those still using PHP 5). Please note that although v1.8.x works both in PHP 5 and PHP 7, the code base hasn't been upgraded to PHP 7.
-
-It is highly recommended to upgrade to PHP7 and Yasumi v2.0.0 to enjoy the latest changes and improvements. More information can be found on the blog here: [Yasumi Release v2](https://azuyalabs.github.io/yasumi/blog/release_v2)
-
Introduction
------------
Yasumi (Japanese for 'Holiday'「休み」) is an easy PHP library to help you calculate the dates and names of holidays and other
@@ -35,6 +27,14 @@ Blog
----
Checkout the [blog](https://azuyalabs.github.io/yasumi/blog/) section on documentation site regularly for latest updates. Keeping you informed about any news, releases, etc. in a handy blog post format!
+## Contributing
+
+Contributions are encouraged and welcome; I am always happy to get feedback or pull requests on Github :) Create [Github Issues](https://github.com/azuyalabs/yasumi/issues) for bugs and new features and comment on the ones you are interested in.
+
+If you enjoy what I am making, an extra cup of coffee is very much appreciated :). Your support helps me to put more time into Open-Source Software projects like this.
+
+
+
License
-------
diff --git a/composer.json b/composer.json
index 29538c08c..1b256086a 100755
--- a/composer.json
+++ b/composer.json
@@ -20,13 +20,14 @@
}
],
"require": {
- "php": ">=7.1"
+ "php": ">=7.1",
+ "ext-json": "*"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.14",
"fzaninotto/faker": "~1.8",
- "mikey179/vfsStream": "~1.6",
- "phpunit/phpunit": "~7.5"
+ "mikey179/vfsstream": "~1.6",
+ "phpunit/phpunit": "~8.4"
},
"autoload": {
"psr-4": {
@@ -44,5 +45,8 @@
},
"config": {
"sort-packages": true
+ },
+ "suggest": {
+ "ext-calendar": "For calculating the date of Easter"
}
}
diff --git a/phpunit.xml b/phpunit.xml
index 158eff6e8..7cbade3eb 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -173,6 +173,11 @@
./tests/SouthAfrica
+
+
+ ./tests/SouthKorea
+
+
./tests/Spain
@@ -203,7 +208,6 @@
./tests/UnitedKingdom
-
diff --git a/src/Yasumi/Exception/Exception.php b/src/Yasumi/Exception/Exception.php
index 2405ddde7..14b038858 100644
--- a/src/Yasumi/Exception/Exception.php
+++ b/src/Yasumi/Exception/Exception.php
@@ -1,4 +1,4 @@
-
+ */
+
+namespace Yasumi\Exception;
+
+use InvalidArgumentException;
+
+/**
+ * Class InvalidYearException.
+ *
+ * @author Quentin Neyrat
+ */
+class InvalidYearException extends InvalidArgumentException implements Exception
+{
+}
diff --git a/src/Yasumi/Exception/ProviderNotFoundException.php b/src/Yasumi/Exception/ProviderNotFoundException.php
new file mode 100644
index 000000000..31b26140e
--- /dev/null
+++ b/src/Yasumi/Exception/ProviderNotFoundException.php
@@ -0,0 +1,24 @@
+
+ */
+
+namespace Yasumi\Exception;
+
+use InvalidArgumentException;
+
+/**
+ * Class ProviderNotFoundException.
+ *
+ * @author Quentin Neyrat
+ */
+class ProviderNotFoundException extends InvalidArgumentException implements Exception
+{
+}
diff --git a/src/Yasumi/Exception/UnknownLocaleException.php b/src/Yasumi/Exception/UnknownLocaleException.php
index 5e64dcc07..b7b434454 100644
--- a/src/Yasumi/Exception/UnknownLocaleException.php
+++ b/src/Yasumi/Exception/UnknownLocaleException.php
@@ -1,4 +1,4 @@
-
+ */
+
+namespace Yasumi\Filters;
+
+use Countable;
+use FilterIterator;
+use Yasumi\SubstituteHoliday;
+
+/**
+ * AbstractFilter.
+ *
+ * @package Yasumi\Filters
+ */
+abstract class AbstractFilter extends FilterIterator implements Countable
+{
+ /**
+ * Returns the number of holidays returned by this iterator.
+ *
+ * In case a holiday is substituted (e.g. observed), the holiday is only counted once.
+ *
+ * @return int Number of unique holidays.
+ */
+ public function count(): int
+ {
+ $names = \array_map(static function (&$holiday) {
+ if ($holiday instanceof SubstituteHoliday) {
+ return $holiday->substitutedHoliday->shortName;
+ }
+
+ return $holiday->shortName;
+ }, \iterator_to_array($this));
+
+ return \count(\array_unique($names));
+ }
+}
diff --git a/src/Yasumi/Filters/BankHolidaysFilter.php b/src/Yasumi/Filters/BankHolidaysFilter.php
index edd1bc2f9..abcee3e70 100644
--- a/src/Yasumi/Filters/BankHolidaysFilter.php
+++ b/src/Yasumi/Filters/BankHolidaysFilter.php
@@ -1,4 +1,4 @@
-getIterator());
*/
-class BankHolidaysFilter extends FilterIterator implements Countable
+class BankHolidaysFilter extends AbstractFilter
{
/**
* Checks whether the current element of the iterator is an observed holiday.
@@ -37,18 +35,4 @@ public function accept(): bool
{
return $this->getInnerIterator()->current()->getType() === Holiday::TYPE_BANK;
}
-
- /**
- * @return integer Returns the number of filtered holidays.
- */
- public function count(): int
- {
- $days = \array_keys(\iterator_to_array($this));
-
- \array_walk($days, function (&$day) {
- $day = \str_replace('substituteHoliday:', '', $day);
- });
-
- return \count(\array_unique($days));
- }
}
diff --git a/src/Yasumi/Filters/BetweenFilter.php b/src/Yasumi/Filters/BetweenFilter.php
index 8153c24a9..73d556d64 100644
--- a/src/Yasumi/Filters/BetweenFilter.php
+++ b/src/Yasumi/Filters/BetweenFilter.php
@@ -1,4 +1,4 @@
-equal = $equal;
+ $this->equal = $equal;
$this->start_date = $start_date->format('Y-m-d');
- $this->end_date = $end_date->format('Y-m-d');
+ $this->end_date = $end_date->format('Y-m-d');
}
/**
@@ -78,18 +76,4 @@ public function accept(): bool
return $holiday > $this->start_date && $holiday < $this->end_date;
}
-
- /**
- * @return integer Returns the number of holidays between the given start and end date.
- */
- public function count(): int
- {
- $days = \array_keys(\iterator_to_array($this));
-
- \array_walk($days, function (&$day) {
- $day = \str_replace('substituteHoliday:', '', $day);
- });
-
- return \count(\array_unique($days));
- }
}
diff --git a/src/Yasumi/Filters/ObservedHolidaysFilter.php b/src/Yasumi/Filters/ObservedHolidaysFilter.php
index 58550e700..4d5bbd23c 100644
--- a/src/Yasumi/Filters/ObservedHolidaysFilter.php
+++ b/src/Yasumi/Filters/ObservedHolidaysFilter.php
@@ -1,4 +1,4 @@
-getIterator());
*/
-class ObservedHolidaysFilter extends FilterIterator implements Countable
+class ObservedHolidaysFilter extends AbstractFilter
{
/**
* Checks whether the current element of the iterator is an observed holiday.
@@ -37,18 +35,4 @@ public function accept(): bool
{
return $this->getInnerIterator()->current()->getType() === Holiday::TYPE_OBSERVANCE;
}
-
- /**
- * @return integer Returns the number of filtered holidays.
- */
- public function count(): int
- {
- $days = \array_keys(\iterator_to_array($this));
-
- \array_walk($days, function (&$day) {
- $day = \str_replace('substituteHoliday:', '', $day);
- });
-
- return \count(\array_unique($days));
- }
}
diff --git a/src/Yasumi/Filters/OfficialHolidaysFilter.php b/src/Yasumi/Filters/OfficialHolidaysFilter.php
index 94e315702..7fe421018 100644
--- a/src/Yasumi/Filters/OfficialHolidaysFilter.php
+++ b/src/Yasumi/Filters/OfficialHolidaysFilter.php
@@ -1,4 +1,4 @@
-getIterator());
*/
-class OfficialHolidaysFilter extends FilterIterator implements Countable
+class OfficialHolidaysFilter extends AbstractFilter
{
/**
* Checks whether the current element of the iterator is an official holiday.
@@ -37,18 +35,4 @@ public function accept(): bool
{
return $this->getInnerIterator()->current()->getType() === Holiday::TYPE_OFFICIAL;
}
-
- /**
- * @return integer Returns the number of filtered holidays.
- */
- public function count(): int
- {
- $days = \array_keys(\iterator_to_array($this));
-
- \array_walk($days, function (&$day) {
- $day = \str_replace('substituteHoliday:', '', $day);
- });
-
- return \count(\array_unique($days));
- }
}
diff --git a/src/Yasumi/Filters/OnFilter.php b/src/Yasumi/Filters/OnFilter.php
index 41fc4053f..f32b10554 100644
--- a/src/Yasumi/Filters/OnFilter.php
+++ b/src/Yasumi/Filters/OnFilter.php
@@ -1,4 +1,4 @@
-date = $date->format('Y-m-d');
+ $this->date = $date->format('Y-m-d');
}
/**
@@ -57,18 +55,4 @@ public function accept(): bool
$holiday = $this->getInnerIterator()->current()->format('Y-m-d');
return $holiday === $this->date;
}
-
- /**
- * @return integer Returns the number of holidays that happen on the specified date
- */
- public function count(): int
- {
- $days = \array_keys(\iterator_to_array($this));
-
- \array_walk($days, function (&$day) {
- $day = \str_replace('substituteHoliday:', '', $day);
- });
-
- return \count(\array_unique($days));
- }
}
diff --git a/src/Yasumi/Filters/OtherHolidaysFilter.php b/src/Yasumi/Filters/OtherHolidaysFilter.php
index 1349a23c7..bd141ec12 100644
--- a/src/Yasumi/Filters/OtherHolidaysFilter.php
+++ b/src/Yasumi/Filters/OtherHolidaysFilter.php
@@ -1,4 +1,4 @@
-getIterator());
*/
-class OtherHolidaysFilter extends FilterIterator implements Countable
+class OtherHolidaysFilter extends AbstractFilter
{
/**
* Checks whether the current element of the iterator is an other type of holiday.
@@ -37,18 +35,4 @@ public function accept(): bool
{
return $this->getInnerIterator()->current()->getType() === Holiday::TYPE_OTHER;
}
-
- /**
- * @return integer Returns the number of filtered holidays.
- */
- public function count(): int
- {
- $days = \array_keys(\iterator_to_array($this));
-
- \array_walk($days, function (&$day) {
- $day = \str_replace('substituteHoliday:', '', $day);
- });
-
- return \count(\array_unique($days));
- }
}
diff --git a/src/Yasumi/Filters/SeasonalHolidaysFilter.php b/src/Yasumi/Filters/SeasonalHolidaysFilter.php
index 5eebaa59e..a98566de3 100644
--- a/src/Yasumi/Filters/SeasonalHolidaysFilter.php
+++ b/src/Yasumi/Filters/SeasonalHolidaysFilter.php
@@ -1,4 +1,4 @@
-getIterator());
*/
-class SeasonalHolidaysFilter extends FilterIterator implements Countable
+class SeasonalHolidaysFilter extends AbstractFilter
{
/**
* Checks whether the current element of the iterator is a seasonal holiday.
@@ -37,18 +35,4 @@ public function accept(): bool
{
return $this->getInnerIterator()->current()->getType() === Holiday::TYPE_SEASON;
}
-
- /**
- * @return integer Returns the number of filtered holidays.
- */
- public function count(): int
- {
- $days = \array_keys(\iterator_to_array($this));
-
- \array_walk($days, function (&$day) {
- $day = \str_replace('substituteHoliday:', '', $day);
- });
-
- return \count(\array_unique($days));
- }
}
diff --git a/src/Yasumi/Holiday.php b/src/Yasumi/Holiday.php
index 1a72e145e..f611cc9e6 100755
--- a/src/Yasumi/Holiday.php
+++ b/src/Yasumi/Holiday.php
@@ -1,4 +1,4 @@
-shortName = $shortName;
- $this->translations = $names;
+ $this->shortName = $shortName;
+ $this->translations = $names;
$this->displayLocale = $displayLocale;
- $this->type = $type;
+ $this->type = $type;
// Construct instance
parent::__construct($date->format('Y-m-d'), $date->getTimezone());
@@ -159,7 +160,20 @@ public function jsonSerialize(): self
*/
public function getName(): string
{
- return $this->translations[$this->displayLocale] ?? $this->translations[self::DEFAULT_LOCALE] ?? $this->shortName;
+ $locales = [$this->displayLocale];
+ $parts = \explode('_', $this->displayLocale);
+ while (\array_pop($parts) && $parts) {
+ $locales[] = \implode('_', $parts);
+ }
+ $locales[] = self::DEFAULT_LOCALE;
+
+ foreach ($locales as $locale) {
+ if (isset($this->translations[$locale])) {
+ return $this->translations[$locale];
+ }
+ }
+
+ return $this->shortName;
}
/**
@@ -170,7 +184,7 @@ public function getName(): string
public function mergeGlobalTranslations(TranslationsInterface $globalTranslations)
{
$holidayGlobalTranslations = $globalTranslations->getTranslations($this->shortName);
- $this->translations = \array_merge($holidayGlobalTranslations, $this->translations);
+ $this->translations = \array_merge($holidayGlobalTranslations, $this->translations);
}
/**
diff --git a/src/Yasumi/Provider/AbstractProvider.php b/src/Yasumi/Provider/AbstractProvider.php
index 8ac7e3305..427b975a3 100755
--- a/src/Yasumi/Provider/AbstractProvider.php
+++ b/src/Yasumi/Provider/AbstractProvider.php
@@ -1,4 +1,4 @@
- [5], // Iran, Islamic Republic of
- // Friday
+ // Sunday
'IN' => [0], // India
];
@@ -98,17 +101,17 @@ abstract class AbstractProvider implements ProviderInterface, Countable, Iterato
/**
* Creates a new holiday provider (i.e. country/state).
*
- * @param int $year the year for which to provide holidays
- * @param string $locale the locale/language in which holidays need to be
+ * @param int $year the year for which to provide holidays
+ * @param string $locale |null the locale/language in which holidays need to be
* represented
* @param TranslationsInterface|null $globalTranslations global translations
*/
- public function __construct($year, $locale = 'en_US', TranslationsInterface $globalTranslations = null)
+ public function __construct($year, $locale = null, TranslationsInterface $globalTranslations = null)
{
$this->clearHolidays();
- $this->year = $year ?: \getdate()['year'];
- $this->locale = $locale;
+ $this->year = $year ?: \getdate()['year'];
+ $this->locale = $locale ?? 'en_US';
$this->globalTranslations = $globalTranslations;
$this->initialize();
@@ -148,7 +151,7 @@ private static function compareDates(\DateTimeInterface $dateA, \DateTimeInterfa
*/
public function addHoliday(Holiday $holiday)
{
- if ($this->globalTranslations !== null) {
+ if ($this->globalTranslations instanceof TranslationsInterface) {
$holiday->mergeGlobalTranslations($this->globalTranslations);
}
@@ -181,15 +184,17 @@ public function removeHoliday($shortName): void
* @param \DateTimeInterface $date any date object that implements the DateTimeInterface (e.g. Yasumi\Holiday,
* \DateTime)
*
- * @throws \Yasumi\Exception\InvalidDateException
- *
* @return bool true if date represents a working day, otherwise false
+ * @throws InvalidDateException
+ *
*/
public function isWorkingDay(\DateTimeInterface $date): bool
{
+ $isWorkingDay = true;
+
// First check if the given date is a holiday
if ($this->isHoliday($date)) {
- return false;
+ $isWorkingDay = false;
}
// Check if given date is a falls in the weekend or not
@@ -199,10 +204,10 @@ public function isWorkingDay(\DateTimeInterface $date): bool
$weekend_days = $weekend_data[$this::ID] ?? [0, 6];
if (\in_array((int)$date->format('w'), $weekend_days, true)) {
- return false;
+ $isWorkingDay = false;
}
- return true;
+ return $isWorkingDay;
}
/**
@@ -211,9 +216,9 @@ public function isWorkingDay(\DateTimeInterface $date): bool
* @param \DateTimeInterface $date any date object that implements the DateTimeInterface (e.g. Yasumi\Holiday,
* \DateTime)
*
- * @throws \Yasumi\Exception\InvalidDateException
- *
* @return bool true if date represents a holiday, otherwise false
+ * @throws InvalidDateException
+ *
*/
public function isHoliday(\DateTimeInterface $date): bool
{
@@ -232,7 +237,7 @@ public function isHoliday(\DateTimeInterface $date): bool
*/
public function getHolidayDates(): array
{
- return \array_map(function ($holiday) {
+ return \array_map(static function ($holiday) {
return (string)$holiday;
}, $this->holidays);
}
@@ -242,9 +247,9 @@ public function getHolidayDates(): array
*
* @param string $shortName short name of the holiday
*
+ * @return string the date of the requested holiday
* @throws InvalidArgumentException when the given name is blank or empty.
*
- * @return string the date of the requested holiday
*/
public function whenIs($shortName): string
{
@@ -258,9 +263,9 @@ public function whenIs($shortName): string
*
* @param string $shortName the name of the holiday to be checked.
*
+ * @return true upon success, otherwise an InvalidArgumentException is thrown
* @throws InvalidArgumentException An InvalidArgumentException is thrown if the given holiday parameter is empty.
*
- * @return true upon success, otherwise an InvalidArgumentException is thrown
*/
protected function isHolidayNameNotEmpty($shortName): bool
{
@@ -279,9 +284,9 @@ protected function isHolidayNameNotEmpty($shortName): bool
*
* @param string $shortName short name of the holiday
*
+ * @return int the index of the weekdays of the requested holiday (0 = Sunday, 1 = Monday, etc.)
* @throws InvalidArgumentException when the given name is blank or empty.
*
- * @return int the index of the weekdays of the requested holiday (0 = Sunday, 1 = Monday, etc.)
*/
public function whatWeekDayIs($shortName): int
{
@@ -298,13 +303,25 @@ public function whatWeekDayIs($shortName): int
*/
public function count(): int
{
- $list = $this->getHolidayNames();
+ $names = \array_map(static function (&$holiday) {
+ if ($holiday instanceof SubstituteHoliday) {
+ return $holiday->substitutedHoliday->shortName;
+ }
- \array_walk($list, function (&$holiday) {
- $holiday = \str_replace('substituteHoliday:', '', $holiday);
- });
+ return $holiday->shortName;
+ }, $this->getHolidays());
- return \count(\array_unique($list));
+ return \count(\array_unique($names));
+ }
+
+ /**
+ * Gets all of the holidays defined by this holiday provider (for the given year).
+ *
+ * @return Holiday[] list of all holidays defined for the given year
+ */
+ public function getHolidays(): array
+ {
+ return $this->holidays;
}
/**
@@ -332,12 +349,12 @@ public function getYear(): int
*
* @param string $shortName the name of the holiday for which the next occurrence need to be retrieved.
*
- * @return \Yasumi\Holiday|null a Holiday instance for the given holiday
+ * @return Holiday|null a Holiday instance for the given holiday
*
* @throws \ReflectionException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \RuntimeException
- * @throws \InvalidArgumentException
+ * @throws InvalidArgumentException
*
* @covers AbstractProvider::anotherTime
*/
@@ -349,14 +366,14 @@ public function next($shortName): ?Holiday
/**
* Determines the date of the given holiday for another year.
*
- * @param int $year the year to get the holiday date for
+ * @param int $year the year to get the holiday date for
* @param string $shortName the name of the holiday for which the date needs to be fetched
*
- * @return \Yasumi\Holiday|null a Holiday instance for the given holiday and year
+ * @return Holiday|null a Holiday instance for the given holiday and year
*
* @throws \ReflectionException
* @throws InvalidArgumentException when the given name is blank or empty.
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \RuntimeException
*/
private function anotherTime($year, $shortName): ?Holiday
@@ -374,9 +391,9 @@ private function anotherTime($year, $shortName): ?Holiday
*
* @param string $shortName the name of the holiday.
*
+ * @return Holiday|null a Holiday instance for the given holiday
* @throws InvalidArgumentException when the given name is blank or empty.
*
- * @return \Yasumi\Holiday|null a Holiday instance for the given holiday
*/
public function getHoliday($shortName): ?Holiday
{
@@ -387,27 +404,17 @@ public function getHoliday($shortName): ?Holiday
return $holidays[$shortName] ?? null;
}
- /**
- * Gets all of the holidays defined by this holiday provider (for the given year).
- *
- * @return \Yasumi\Holiday[] list of all holidays defined for the given year
- */
- public function getHolidays(): array
- {
- return $this->holidays;
- }
-
/**
* Retrieves the previous date (year) the given holiday took place.
*
* @param string $shortName the name of the holiday for which the previous occurrence need to be retrieved.
*
- * @return \Yasumi\Holiday|null a Holiday instance for the given holiday
+ * @return Holiday|null a Holiday instance for the given holiday
*
* @throws \ReflectionException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \RuntimeException
- * @throws \InvalidArgumentException
+ * @throws InvalidArgumentException
*
* @covers AbstractProvider::anotherTime
*/
@@ -429,22 +436,32 @@ public function previous($shortName): ?Holiday
* correct).
*
* @param \DateTimeInterface $start_date Start date of the time frame to check against
- * @param \DateTimeInterface $end_date End date of the time frame to check against
- * @param bool $equals indicate whether the start and end dates should be included in the
+ * @param \DateTimeInterface $end_date End date of the time frame to check against
+ * @param bool $equals indicate whether the start and end dates should be included in the
* comparison
*
+ * @return BetweenFilter
* @throws InvalidArgumentException An InvalidArgumentException is thrown if the start date is set after the end
* date.
*
- * @return \Yasumi\Filters\BetweenFilter
*/
- public function between(\DateTimeInterface $start_date, \DateTimeInterface $end_date, $equals = true): BetweenFilter
+ public function between(\DateTimeInterface $start_date, \DateTimeInterface $end_date, $equals = null): BetweenFilter
{
if ($start_date > $end_date) {
throw new InvalidArgumentException('Start date must be a date before the end date.');
}
- return new BetweenFilter($this->getIterator(), $start_date, $end_date, $equals);
+ return new BetweenFilter($this->getIterator(), $start_date, $end_date, $equals ?? true);
+ }
+
+ /**
+ * Get an iterator for the holidays.
+ *
+ * @return ArrayIterator iterator for the holidays of this calendar
+ */
+ public function getIterator(): ArrayIterator
+ {
+ return new ArrayIterator($this->getHolidays());
}
/**
@@ -458,20 +475,10 @@ public function between(\DateTimeInterface $start_date, \DateTimeInterface $end_
*
* @param \DateTimeInterface $date Date to check for holidays on.
*
- * @return \Yasumi\Filters\OnFilter
+ * @return OnFilter
*/
public function on(\DateTimeInterface $date): OnFilter
{
return new OnFilter($this->getIterator(), $date);
}
-
- /**
- * Get an iterator for the holidays.
- *
- * @return ArrayIterator iterator for the holidays of this calendar
- */
- public function getIterator(): ArrayIterator
- {
- return new ArrayIterator($this->getHolidays());
- }
}
diff --git a/src/Yasumi/Provider/Australia.php b/src/Yasumi/Provider/Australia.php
index 11d3c1a11..2f87b0e78 100755
--- a/src/Yasumi/Provider/Australia.php
+++ b/src/Yasumi/Provider/Australia.php
@@ -1,4 +1,4 @@
-year-01-26", new DateTimeZone($this->timezone));
-
- $this->calculateHoliday('australiaDay', ['en_AU' => 'Australia Day'], $date);
+ $newyearsday = new DateTime("$this->year-01-01", new DateTimeZone($this->timezone));
+ $this->calculateHoliday('newYearsDay', [], $newyearsday, false, false);
+ switch ($newyearsday->format('w')) {
+ case 0: // sunday
+ $newyearsday->add(new DateInterval('P1D'));
+ $this->calculateHoliday('newYearsHoliday', ['en' => 'New Year\'s Holiday'], $newyearsday, false, false);
+ break;
+ case 6: // saturday
+ $newyearsday->add(new DateInterval('P2D'));
+ $this->calculateHoliday('newYearsHoliday', ['en' => 'New Year\'s Holiday'], $newyearsday, false, false);
+ break;
+ }
}
/**
* Function to simplify moving holidays to mondays if required
*
- * @param string $shortName
- * @param array $names
- * @param DateTime $date
- * @param bool $moveFromSaturday
- * @param bool $moveFromSunday
- * @param string $type
+ * @param string $shortName
+ * @param array $names
+ * @param DateTime $date
+ * @param bool $moveFromSaturday
+ * @param bool $moveFromSunday
+ * @param string $type
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
public function calculateHoliday(
string $shortName,
array $names = [],
$date,
- $moveFromSaturday = true,
- $moveFromSunday = true,
- $type = Holiday::TYPE_OFFICIAL
+ $moveFromSaturday = null,
+ $moveFromSunday = null,
+ $type = null
): void {
$day = (int)$date->format('w');
- if (($day === 0 && $moveFromSunday) || ($day === 6 && $moveFromSaturday)) {
- $date = $date->add($day === 0 ? new DateInterval('P1D') : new DateInterval('P2D'));
+ if ((0 === $day && ($moveFromSunday ?? true)) || (6 === $day && ($moveFromSaturday ?? true))) {
+ $date = $date->add(0 === $day ? new DateInterval('P1D') : new DateInterval('P2D'));
}
- $this->addHoliday(new Holiday($shortName, $names, $date, $this->locale, $type));
+ $this->addHoliday(new Holiday($shortName, $names, $date, $this->locale, $type ?? Holiday::TYPE_OFFICIAL));
}
/**
- * Holidays associated with the start of the modern Gregorian calendar.
+ * Australia Day.
*
- * New Year's Day is on January 1 and is the first day of a new year in the Gregorian calendar,
- * which is used in Australia and many other countries. Due to its geographical position close
- * to the International Date Line, Australia is one of the first countries in the world to welcome the New Year.
- * If it falls on a weekend an additional public holiday is held on the next available weekday.
+ * Australia Day is the official National Day of Australia. Celebrated annually on 26 January,
+ * it marks the anniversary of the 1788 arrival of the First Fleet of British Ships at
+ * Port Jackson, New South Wales, and the raising of the Flag of Great Britain at Sydney Cove
+ * by Governor Arthur Phillip. In present-day Australia, celebrations reflect the diverse
+ * society and landscape of the nation, and are marked by community and family events,
+ * reflections on Australian history, official community awards, and citizenship ceremonies
+ * welcoming new immigrants into the Australian community.
*
- * @link https://www.timeanddate.com/holidays/australia/new-year-day
+ * @link https://en.wikipedia.org/wiki/Waitangi_Day
+ * @link https://www.timeanddate.com/holidays/australia/australia-day
*
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateNewYearHolidays(): void
+ private function calculateAustraliaDay(): void
{
- $newyearsday = new DateTime("$this->year-01-01", new DateTimeZone($this->timezone));
- $this->calculateHoliday('newYearsDay', ['en_AU' => 'New Year\'s Day'], $newyearsday, false, false);
- switch ($newyearsday->format('w')) {
- case 0: // sunday
- $newyearsday->add(new DateInterval('P1D'));
- $this->calculateHoliday('newYearsHoliday', ['en_AU' => 'New Year\'s Holiday'], $newyearsday, false, false);
- break;
- case 6: // saturday
- $newyearsday->add(new DateInterval('P2D'));
- $this->calculateHoliday('newYearsHoliday', ['en_AU' => 'New Year\'s Holiday'], $newyearsday, false, false);
- break;
- }
+ $date = new DateTime("$this->year-01-26", new DateTimeZone($this->timezone));
+
+ $this->calculateHoliday('australiaDay', ['en' => 'Australia Day'], $date);
}
/**
@@ -151,17 +153,17 @@ public function calculateNewYearHolidays(): void
* @link https://www.timeanddate.com/holidays/australia/anzac-day
*
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateAnzacDay(): void
+ private function calculateAnzacDay(): void
{
if ($this->year < 1921) {
return;
}
$date = new DateTime("$this->year-04-25", new DateTimeZone($this->timezone));
- $this->calculateHoliday('anzacDay', ['en_AU' => 'ANZAC Day'], $date, false, false);
+ $this->calculateHoliday('anzacDay', [], $date, false, false);
$easter = $this->calculateEaster($this->year, $this->timezone);
$easterMonday = $this->calculateEaster($this->year, $this->timezone);
@@ -170,7 +172,7 @@ public function calculateAnzacDay(): void
$fDate = $date->format('Y-m-d');
if ($fDate === $easter->format('Y-m-d') || $fDate === $easterMonday->format('Y-m-d')) {
$easterMonday->add(new DateInterval('P1D'));
- $this->calculateHoliday('easterTuesday', ['en_AU' => 'Easter Tuesday'], $easterMonday, false, false);
+ $this->calculateHoliday('easterTuesday', ['en' => 'Easter Tuesday'], $easterMonday, false, false);
}
unset($fDate);
}
@@ -184,30 +186,30 @@ public function calculateAnzacDay(): void
* @link https://www.timeanddate.com/holidays/australia/christmas-day-holiday
*
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateChristmasDay(): void
+ private function calculateChristmasDay(): void
{
$christmasDay = new DateTime("$this->year-12-25", new DateTimeZone($this->timezone));
- $boxingDay = new DateTime("$this->year-12-26", new DateTimeZone($this->timezone));
- $this->calculateHoliday('christmasDay', ['en_AU' => 'Christmas Day'], $christmasDay, false, false);
- $this->calculateHoliday('secondChristmasDay', ['en_AU' => 'Boxing Day'], $boxingDay, false, false);
+ $boxingDay = new DateTime("$this->year-12-26", new DateTimeZone($this->timezone));
+ $this->calculateHoliday('christmasDay', [], $christmasDay, false, false);
+ $this->calculateHoliday('secondChristmasDay', [], $boxingDay, false, false);
switch ($christmasDay->format('w')) {
case 0: // sunday
$christmasDay->add(new DateInterval('P2D'));
- $this->calculateHoliday('christmasHoliday', ['en_AU' => 'Christmas Holiday'], $christmasDay, false, false);
+ $this->calculateHoliday('christmasHoliday', ['en' => 'Christmas Holiday'], $christmasDay, false, false);
break;
case 5: // friday
$boxingDay->add(new DateInterval('P2D'));
- $this->calculateHoliday('secondChristmasHoliday', ['en_AU' => 'Boxing Day Holiday'], $boxingDay, false, false);
+ $this->calculateHoliday('secondChristmasHoliday', ['en' => 'Boxing Day Holiday'], $boxingDay, false, false);
break;
case 6: // saturday
$christmasDay->add(new DateInterval('P2D'));
$boxingDay->add(new DateInterval('P2D'));
- $this->calculateHoliday('christmasHoliday', ['en_AU' => 'Christmas Holiday'], $christmasDay, false, false);
- $this->calculateHoliday('secondChristmasHoliday', ['en_AU' => 'Boxing Day Holiday'], $boxingDay, false, false);
+ $this->calculateHoliday('christmasHoliday', ['en' => 'Christmas Holiday'], $christmasDay, false, false);
+ $this->calculateHoliday('secondChristmasHoliday', ['en' => 'Boxing Day Holiday'], $boxingDay, false, false);
break;
}
}
diff --git a/src/Yasumi/Provider/Australia/ACT.php b/src/Yasumi/Provider/Australia/ACT.php
index bd50aa21b..4fc035f2e 100644
--- a/src/Yasumi/Provider/Australia/ACT.php
+++ b/src/Yasumi/Provider/Australia/ACT.php
@@ -1,4 +1,4 @@
-year < 2007) {
- $date = new DateTime("third monday of march $this->year", new DateTimeZone($this->timezone));
- } else {
- $date = new DateTime("second monday of march $this->year", new DateTimeZone($this->timezone));
- }
- $this->addHoliday(new Holiday('canberraDay', ['en_AU' => 'Canberra Day'], $date, $this->locale));
- }
-
- /**
- * Reconciliation Day
- *
- * @throws \Exception
- */
- public function calculateReconciliationDay(): void
- {
- if ($this->year < 2018) {
- return;
- }
-
- $date = new DateTime($this->year . '-05-27', new DateTimeZone($this->timezone));
- $day = (int)$date->format('w');
- if ($day !== 1) {
- $date = $date->add($day === 0 ? new DateInterval('P1D') : new DateInterval('P'.(8-$day).'D'));
- }
- $this->addHoliday(new Holiday('reconciliationDay', ['en_AU' => 'Reconciliation Day'], $date, $this->locale));
- }
-
- /**
- * Labour Day
- *
- * @throws \Exception
- */
- public function calculateLabourDay(): void
- {
- $date = new DateTime("first monday of october $this->year", new DateTimeZone($this->timezone));
-
- $this->addHoliday(new Holiday('labourDay', ['en_AU' => 'Labour Day'], $date, $this->locale));
- }
-
- /**
- * Easter Saturday.
+ * Easter Sunday.
*
* Easter is a festival and holiday celebrating the resurrection of Jesus Christ from the dead. Easter is celebrated
* on a date based on a certain number of days after March 21st. The date of Easter Day was defined by the Council
* of Nicaea in AD325 as the Sunday after the first full moon which falls on or after the Spring Equinox.
*
- * @link http://en.wikipedia.org/wiki/Easter
+ * @link https://en.wikipedia.org/wiki/Easter
*
- * @param int $year the year for which Easter Saturday need to be created
+ * @param int $year the year for which Easter Saturday need to be created
* @param string $timezone the timezone in which Easter Saturday is celebrated
- * @param string $locale the locale for which Easter Saturday need to be displayed in.
- * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
+ * @param string $locale the locale for which Easter Saturday need to be displayed in.
+ * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
* TYPE_SEASON, TYPE_BANK or TYPE_OTHER. By default an official holiday is considered.
*
- * @return \Yasumi\Holiday
+ * @return Holiday
*
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \InvalidArgumentException
* @throws \Exception
*/
- public function easterSaturday($year, $timezone, $locale, $type = Holiday::TYPE_OFFICIAL): Holiday
+ private function easterSunday($year, $timezone, $locale, $type = null): Holiday
{
return new Holiday(
- 'easterSaturday',
- ['en_AU' => 'Easter Saturday'],
- $this->calculateEaster($year, $timezone)->sub(new DateInterval('P1D')),
+ 'easter',
+ ['en' => 'Easter Sunday'],
+ $this->calculateEaster($year, $timezone),
$locale,
- $type
+ $type ?? Holiday::TYPE_OFFICIAL
);
}
/**
- * Easter Sunday.
+ * Easter Saturday.
*
* Easter is a festival and holiday celebrating the resurrection of Jesus Christ from the dead. Easter is celebrated
* on a date based on a certain number of days after March 21st. The date of Easter Day was defined by the Council
* of Nicaea in AD325 as the Sunday after the first full moon which falls on or after the Spring Equinox.
*
- * @link http://en.wikipedia.org/wiki/Easter
+ * @link https://en.wikipedia.org/wiki/Easter
*
- * @param int $year the year for which Easter Saturday need to be created
+ * @param int $year the year for which Easter Saturday need to be created
* @param string $timezone the timezone in which Easter Saturday is celebrated
- * @param string $locale the locale for which Easter Saturday need to be displayed in.
- * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
+ * @param string $locale the locale for which Easter Saturday need to be displayed in.
+ * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
* TYPE_SEASON, TYPE_BANK or TYPE_OTHER. By default an official holiday is considered.
*
- * @return \Yasumi\Holiday
+ * @return Holiday
*
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \InvalidArgumentException
* @throws \Exception
*/
- public function easterSunday($year, $timezone, $locale, $type = Holiday::TYPE_OFFICIAL): Holiday
+ private function easterSaturday($year, $timezone, $locale, $type = null): Holiday
{
return new Holiday(
- 'easter',
- ['en_AU' => 'Easter Sunday'],
- $this->calculateEaster($year, $timezone),
+ 'easterSaturday',
+ ['en' => 'Easter Saturday'],
+ $this->calculateEaster($year, $timezone)->sub(new DateInterval('P1D')),
$locale,
- $type
+ $type ?? Holiday::TYPE_OFFICIAL
);
}
@@ -176,14 +131,60 @@ public function easterSunday($year, $timezone, $locale, $type = Holiday::TYPE_OF
* @throws \InvalidArgumentException
* @throws \Exception
*/
- public function calculateQueensBirthday(): void
+ private function calculateQueensBirthday(): void
{
$this->calculateHoliday(
'queensBirthday',
- ['en_AU' => "Queen's Birthday"],
+ ['en' => "Queen's Birthday"],
new DateTime('second monday of june ' . $this->year, new DateTimeZone($this->timezone)),
false,
false
);
}
+
+ /**
+ * Labour Day
+ *
+ * @throws \Exception
+ */
+ private function calculateLabourDay(): void
+ {
+ $date = new DateTime("first monday of october $this->year", new DateTimeZone($this->timezone));
+
+ $this->addHoliday(new Holiday('labourDay', [], $date, $this->locale));
+ }
+
+ /**
+ * Canberra Day
+ *
+ * @throws \Exception
+ */
+ private function calculateCanberraDay(): void
+ {
+ if ($this->year < 2007) {
+ $date = new DateTime("third monday of march $this->year", new DateTimeZone($this->timezone));
+ } else {
+ $date = new DateTime("second monday of march $this->year", new DateTimeZone($this->timezone));
+ }
+ $this->addHoliday(new Holiday('canberraDay', ['en' => 'Canberra Day'], $date, $this->locale));
+ }
+
+ /**
+ * Reconciliation Day
+ *
+ * @throws \Exception
+ */
+ private function calculateReconciliationDay(): void
+ {
+ if ($this->year < 2018) {
+ return;
+ }
+
+ $date = new DateTime($this->year . '-05-27', new DateTimeZone($this->timezone));
+ $day = (int)$date->format('w');
+ if (1 !== $day) {
+ $date = $date->add(0 === $day ? new DateInterval('P1D') : new DateInterval('P' . (8 - $day) . 'D'));
+ }
+ $this->addHoliday(new Holiday('reconciliationDay', ['en' => 'Reconciliation Day'], $date, $this->locale));
+ }
}
diff --git a/src/Yasumi/Provider/Australia/NSW.php b/src/Yasumi/Provider/Australia/NSW.php
index 73c7efedd..df5c7567e 100644
--- a/src/Yasumi/Provider/Australia/NSW.php
+++ b/src/Yasumi/Provider/Australia/NSW.php
@@ -1,4 +1,4 @@
-addHoliday(new Holiday('easter', ['en_AU' => 'Easter Sunday'], $this->calculateEaster($this->year, $this->timezone), $this->locale));
+ $this->addHoliday(new Holiday('easter', [], $this->calculateEaster($this->year, $this->timezone), $this->locale));
$this->addHoliday($this->easterSaturday($this->year, $this->timezone, $this->locale));
$this->calculateQueensBirthday();
$this->calculateLabourDay();
$this->calculateBankHoliday();
}
- /**
- * Labour Day
- *
- * @throws \Exception
- */
- public function calculateLabourDay(): void
- {
- $date = new DateTime("first monday of october $this->year", new DateTimeZone($this->timezone));
-
- $this->addHoliday(new Holiday('labourDay', [], $date, $this->locale));
- }
-
/**
* Easter Saturday.
*
@@ -69,28 +58,28 @@ public function calculateLabourDay(): void
* on a date based on a certain number of days after March 21st. The date of Easter Day was defined by the Council
* of Nicaea in AD325 as the Sunday after the first full moon which falls on or after the Spring Equinox.
*
- * @link http://en.wikipedia.org/wiki/Easter
+ * @link https://en.wikipedia.org/wiki/Easter
*
- * @param int $year the year for which Easter Saturday need to be created
+ * @param int $year the year for which Easter Saturday need to be created
* @param string $timezone the timezone in which Easter Saturday is celebrated
- * @param string $locale the locale for which Easter Saturday need to be displayed in.
- * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
+ * @param string $locale the locale for which Easter Saturday need to be displayed in.
+ * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
* TYPE_SEASON, TYPE_BANK or TYPE_OTHER. By default an official holiday is considered.
*
- * @return \Yasumi\Holiday
+ * @return Holiday
*
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \InvalidArgumentException
* @throws \Exception
*/
- public function easterSaturday($year, $timezone, $locale, $type = Holiday::TYPE_OFFICIAL): Holiday
+ private function easterSaturday($year, $timezone, $locale, $type = null): Holiday
{
return new Holiday(
'easterSaturday',
- ['en_AU' => 'Easter Saturday'],
+ ['en' => 'Easter Saturday'],
$this->calculateEaster($year, $timezone)->sub(new DateInterval('P1D')),
$locale,
- $type
+ $type ?? Holiday::TYPE_OFFICIAL
);
}
@@ -109,29 +98,41 @@ public function easterSaturday($year, $timezone, $locale, $type = Holiday::TYPE_
* @throws \InvalidArgumentException
* @throws \Exception
*/
- public function calculateQueensBirthday(): void
+ private function calculateQueensBirthday(): void
{
$this->calculateHoliday(
'queensBirthday',
- ['en_AU' => "Queen's Birthday"],
+ ['en' => "Queen's Birthday"],
new DateTime('second monday of june ' . $this->year, new DateTimeZone($this->timezone)),
false,
false
);
}
-
+
+ /**
+ * Labour Day
+ *
+ * @throws \Exception
+ */
+ private function calculateLabourDay(): void
+ {
+ $date = new DateTime("first monday of october $this->year", new DateTimeZone($this->timezone));
+
+ $this->addHoliday(new Holiday('labourDay', [], $date, $this->locale));
+ }
+
/**
* Bank Holiday.
*
* @throws \InvalidArgumentException
* @throws \Exception
*/
- public function calculateBankHoliday(): void
+ private function calculateBankHoliday(): void
{
$this->calculateHoliday(
'bankHoliday',
- ['en_AU' => 'Bank Holiday'],
- new DateTime('first monday of august '. $this->year, new DateTimeZone($this->timezone)),
+ ['en' => 'Bank Holiday'],
+ new DateTime('first monday of august ' . $this->year, new DateTimeZone($this->timezone)),
false,
false,
Holiday::TYPE_BANK
diff --git a/src/Yasumi/Provider/Australia/NT.php b/src/Yasumi/Provider/Australia/NT.php
index effa3dc97..53444460c 100644
--- a/src/Yasumi/Provider/Australia/NT.php
+++ b/src/Yasumi/Provider/Australia/NT.php
@@ -1,4 +1,4 @@
-calculatePicnicDay();
}
- /**
- * May Day
- *
- * @throws \Exception
- */
- public function calculateMayDay(): void
- {
- $date = new DateTime("first monday of may $this->year", new DateTimeZone($this->timezone));
-
- $this->addHoliday(new Holiday('mayDay', ['en_AU' => 'May Day'], $date, $this->locale));
- }
-
- /**
- * Picnic Day
- *
- * @link https://en.wikipedia.org/wiki/Picnic_Day_(Australian_holiday)
- *
- * @throws \InvalidArgumentException
- * @throws \Exception
- */
- public function calculatePicnicDay(): void
- {
- $this->calculateHoliday(
- 'picnicDay',
- ['en_AU' => 'Picnic Day'],
- new DateTime('first monday of august '. $this->year, new DateTimeZone($this->timezone)),
- false,
- false
- );
- }
-
/**
* Easter Saturday.
*
@@ -87,28 +57,28 @@ public function calculatePicnicDay(): void
* on a date based on a certain number of days after March 21st. The date of Easter Day was defined by the Council
* of Nicaea in AD325 as the Sunday after the first full moon which falls on or after the Spring Equinox.
*
- * @link http://en.wikipedia.org/wiki/Easter
+ * @link https://en.wikipedia.org/wiki/Easter
*
- * @param int $year the year for which Easter Saturday need to be created
+ * @param int $year the year for which Easter Saturday need to be created
* @param string $timezone the timezone in which Easter Saturday is celebrated
- * @param string $locale the locale for which Easter Saturday need to be displayed in.
- * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
+ * @param string $locale the locale for which Easter Saturday need to be displayed in.
+ * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
* TYPE_SEASON, TYPE_BANK or TYPE_OTHER. By default an official holiday is considered.
*
- * @return \Yasumi\Holiday
+ * @return Holiday
*
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \InvalidArgumentException
* @throws \Exception
*/
- public function easterSaturday($year, $timezone, $locale, $type = Holiday::TYPE_OFFICIAL): Holiday
+ private function easterSaturday($year, $timezone, $locale, $type = null): Holiday
{
return new Holiday(
'easterSaturday',
- ['en_AU' => 'Easter Saturday'],
+ ['en' => 'Easter Saturday'],
$this->calculateEaster($year, $timezone)->sub(new DateInterval('P1D')),
$locale,
- $type
+ $type ?? Holiday::TYPE_OFFICIAL
);
}
@@ -127,14 +97,45 @@ public function easterSaturday($year, $timezone, $locale, $type = Holiday::TYPE_
* @throws \InvalidArgumentException
* @throws \Exception
*/
- public function calculateQueensBirthday(): void
+ private function calculateQueensBirthday(): void
{
$this->calculateHoliday(
'queensBirthday',
- ['en_AU' => "Queen's Birthday"],
+ ['en' => "Queen's Birthday"],
new DateTime('second monday of june ' . $this->year, new DateTimeZone($this->timezone)),
false,
false
);
}
+
+ /**
+ * May Day
+ *
+ * @throws \Exception
+ */
+ private function calculateMayDay(): void
+ {
+ $date = new DateTime("first monday of may $this->year", new DateTimeZone($this->timezone));
+
+ $this->addHoliday(new Holiday('mayDay', ['en' => 'May Day'], $date, $this->locale));
+ }
+
+ /**
+ * Picnic Day
+ *
+ * @link https://en.wikipedia.org/wiki/Picnic_Day_(Australian_holiday)
+ *
+ * @throws \InvalidArgumentException
+ * @throws \Exception
+ */
+ private function calculatePicnicDay(): void
+ {
+ $this->calculateHoliday(
+ 'picnicDay',
+ ['en' => 'Picnic Day'],
+ new DateTime('first monday of august ' . $this->year, new DateTimeZone($this->timezone)),
+ false,
+ false
+ );
+ }
}
diff --git a/src/Yasumi/Provider/Australia/Queensland.php b/src/Yasumi/Provider/Australia/Queensland.php
index 713dddfa5..0e954878b 100644
--- a/src/Yasumi/Provider/Australia/Queensland.php
+++ b/src/Yasumi/Provider/Australia/Queensland.php
@@ -1,4 +1,4 @@
-calculateLabourDay();
}
- /**
- * Labour Day
- *
- * @throws \Exception
- */
- public function calculateLabourDay(): void
- {
- if ($this->year === 2013 || $this->year === 2014 || $this->year === 2015) {
- $date = new DateTime("first monday of october $this->year", new DateTimeZone($this->timezone));
- } else {
- $date = new DateTime("first monday of may $this->year", new DateTimeZone($this->timezone));
- }
-
- $this->addHoliday(new Holiday('labourDay', [], $date, $this->locale));
- }
-
/**
* Queens Birthday.
*
@@ -77,12 +62,12 @@ public function calculateLabourDay(): void
* @throws \InvalidArgumentException
* @throws \Exception
*/
- public function calculateQueensBirthday(): void
+ private function calculateQueensBirthday(): void
{
- if ($this->year < 2012 || $this->year === 2013 || $this->year === 2014 || $this->year === 2015) {
+ if ($this->year < 2012 || 2013 === $this->year || 2014 === $this->year || 2015 === $this->year) {
$this->calculateHoliday(
'queensBirthday',
- ['en_AU' => "Queen's Birthday"],
+ ['en' => "Queen's Birthday"],
new DateTime('second monday of june ' . $this->year, new DateTimeZone($this->timezone)),
false,
false
@@ -90,11 +75,27 @@ public function calculateQueensBirthday(): void
} else {
$this->calculateHoliday(
'queensBirthday',
- ['en_AU' => "Queen's Birthday"],
+ ['en' => "Queen's Birthday"],
new DateTime('first monday of october ' . $this->year, new DateTimeZone($this->timezone)),
false,
false
);
}
}
+
+ /**
+ * Labour Day
+ *
+ * @throws \Exception
+ */
+ private function calculateLabourDay(): void
+ {
+ if (2013 === $this->year || 2014 === $this->year || 2015 === $this->year) {
+ $date = new DateTime("first monday of october $this->year", new DateTimeZone($this->timezone));
+ } else {
+ $date = new DateTime("first monday of may $this->year", new DateTimeZone($this->timezone));
+ }
+
+ $this->addHoliday(new Holiday('labourDay', [], $date, $this->locale));
+ }
}
diff --git a/src/Yasumi/Provider/Australia/Queensland/Brisbane.php b/src/Yasumi/Provider/Australia/Queensland/Brisbane.php
index de0cb863c..84accf1a6 100644
--- a/src/Yasumi/Provider/Australia/Queensland/Brisbane.php
+++ b/src/Yasumi/Provider/Australia/Queensland/Brisbane.php
@@ -1,4 +1,4 @@
-calculatePeoplesDay();
}
-
+
/**
* Ekka People's Day.
*
@@ -61,16 +62,16 @@ public function initialize(): void
* @link https://en.wikipedia.org/wiki/Ekka
*
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculatePeoplesDay(): void
+ private function calculatePeoplesDay(): void
{
$date = new DateTime('first friday of august ' . $this->year, new DateTimeZone($this->timezone));
if ($date->format('d') < 5) {
$date = $date->add(new DateInterval('P7D'));
}
$date = $date->add(new DateInterval('P5D'));
- $this->addHoliday(new Holiday('peoplesDay', ['en_AU' => 'Ekka People\'s Day'], $date, $this->locale));
+ $this->addHoliday(new Holiday('peoplesDay', ['en' => 'Ekka People\'s Day'], $date, $this->locale));
}
}
diff --git a/src/Yasumi/Provider/Australia/SA.php b/src/Yasumi/Provider/Australia/SA.php
index 1cdabcb34..1f337c229 100644
--- a/src/Yasumi/Provider/Australia/SA.php
+++ b/src/Yasumi/Provider/Australia/SA.php
@@ -1,4 +1,4 @@
-calculateQueensBirthday();
$this->calculateLabourDay();
$this->calculateAdelaideCupDay();
-
+
// South Australia have Proclamation Day instead of Boxing Day, but the date definition is slightly different,
// so we have to rework everything here...
$this->removeHoliday('christmasDay');
@@ -58,36 +59,61 @@ public function initialize(): void
}
/**
- * Proclamation Day
+ * Easter Saturday.
+ *
+ * Easter is a festival and holiday celebrating the resurrection of Jesus Christ from the dead. Easter is celebrated
+ * on a date based on a certain number of days after March 21st. The date of Easter Day was defined by the Council
+ * of Nicaea in AD325 as the Sunday after the first full moon which falls on or after the Spring Equinox.
+ *
+ * @link https://en.wikipedia.org/wiki/Easter
*
+ * @param int $year the year for which Easter Saturday need to be created
+ * @param string $timezone the timezone in which Easter Saturday is celebrated
+ * @param string $locale the locale for which Easter Saturday need to be displayed in.
+ * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
+ * TYPE_SEASON, TYPE_BANK or TYPE_OTHER. By default an official holiday is considered.
+ *
+ * @return Holiday
+ *
+ * @throws UnknownLocaleException
+ * @throws \InvalidArgumentException
* @throws \Exception
*/
- public function calculateProclamationDay(): void
+ private function easterSaturday($year, $timezone, $locale, $type = null): Holiday
{
- $christmasDay = new DateTime("$this->year-12-25", new DateTimeZone($this->timezone));
- $this->calculateHoliday('christmasDay', ['en_AU' => 'Christmas Day'], $christmasDay, false, false);
- switch ($christmasDay->format('w')) {
- case 0: // sunday
- $christmasDay->add(new DateInterval('P1D'));
- $this->calculateHoliday('christmasHoliday', ['en_AU' => 'Christmas Holiday'], $christmasDay, false, false);
- $proclamationDay = $christmasDay->add(new DateInterval('P1D'));
- $this->calculateHoliday('proclamationDay', ['en_AU' => 'Proclamation Day'], $proclamationDay, false, false);
- break;
- case 5: // friday
- $proclamationDay = $christmasDay->add(new DateInterval('P3D'));
- $this->calculateHoliday('proclamationDay', ['en_AU' => 'Proclamation Day'], $proclamationDay, false, false);
- break;
- case 6: // saturday
- $christmasDay->add(new DateInterval('P2D'));
- $this->calculateHoliday('christmasHoliday', ['en_AU' => 'Christmas Holiday'], $christmasDay, false, false);
- $proclamationDay = $christmasDay->add(new DateInterval('P1D'));
- $this->calculateHoliday('proclamationDay', ['en_AU' => 'Proclamation Day'], $proclamationDay, false, false);
- break;
- default: // monday-thursday
- $proclamationDay = $christmasDay->add(new DateInterval('P1D'));
- $this->calculateHoliday('proclamationDay', ['en_AU' => 'Proclamation Day'], $proclamationDay, false, false);
- break;
- }
+ return new Holiday(
+ 'easterSaturday',
+ ['en' => 'Easter Saturday'],
+ $this->calculateEaster($year, $timezone)->sub(new DateInterval('P1D')),
+ $locale,
+ $type ?? Holiday::TYPE_OFFICIAL
+ );
+ }
+
+ /**
+ * Queens Birthday.
+ *
+ * The Queen's Birthday is an Australian public holiday but the date varies across
+ * states and territories. Australia celebrates this holiday because it is a constitutional
+ * monarchy, with the English monarch as head of state.
+ *
+ * Her actual birthday is on April 21, but it's celebrated as a public holiday on the second Monday of June.
+ * (Except QLD & WA)
+ *
+ * @link https://www.timeanddate.com/holidays/australia/queens-birthday
+ *
+ * @throws \InvalidArgumentException
+ * @throws \Exception
+ */
+ private function calculateQueensBirthday(): void
+ {
+ $this->calculateHoliday(
+ 'queensBirthday',
+ ['en' => "Queen's Birthday"],
+ new DateTime('second monday of june ' . $this->year, new DateTimeZone($this->timezone)),
+ false,
+ false
+ );
}
/**
@@ -95,11 +121,11 @@ public function calculateProclamationDay(): void
*
* @throws \Exception
*/
- public function calculateLabourDay(): void
+ private function calculateLabourDay(): void
{
$date = new DateTime("first monday of october $this->year", new DateTimeZone($this->timezone));
- $this->addHoliday(new Holiday('labourDay', ['en_AU' => 'Labour Day'], $date, $this->locale));
+ $this->addHoliday(new Holiday('labourDay', ['en' => 'Labour Day'], $date, $this->locale));
}
/**
@@ -110,13 +136,13 @@ public function calculateLabourDay(): void
* @throws \InvalidArgumentException
* @throws \Exception
*/
- public function calculateAdelaideCupDay(): void
+ private function calculateAdelaideCupDay(): void
{
if ($this->year >= 1973) {
if ($this->year < 2006) {
$this->calculateHoliday(
'adelaideCup',
- ['en_AU' => 'Adelaide Cup'],
+ ['en' => 'Adelaide Cup'],
new DateTime('third monday of may ' . $this->year, new DateTimeZone($this->timezone)),
false,
false
@@ -124,7 +150,7 @@ public function calculateAdelaideCupDay(): void
} else {
$this->calculateHoliday(
'adelaideCup',
- ['en_AU' => 'Adelaide Cup'],
+ ['en' => 'Adelaide Cup'],
new DateTime('second monday of march ' . $this->year, new DateTimeZone($this->timezone)),
false,
false
@@ -132,62 +158,37 @@ public function calculateAdelaideCupDay(): void
}
}
}
-
- /**
- * Easter Saturday.
- *
- * Easter is a festival and holiday celebrating the resurrection of Jesus Christ from the dead. Easter is celebrated
- * on a date based on a certain number of days after March 21st. The date of Easter Day was defined by the Council
- * of Nicaea in AD325 as the Sunday after the first full moon which falls on or after the Spring Equinox.
- *
- * @link http://en.wikipedia.org/wiki/Easter
- *
- * @param int $year the year for which Easter Saturday need to be created
- * @param string $timezone the timezone in which Easter Saturday is celebrated
- * @param string $locale the locale for which Easter Saturday need to be displayed in.
- * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
- * TYPE_SEASON, TYPE_BANK or TYPE_OTHER. By default an official holiday is considered.
- *
- * @return \Yasumi\Holiday
- *
- * @throws \Yasumi\Exception\UnknownLocaleException
- * @throws \InvalidArgumentException
- * @throws \Exception
- */
- public function easterSaturday($year, $timezone, $locale, $type = Holiday::TYPE_OFFICIAL): Holiday
- {
- return new Holiday(
- 'easterSaturday',
- ['en_AU' => 'Easter Saturday'],
- $this->calculateEaster($year, $timezone)->sub(new DateInterval('P1D')),
- $locale,
- $type
- );
- }
/**
- * Queens Birthday.
- *
- * The Queen's Birthday is an Australian public holiday but the date varies across
- * states and territories. Australia celebrates this holiday because it is a constitutional
- * monarchy, with the English monarch as head of state.
- *
- * Her actual birthday is on April 21, but it's celebrated as a public holiday on the second Monday of June.
- * (Except QLD & WA)
- *
- * @link https://www.timeanddate.com/holidays/australia/queens-birthday
+ * Proclamation Day
*
- * @throws \InvalidArgumentException
* @throws \Exception
*/
- public function calculateQueensBirthday(): void
+ private function calculateProclamationDay(): void
{
- $this->calculateHoliday(
- 'queensBirthday',
- ['en_AU' => "Queen's Birthday"],
- new DateTime('second monday of june ' . $this->year, new DateTimeZone($this->timezone)),
- false,
- false
- );
+ $christmasDay = new DateTime("$this->year-12-25", new DateTimeZone($this->timezone));
+ $this->calculateHoliday('christmasDay', [], $christmasDay, false, false);
+ switch ($christmasDay->format('w')) {
+ case 0: // sunday
+ $christmasDay->add(new DateInterval('P1D'));
+ $this->calculateHoliday('christmasHoliday', ['en' => 'Christmas Holiday'], $christmasDay, false, false);
+ $proclamationDay = $christmasDay->add(new DateInterval('P1D'));
+ $this->calculateHoliday('proclamationDay', ['en' => 'Proclamation Day'], $proclamationDay, false, false);
+ break;
+ case 5: // friday
+ $proclamationDay = $christmasDay->add(new DateInterval('P3D'));
+ $this->calculateHoliday('proclamationDay', ['en' => 'Proclamation Day'], $proclamationDay, false, false);
+ break;
+ case 6: // saturday
+ $christmasDay->add(new DateInterval('P2D'));
+ $this->calculateHoliday('christmasHoliday', ['en' => 'Christmas Holiday'], $christmasDay, false, false);
+ $proclamationDay = $christmasDay->add(new DateInterval('P1D'));
+ $this->calculateHoliday('proclamationDay', ['en' => 'Proclamation Day'], $proclamationDay, false, false);
+ break;
+ default: // monday-thursday
+ $proclamationDay = $christmasDay->add(new DateInterval('P1D'));
+ $this->calculateHoliday('proclamationDay', ['en' => 'Proclamation Day'], $proclamationDay, false, false);
+ break;
+ }
}
}
diff --git a/src/Yasumi/Provider/Australia/Tasmania.php b/src/Yasumi/Provider/Australia/Tasmania.php
index 6e055a598..bf53bbe03 100644
--- a/src/Yasumi/Provider/Australia/Tasmania.php
+++ b/src/Yasumi/Provider/Australia/Tasmania.php
@@ -1,4 +1,4 @@
-year", new DateTimeZone($this->timezone));
- $this->addHoliday(new Holiday('eightHourDay', ['en_AU' => 'Eight Hour Day'], $date, $this->locale));
+ $this->addHoliday(new Holiday('eightHourDay', ['en' => 'Eight Hour Day'], $date, $this->locale));
}
-
+
/**
* Queens Birthday.
*
@@ -74,17 +75,17 @@ public function calculateEightHoursDay(): void
* @throws \InvalidArgumentException
* @throws \Exception
*/
- public function calculateQueensBirthday(): void
+ private function calculateQueensBirthday(): void
{
$this->calculateHoliday(
'queensBirthday',
- ['en_AU' => 'Queen\'s Birthday'],
+ ['en' => 'Queen\'s Birthday'],
new DateTime('second monday of june ' . $this->year, new DateTimeZone($this->timezone)),
false,
false
);
}
-
+
/**
* Recreation Day
*
@@ -93,11 +94,11 @@ public function calculateQueensBirthday(): void
* @throws \InvalidArgumentException
* @throws \Exception
*/
- public function calculateRecreationDay(): void
+ private function calculateRecreationDay(): void
{
$this->calculateHoliday(
'recreationDay',
- ['en_AU' => 'Recreation Day'],
+ ['en' => 'Recreation Day'],
new DateTime('first monday of november ' . $this->year, new DateTimeZone($this->timezone)),
false,
false
diff --git a/src/Yasumi/Provider/Australia/Tasmania/CentralNorth.php b/src/Yasumi/Provider/Australia/Tasmania/CentralNorth.php
index a060a16c9..65761d3fb 100644
--- a/src/Yasumi/Provider/Australia/Tasmania/CentralNorth.php
+++ b/src/Yasumi/Provider/Australia/Tasmania/CentralNorth.php
@@ -1,4 +1,4 @@
-year . '-12-02', new DateTimeZone($this->timezone));
$date = $date->modify('previous friday');
- $this->addHoliday(new Holiday('devonportShow', ['en_AU' => 'Devonport Show'], $date, $this->locale));
+ $this->addHoliday(new Holiday('devonportShow', ['en' => 'Devonport Show'], $date, $this->locale));
}
}
diff --git a/src/Yasumi/Provider/Australia/Tasmania/FlindersIsland.php b/src/Yasumi/Provider/Australia/Tasmania/FlindersIsland.php
index 5bcf55cbe..2dedb98d8 100644
--- a/src/Yasumi/Provider/Australia/Tasmania/FlindersIsland.php
+++ b/src/Yasumi/Provider/Australia/Tasmania/FlindersIsland.php
@@ -1,4 +1,4 @@
-year, new DateTimeZone($this->timezone));
$date = $date->sub(new DateInterval('P1D'));
- $this->addHoliday(new Holiday('flindersIslandShow', ['en_AU' => 'Flinders Island Show'], $date, $this->locale));
+ $this->addHoliday(new Holiday('flindersIslandShow', ['en' => 'Flinders Island Show'], $date, $this->locale));
}
}
diff --git a/src/Yasumi/Provider/Australia/Tasmania/KingIsland.php b/src/Yasumi/Provider/Australia/Tasmania/KingIsland.php
index 040ad4625..f26bdd06d 100644
--- a/src/Yasumi/Provider/Australia/Tasmania/KingIsland.php
+++ b/src/Yasumi/Provider/Australia/Tasmania/KingIsland.php
@@ -1,4 +1,4 @@
-calculateHoliday(
'kingIslandShow',
- ['en_AU' => 'King Island Show'],
+ ['en' => 'King Island Show'],
new DateTime('first tuesday of march ' . $this->year, new DateTimeZone($this->timezone)),
false,
false
diff --git a/src/Yasumi/Provider/Australia/Tasmania/Northeast.php b/src/Yasumi/Provider/Australia/Tasmania/Northeast.php
index 354c9b372..dcd67f1c1 100644
--- a/src/Yasumi/Provider/Australia/Tasmania/Northeast.php
+++ b/src/Yasumi/Provider/Australia/Tasmania/Northeast.php
@@ -1,4 +1,4 @@
-year, new DateTimeZone($this->timezone));
$date = $date->sub(new DateInterval('P2D'));
- $this->addHoliday(new Holiday('launcestonShow', ['en_AU' => 'Royal Launceston Show'], $date, $this->locale));
+ $this->addHoliday(new Holiday('launcestonShow', ['en' => 'Royal Launceston Show'], $date, $this->locale));
}
}
diff --git a/src/Yasumi/Provider/Australia/Tasmania/Northwest.php b/src/Yasumi/Provider/Australia/Tasmania/Northwest.php
index 893576365..049d56c0f 100644
--- a/src/Yasumi/Provider/Australia/Tasmania/Northwest.php
+++ b/src/Yasumi/Provider/Australia/Tasmania/Northwest.php
@@ -1,4 +1,4 @@
-year, new DateTimeZone($this->timezone));
$date = $date->sub(new DateInterval('P1D'));
- $this->addHoliday(new Holiday('burnieShow', ['en_AU' => 'Burnie Show'], $date, $this->locale));
+ $this->addHoliday(new Holiday('burnieShow', ['en' => 'Burnie Show'], $date, $this->locale));
}
}
diff --git a/src/Yasumi/Provider/Australia/Tasmania/Northwest/CircularHead.php b/src/Yasumi/Provider/Australia/Tasmania/Northwest/CircularHead.php
index 6f36f8ab7..4c7108281 100644
--- a/src/Yasumi/Provider/Australia/Tasmania/Northwest/CircularHead.php
+++ b/src/Yasumi/Provider/Australia/Tasmania/Northwest/CircularHead.php
@@ -1,4 +1,4 @@
-year, new DateTimeZone($this->timezone));
$date = $date->add(new DateInterval('P1D'));
- $this->addHoliday(new Holiday('agfest', ['en_AU' => 'AGFEST'], $date, $this->locale));
+ $this->addHoliday(new Holiday('agfest', ['en' => 'AGFEST'], $date, $this->locale));
}
}
diff --git a/src/Yasumi/Provider/Australia/Tasmania/South.php b/src/Yasumi/Provider/Australia/Tasmania/South.php
index cbf1977b4..562b59de0 100644
--- a/src/Yasumi/Provider/Australia/Tasmania/South.php
+++ b/src/Yasumi/Provider/Australia/Tasmania/South.php
@@ -1,4 +1,4 @@
-year, new DateTimeZone($this->timezone));
$date = $date->sub(new DateInterval('P2D'));
- $this->addHoliday(new Holiday('hobartShow', ['en_AU' => 'Royal Hobart Show'], $date, $this->locale));
+ $this->addHoliday(new Holiday('hobartShow', ['en' => 'Royal Hobart Show'], $date, $this->locale));
}
}
diff --git a/src/Yasumi/Provider/Australia/Tasmania/South/Southeast.php b/src/Yasumi/Provider/Australia/Tasmania/South/Southeast.php
index 9f2014159..c1ae91d3c 100644
--- a/src/Yasumi/Provider/Australia/Tasmania/South/Southeast.php
+++ b/src/Yasumi/Provider/Australia/Tasmania/South/Southeast.php
@@ -1,4 +1,4 @@
-calculateHoliday(
'hobartRegatta',
- ['en_AU' => 'Royal Hobart Regatta'],
+ ['en' => 'Royal Hobart Regatta'],
new DateTime('second monday of february ' . $this->year, new DateTimeZone($this->timezone)),
false,
false
diff --git a/src/Yasumi/Provider/Australia/Victoria.php b/src/Yasumi/Provider/Australia/Victoria.php
index 7c2a87af1..88a9a2ccf 100644
--- a/src/Yasumi/Provider/Australia/Victoria.php
+++ b/src/Yasumi/Provider/Australia/Victoria.php
@@ -1,4 +1,4 @@
-year", new DateTimeZone($this->timezone));
-
- $this->addHoliday(new Holiday('labourDay', ['en_AU' => 'Labour Day'], $date, $this->locale));
+ return new Holiday(
+ 'easter',
+ ['en' => 'Easter Sunday'],
+ $this->calculateEaster($year, $timezone),
+ $locale,
+ $type ?? Holiday::TYPE_OFFICIAL
+ );
}
/**
- * Melbourne Cup Day
+ * Easter Saturday.
+ *
+ * Easter is a festival and holiday celebrating the resurrection of Jesus Christ from the dead. Easter is celebrated
+ * on a date based on a certain number of days after March 21st. The date of Easter Day was defined by the Council
+ * of Nicaea in AD325 as the Sunday after the first full moon which falls on or after the Spring Equinox.
+ *
+ * @link https://en.wikipedia.org/wiki/Easter
+ *
+ * @param int $year the year for which Easter Saturday need to be created
+ * @param string $timezone the timezone in which Easter Saturday is celebrated
+ * @param string $locale the locale for which Easter Saturday need to be displayed in.
+ * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
+ * TYPE_SEASON, TYPE_BANK or TYPE_OTHER. By default an official holiday is considered.
+ *
+ * @return Holiday
*
+ * @throws UnknownLocaleException
+ * @throws \InvalidArgumentException
* @throws \Exception
*/
- public function calculateMelbourneCupDay(): void
+ private function easterSaturday($year, $timezone, $locale, $type = null): Holiday
{
- $date = new DateTime('first Tuesday of November' . " $this->year", new DateTimeZone($this->timezone));
-
- $this->addHoliday(new Holiday('melbourneCup', ['en_AU' => 'Melbourne Cup'], $date, $this->locale));
+ return new Holiday(
+ 'easterSaturday',
+ ['en' => 'Easter Saturday'],
+ $this->calculateEaster($year, $timezone)->sub(new DateInterval('P1D')),
+ $locale,
+ $type ?? Holiday::TYPE_OFFICIAL
+ );
}
/**
- * AFL Grand Final Day
+ * Labour Day
*
* @throws \Exception
*/
- public function calculateAFLGrandFinalDay(): void
+ private function calculateLabourDay(): void
{
- switch ($this->year) {
- case 2015:
- $aflGrandFinalFriday = '2015-10-02';
- break;
- case 2016:
- $aflGrandFinalFriday = '2016-09-30';
- break;
- case 2017:
- $aflGrandFinalFriday = '2017-09-29';
- break;
- case 2018:
- $aflGrandFinalFriday = '2018-09-28';
- break;
- default:
- return;
- }
-
- $date = new DateTime($aflGrandFinalFriday, new DateTimeZone($this->timezone));
+ $date = new DateTime("second monday of march $this->year", new DateTimeZone($this->timezone));
- $this->addHoliday(new Holiday(
- 'aflGrandFinalFriday',
- ['en_AU' => 'AFL Grand Final Friday'],
- $date,
- $this->locale
- ));
+ $this->addHoliday(new Holiday('labourDay', [], $date, $this->locale));
}
/**
@@ -124,11 +143,11 @@ public function calculateAFLGrandFinalDay(): void
* @throws \InvalidArgumentException
* @throws \Exception
*/
- public function calculateQueensBirthday(): void
+ private function calculateQueensBirthday(): void
{
$this->calculateHoliday(
'queensBirthday',
- ['en_AU' => 'Queen\'s Birthday'],
+ ['en' => 'Queen\'s Birthday'],
new DateTime('second monday of june ' . $this->year, new DateTimeZone($this->timezone)),
false,
false
@@ -136,66 +155,48 @@ public function calculateQueensBirthday(): void
}
/**
- * Easter Saturday.
- *
- * Easter is a festival and holiday celebrating the resurrection of Jesus Christ from the dead. Easter is celebrated
- * on a date based on a certain number of days after March 21st. The date of Easter Day was defined by the Council
- * of Nicaea in AD325 as the Sunday after the first full moon which falls on or after the Spring Equinox.
- *
- * @link http://en.wikipedia.org/wiki/Easter
- *
- * @param int $year the year for which Easter Saturday need to be created
- * @param string $timezone the timezone in which Easter Saturday is celebrated
- * @param string $locale the locale for which Easter Saturday need to be displayed in.
- * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
- * TYPE_SEASON, TYPE_BANK or TYPE_OTHER. By default an official holiday is considered.
- *
- * @return \Yasumi\Holiday
+ * Melbourne Cup Day
*
- * @throws \Yasumi\Exception\UnknownLocaleException
- * @throws \InvalidArgumentException
* @throws \Exception
*/
- public function easterSaturday($year, $timezone, $locale, $type = Holiday::TYPE_OFFICIAL): Holiday
+ private function calculateMelbourneCupDay(): void
{
- return new Holiday(
- 'easterSaturday',
- ['en_AU' => 'Easter Saturday'],
- $this->calculateEaster($year, $timezone)->sub(new DateInterval('P1D')),
- $locale,
- $type
- );
+ $date = new DateTime('first Tuesday of November' . " $this->year", new DateTimeZone($this->timezone));
+
+ $this->addHoliday(new Holiday('melbourneCup', ['en' => 'Melbourne Cup'], $date, $this->locale));
}
-
+
/**
- * Easter Sunday.
- *
- * Easter is a festival and holiday celebrating the resurrection of Jesus Christ from the dead. Easter is celebrated
- * on a date based on a certain number of days after March 21st. The date of Easter Day was defined by the Council
- * of Nicaea in AD325 as the Sunday after the first full moon which falls on or after the Spring Equinox.
- *
- * @link http://en.wikipedia.org/wiki/Easter
- *
- * @param int $year the year for which Easter Saturday need to be created
- * @param string $timezone the timezone in which Easter Saturday is celebrated
- * @param string $locale the locale for which Easter Saturday need to be displayed in.
- * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
- * TYPE_SEASON, TYPE_BANK or TYPE_OTHER. By default an official holiday is considered.
- *
- * @return \Yasumi\Holiday
+ * AFL Grand Final Day
*
- * @throws \Yasumi\Exception\UnknownLocaleException
- * @throws \InvalidArgumentException
* @throws \Exception
*/
- public function easterSunday($year, $timezone, $locale, $type = Holiday::TYPE_OFFICIAL): Holiday
+ private function calculateAFLGrandFinalDay(): void
{
- return new Holiday(
- 'easter',
- ['en_AU' => 'Easter Sunday'],
- $this->calculateEaster($year, $timezone),
- $locale,
- $type
- );
+ switch ($this->year) {
+ case 2015:
+ $aflGrandFinalFriday = '2015-10-02';
+ break;
+ case 2016:
+ $aflGrandFinalFriday = '2016-09-30';
+ break;
+ case 2017:
+ $aflGrandFinalFriday = '2017-09-29';
+ break;
+ case 2018:
+ $aflGrandFinalFriday = '2018-09-28';
+ break;
+ default:
+ return;
+ }
+
+ $date = new DateTime($aflGrandFinalFriday, new DateTimeZone($this->timezone));
+
+ $this->addHoliday(new Holiday(
+ 'aflGrandFinalFriday',
+ ['en' => 'AFL Grand Final Friday'],
+ $date,
+ $this->locale
+ ));
}
}
diff --git a/src/Yasumi/Provider/Australia/WA.php b/src/Yasumi/Provider/Australia/WA.php
index de7dd89b6..74649e098 100644
--- a/src/Yasumi/Provider/Australia/WA.php
+++ b/src/Yasumi/Provider/Australia/WA.php
@@ -1,4 +1,4 @@
-calculateWesternAustraliaDay();
}
- /**
- * Labour Day
- *
- * @throws \Exception
- */
- public function calculateLabourDay(): void
- {
- $date = new DateTime("first monday of march $this->year", new DateTimeZone($this->timezone));
-
- $this->addHoliday(new Holiday('labourDay', [], $date, $this->locale));
- }
-
- /**
- * Western Australia Day
- *
- * @link https://en.wikipedia.org/wiki/Western_Australia_Day
- *
- * @throws \InvalidArgumentException
- * @throws \Exception
- */
- public function calculateWesternAustraliaDay(): void
- {
- $this->calculateHoliday(
- 'westernAustraliaDay',
- ['en_AU' => 'Western Australia Day'],
- new DateTime('first monday of june ' . $this->year, new DateTimeZone($this->timezone)),
- false,
- false
- );
- }
-
/**
* Queens Birthday.
*
@@ -93,20 +63,20 @@ public function calculateWesternAustraliaDay(): void
* @throws \InvalidArgumentException
* @throws \Exception
*/
- public function calculateQueensBirthday(): void
+ private function calculateQueensBirthday(): void
{
- if ($this->year === 2011) {
+ if (2011 === $this->year) {
$this->calculateHoliday(
'queensBirthday',
- ['en_AU' => "Queen's Birthday"],
+ ['en' => "Queen's Birthday"],
new DateTime('2011-10-28', new DateTimeZone($this->timezone)),
false,
false
);
- } elseif ($this->year === 2012) {
+ } elseif (2012 === $this->year) {
$this->calculateHoliday(
'queensBirthday',
- ['en_AU' => "Queen's Birthday"],
+ ['en' => "Queen's Birthday"],
new DateTime('2012-10-01', new DateTimeZone($this->timezone)),
false,
false
@@ -114,11 +84,42 @@ public function calculateQueensBirthday(): void
} else {
$this->calculateHoliday(
'queensBirthday',
- ['en_AU' => "Queen's Birthday"],
+ ['en' => "Queen's Birthday"],
new DateTime('last monday of september ' . $this->year, new DateTimeZone($this->timezone)),
false,
false
);
}
}
+
+ /**
+ * Labour Day
+ *
+ * @throws \Exception
+ */
+ private function calculateLabourDay(): void
+ {
+ $date = new DateTime("first monday of march $this->year", new DateTimeZone($this->timezone));
+
+ $this->addHoliday(new Holiday('labourDay', [], $date, $this->locale));
+ }
+
+ /**
+ * Western Australia Day
+ *
+ * @link https://en.wikipedia.org/wiki/Western_Australia_Day
+ *
+ * @throws \InvalidArgumentException
+ * @throws \Exception
+ */
+ private function calculateWesternAustraliaDay(): void
+ {
+ $this->calculateHoliday(
+ 'westernAustraliaDay',
+ ['en' => 'Western Australia Day'],
+ new DateTime('first monday of june ' . $this->year, new DateTimeZone($this->timezone)),
+ false,
+ false
+ );
+ }
}
diff --git a/src/Yasumi/Provider/Austria.php b/src/Yasumi/Provider/Austria.php
index aaccc065d..0d31900db 100644
--- a/src/Yasumi/Provider/Austria.php
+++ b/src/Yasumi/Provider/Austria.php
@@ -1,4 +1,4 @@
-year < 1955) {
return;
@@ -86,7 +88,7 @@ public function calculateNationalDay(): void
$this->addHoliday(new Holiday(
'nationalDay',
- ['de_AT' => 'Nationalfeiertag'],
+ ['de' => 'Nationalfeiertag'],
new DateTime($this->year . '-10-26', new \DateTimeZone($this->timezone)),
$this->locale
));
diff --git a/src/Yasumi/Provider/Belgium.php b/src/Yasumi/Provider/Belgium.php
index 9444f06fb..720a68c56 100755
--- a/src/Yasumi/Provider/Belgium.php
+++ b/src/Yasumi/Provider/Belgium.php
@@ -1,4 +1,4 @@
-addHoliday(new Holiday('nationalDay', [
- 'fr_FR' => 'Fête nationale',
- 'fr_BE' => 'Fête nationale',
- 'en_US' => 'Belgian National Day',
- 'nl_NL' => 'Nationale feestdag',
- 'nl_BE' => 'Nationale feestdag',
+ 'fr' => 'Fête nationale',
+ 'en' => 'Belgian National Day',
+ 'nl' => 'Nationale feestdag',
], new DateTime("$this->year-7-21", new DateTimeZone($this->timezone)), $this->locale));
}
}
diff --git a/src/Yasumi/Provider/Bosnia.php b/src/Yasumi/Provider/Bosnia.php
index d90f7e44b..5ec2b109a 100644
--- a/src/Yasumi/Provider/Bosnia.php
+++ b/src/Yasumi/Provider/Bosnia.php
@@ -1,4 +1,4 @@
-addHoliday(new Holiday('orthodoxChristmasDay', [
- 'en_US' => 'Orthodox Christmas Day',
- 'bs_Latn_BA' => 'Pravoslavni Božić'
- ], new \DateTime("{$this->year}-01-07", new \DateTimeZone($this->timezone))));
-
+ 'en' => 'Orthodox Christmas Day',
+ 'bs_Latn' => 'Pravoslavni Božić',
+ ], new DateTime("{$this->year}-01-07", new DateTimeZone($this->timezone))));
/**
* Independence Day
*/
if ($this->year >= 1992) {
$this->addHoliday(new Holiday('independenceDay', [
- 'en_US' => 'Independence Day',
- 'bs_Latn_BA' => 'Dan Nezavisnosti'
+ 'en' => 'Independence Day',
+ 'bs_Latn' => 'Dan Nezavisnosti',
], new DateTime("$this->year-3-1", new DateTimeZone($this->timezone)), $this->locale));
}
@@ -75,8 +76,8 @@ public function initialize(): void
*/
if ($this->year >= 1943) {
$this->addHoliday(new Holiday('statehoodDay', [
- 'en_US' => 'Statehood Day',
- 'bs_Latn_BA' => 'Dan državnosti'
+ 'en' => 'Statehood Day',
+ 'bs_Latn' => 'Dan državnosti',
], new DateTime("$this->year-11-25", new DateTimeZone($this->timezone)), $this->locale));
}
@@ -84,16 +85,16 @@ public function initialize(): void
* Day after New Years Day
*/
$this->addHoliday(new Holiday('dayAfterNewYearsDay', [
- 'en_US' => 'Day after New Year\'s Day',
- 'ro_RO' => 'Nova godina - drugi dan'
+ 'en' => 'Day after New Year\'s Day',
+ 'bs_Latn' => 'Nova godina - drugi dan',
], new DateTime("$this->year-01-02", new DateTimeZone($this->timezone)), $this->locale));
/**
* Second Labour day
*/
$this->addHoliday(new Holiday('secondLabourDay', [
- 'en_US' => 'Second Labour Day',
- 'ro_RO' => 'Praznik rada - drugi dan'
+ 'en' => 'Second Labour Day',
+ 'bs_Latn' => 'Praznik rada - drugi dan',
], new DateTime("$this->year-05-02", new DateTimeZone($this->timezone)), $this->locale));
}
}
diff --git a/src/Yasumi/Provider/Brazil.php b/src/Yasumi/Provider/Brazil.php
index 278e3f973..fa27e96a8 100644
--- a/src/Yasumi/Provider/Brazil.php
+++ b/src/Yasumi/Provider/Brazil.php
@@ -1,4 +1,4 @@
-addHoliday($this->christmasDay($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->easter($this->year, $this->timezone, $this->locale, Holiday::TYPE_OBSERVANCE));
$this->addHoliday($this->corpusChristi($this->year, $this->timezone, $this->locale, Holiday::TYPE_OBSERVANCE));
- $this->addHoliday($this->goodFriday($this->year, $this->timezone, $this->locale));
+ $this->addHoliday($this->goodFriday($this->year, $this->timezone, $this->locale, Holiday::TYPE_OBSERVANCE));
$this->addHoliday($this->ashWednesday($this->year, $this->timezone, $this->locale, Holiday::TYPE_OBSERVANCE));
/**
@@ -66,21 +68,21 @@ public function initialize(): void
$carnavalMonday = clone $easter;
$this->addHoliday(new Holiday(
- 'carnavalMonday',
- ['pt_BR' => 'Segunda-feira de Carnaval'],
- $carnavalMonday->sub(new DateInterval('P48D')),
- $this->locale,
- Holiday::TYPE_OBSERVANCE
- ));
+ 'carnavalMonday',
+ ['pt' => 'Segunda-feira de Carnaval'],
+ $carnavalMonday->sub(new DateInterval('P48D')),
+ $this->locale,
+ Holiday::TYPE_OBSERVANCE
+ ));
$carnavalTuesday = clone $easter;
$this->addHoliday(new Holiday(
- 'carnavalTuesday',
- ['pt_BR' => 'Terça-feira de Carnaval'],
- $carnavalTuesday->sub(new DateInterval('P47D')),
- $this->locale,
- Holiday::TYPE_OBSERVANCE
- ));
+ 'carnavalTuesday',
+ ['pt' => 'Terça-feira de Carnaval'],
+ $carnavalTuesday->sub(new DateInterval('P47D')),
+ $this->locale,
+ Holiday::TYPE_OBSERVANCE
+ ));
}
/**
@@ -95,7 +97,7 @@ public function initialize(): void
if ($this->year >= 1792) {
$this->addHoliday(new Holiday(
'tiradentesDay',
- ['pt_BR' => 'Dia de Tiradentes'],
+ ['pt' => 'Dia de Tiradentes'],
new DateTime("$this->year-04-21", new DateTimeZone($this->timezone)),
$this->locale
));
@@ -112,7 +114,7 @@ public function initialize(): void
if ($this->year >= 1822) {
$this->addHoliday(new Holiday(
'independenceDay',
- ['pt_BR' => 'Dia da Independência do Brasil'],
+ ['pt' => 'Dia da Independência do Brasil'],
new DateTime("$this->year-09-07", new DateTimeZone($this->timezone)),
$this->locale
));
@@ -132,7 +134,7 @@ public function initialize(): void
if ($this->year >= 1980) {
$this->addHoliday(new Holiday(
'ourLadyOfAparecidaDay',
- ['pt_BR' => 'Dia de Nossa Senhora Aparecida'],
+ ['pt' => 'Dia de Nossa Senhora Aparecida'],
new DateTime("$this->year-10-12", new DateTimeZone($this->timezone)),
$this->locale
));
@@ -148,7 +150,7 @@ public function initialize(): void
if ($this->year >= 1300) {
$this->addHoliday(new Holiday(
'allSoulsDay',
- ['pt_BR' => 'Dia de Finados'],
+ ['pt' => 'Dia de Finados'],
new DateTime("$this->year-11-02", new DateTimeZone($this->timezone)),
$this->locale
));
@@ -166,7 +168,7 @@ public function initialize(): void
if ($this->year >= 1889) {
$this->addHoliday(new Holiday(
'proclamationOfRepublicDay',
- ['pt_BR' => 'Dia da Proclamação da República'],
+ ['pt' => 'Dia da Proclamação da República'],
new DateTime("$this->year-11-15", new DateTimeZone($this->timezone)),
$this->locale
));
diff --git a/src/Yasumi/Provider/ChristianHolidays.php b/src/Yasumi/Provider/ChristianHolidays.php
index aa1743788..17fe0aa28 100644
--- a/src/Yasumi/Provider/ChristianHolidays.php
+++ b/src/Yasumi/Provider/ChristianHolidays.php
@@ -1,4 +1,4 @@
-calculateEaster($year, $timezone), $locale, $type);
+ return new Holiday('easter', [], $this->calculateEaster($year, $timezone), $locale, $type);
+ }
+
+ /**
+ * Calculates the date for Easter.
+ *
+ * Easter is a festival and holiday celebrating the resurrection of Jesus Christ from the dead. Easter is celebrated
+ * on a date based on a certain number of days after March 21st.
+ *
+ * This function uses the standard PHP 'easter_days' function if the calendar extension is enabled. In case the
+ * calendar function is not enabled, a fallback calculation has been implemented that is based on the same
+ * 'easter_days' c function.
+ *
+ * Note: In calendrical calculations, frequently operations called integer division are used.
+ *
+ * @param int $year the year for which Easter needs to be calculated
+ * @param string $timezone the timezone in which Easter is celebrated
+ *
+ * @return DateTime date of Easter
+ * @throws \Exception
+ * @see easter_days
+ *
+ * @link https://github.com/php/php-src/blob/c8aa6f3a9a3d2c114d0c5e0c9fdd0a465dbb54a5/ext/calendar/easter.c
+ * @link http://www.gmarts.org/index.php?go=415#EasterMallen
+ * @link https://www.tondering.dk/claus/cal/easter.php
+ *
+ */
+ protected function calculateEaster(int $year, string $timezone): DateTime
+ {
+ if (\extension_loaded('calendar')) {
+ $easter_days = \easter_days($year);
+ } else {
+ $golden = ($year % 19) + 1; // The Golden Number
+
+ // The Julian calendar applies to the original method from 326AD. The Gregorian calendar was first
+ // introduced in October 1582 in Italy. Easter algorithms using the Gregorian calendar apply to years
+ // 1583 AD to 4099 (A day adjustment is required in or shortly after 4100 AD).
+ // After 1752, most western churches have adopted the current algorithm.
+ if ($year <= 1752) {
+ $dom = ($year + (int)($year / 4) + 5) % 7; // The 'Dominical number' - finding a Sunday
+ if ($dom < 0) {
+ $dom += 7;
+ }
+
+ $pfm = (3 - (11 * $golden) - 7) % 30; // Uncorrected date of the Paschal full moon
+ if ($pfm < 0) {
+ $pfm += 30;
+ }
+ } else {
+ $dom = ($year + (int)($year / 4) - (int)($year / 100) + (int)($year / 400)) % 7; // The 'Dominical number' - finding a Sunday
+ if ($dom < 0) {
+ $dom += 7;
+ }
+
+ $solar = (int)(($year - 1600) / 100) - (int)(($year - 1600) / 400); // The solar correction
+ $lunar = (int)(((int)(($year - 1400) / 100) * 8) / 25); // The lunar correction
+
+ $pfm = (3 - (11 * $golden) + $solar - $lunar) % 30; // Uncorrected date of the Paschal full moon
+ if ($pfm < 0) {
+ $pfm += 30;
+ }
+ }
+
+ // Corrected date of the Paschal full moon, - days after 21st March
+ if ((29 === $pfm) || (28 === $pfm && $golden > 11)) {
+ --$pfm;
+ }
+
+ $tmp = (4 - $pfm - $dom) % 7;
+ if ($tmp < 0) {
+ $tmp += 7;
+ }
+
+ $easter_days = $pfm + $tmp + 1; // Easter as the number of days after 21st March
+ }
+
+ $easter = new DateTime("$year-3-21", new DateTimeZone($timezone));
+ $easter->add(new DateInterval('P' . $easter_days . 'D'));
+
+ return $easter;
}
/**
@@ -59,18 +140,18 @@ public function easter(int $year, string $timezone, string $locale, string $type
* on a date based on a certain number of days after March 21st. The date of Easter Day was defined by the Council
* of Nicaea in AD325 as the Sunday after the first full moon which falls on or after the Spring Equinox.
*
- * @link http://en.wikipedia.org/wiki/Easter
+ * @link https://en.wikipedia.org/wiki/Easter
*
- * @param int $year the year for which Easter Monday need to be created
+ * @param int $year the year for which Easter Monday need to be created
* @param string $timezone the timezone in which Easter Monday is celebrated
- * @param string $locale the locale for which Easter Monday need to be displayed in.
- * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
+ * @param string $locale the locale for which Easter Monday need to be displayed in.
+ * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
* TYPE_SEASON, TYPE_BANK or TYPE_OTHER. By default an official holiday is considered.
*
- * @return \Yasumi\Holiday
+ * @return Holiday
*
- * @throws \Yasumi\Exception\InvalidDateException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws InvalidDateException
+ * @throws UnknownLocaleException
* @throws \InvalidArgumentException
* @throws \Exception
*/
@@ -96,18 +177,18 @@ public function easterMonday(
* Christian churches. Ascension Day is traditionally celebrated on a Thursday, the fortieth day of Easter although
* some Catholic provinces have moved the observance to the following Sunday.
*
- * @link http://en.wikipedia.org/wiki/Feast_of_the_Ascension
+ * @link https://en.wikipedia.org/wiki/Feast_of_the_Ascension
*
- * @param int $year the year for which Ascension need to be created
+ * @param int $year the year for which Ascension need to be created
* @param string $timezone the timezone in which Ascension is celebrated
- * @param string $locale the locale for which Ascension need to be displayed in.
- * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
+ * @param string $locale the locale for which Ascension need to be displayed in.
+ * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
* TYPE_SEASON, TYPE_BANK or TYPE_OTHER. By default an official holiday is considered.
*
- * @return \Yasumi\Holiday
+ * @return Holiday
*
- * @throws \Yasumi\Exception\InvalidDateException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws InvalidDateException
+ * @throws UnknownLocaleException
* @throws \InvalidArgumentException
* @throws \Exception
*/
@@ -132,16 +213,16 @@ public function ascensionDay(
* Pentecost a feast commemorating the descent of the Holy Spirit upon the Apostles and other followers of Jesus
* Christ. It is celebrated 49 days after Easter and always takes place on Sunday.
*
- * @param int $year the year for which Pentecost need to be created
+ * @param int $year the year for which Pentecost need to be created
* @param string $timezone the timezone in which Pentecost is celebrated
- * @param string $locale the locale for which Pentecost need to be displayed in.
- * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
+ * @param string $locale the locale for which Pentecost need to be displayed in.
+ * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
* TYPE_SEASON, TYPE_BANK or TYPE_OTHER. By default an official holiday is considered.
*
- * @return \Yasumi\Holiday
+ * @return Holiday
*
- * @throws \Yasumi\Exception\InvalidDateException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws InvalidDateException
+ * @throws UnknownLocaleException
* @throws \InvalidArgumentException
* @throws \Exception
*/
@@ -166,16 +247,16 @@ public function pentecost(
* Pentecost a feast commemorating the descent of the Holy Spirit upon the Apostles and other followers of Jesus
* Christ. It is celebrated 49 days after Easter and always takes place on Sunday.
*
- * @param int $year the year for which Pentecost (Whitmonday) need to be created
+ * @param int $year the year for which Pentecost (Whitmonday) need to be created
* @param string $timezone the timezone in which Pentecost (Whitmonday) is celebrated
- * @param string $locale the locale for which Pentecost (Whitmonday) need to be displayed in.
- * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
+ * @param string $locale the locale for which Pentecost (Whitmonday) need to be displayed in.
+ * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
* TYPE_SEASON, TYPE_BANK or TYPE_OTHER. By default an official holiday is considered.
*
- * @return \Yasumi\Holiday
+ * @return Holiday
*
- * @throws \Yasumi\Exception\InvalidDateException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws InvalidDateException
+ * @throws UnknownLocaleException
* @throws \InvalidArgumentException
* @throws \Exception
*/
@@ -203,16 +284,16 @@ public function pentecostMonday(
* The Most Holy Body and Blood of Christ is not a holy day of obligation, it is assigned to the Sunday after the
* Most Holy Trinity as its proper day". This is 60 days after Easter.
*
- * @param int $year the year for which Corpus Christi need to be created
+ * @param int $year the year for which Corpus Christi need to be created
* @param string $timezone the timezone in which Corpus Christi is celebrated
- * @param string $locale the locale for which Corpus Christi need to be displayed in.
- * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
+ * @param string $locale the locale for which Corpus Christi need to be displayed in.
+ * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
* TYPE_SEASON, TYPE_BANK or TYPE_OTHER. By default a type of 'other' is considered.
*
- * @return \Yasumi\Holiday
+ * @return Holiday
*
- * @throws \Yasumi\Exception\InvalidDateException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws InvalidDateException
+ * @throws UnknownLocaleException
* @throws \InvalidArgumentException
* @throws \Exception
*/
@@ -241,16 +322,16 @@ public function corpusChristi(
*
* @link https://en.wikipedia.org/wiki/Christmas_Eve
*
- * @param int $year the year for which Christmas Eve needs to be created
+ * @param int $year the year for which Christmas Eve needs to be created
* @param string $timezone the timezone in which Christmas Eve is celebrated
- * @param string $locale the locale for which Christmas Eve need to be displayed in.
- * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
+ * @param string $locale the locale for which Christmas Eve need to be displayed in.
+ * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
* TYPE_SEASON, TYPE_BANK or TYPE_OTHER. By default observance is considered.
*
- * @return \Yasumi\Holiday
+ * @return Holiday
*
- * @throws \Yasumi\Exception\InvalidDateException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws InvalidDateException
+ * @throws UnknownLocaleException
* @throws \InvalidArgumentException
* @throws \Exception
*/
@@ -276,16 +357,16 @@ public function christmasEve(
* commemorating the birth of Jesus Christ, observed most commonly on December 25 as a religious and cultural
* celebration among billions of people around the world.
*
- * @param int $year the year for which Christmas Day need to be created
+ * @param int $year the year for which Christmas Day need to be created
* @param string $timezone the timezone in which Christmas Day is celebrated
- * @param string $locale the locale for which Christmas Day need to be displayed in.
- * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
+ * @param string $locale the locale for which Christmas Day need to be displayed in.
+ * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
* TYPE_SEASON, TYPE_BANK or TYPE_OTHER. By default an official holiday is considered.
*
- * @return \Yasumi\Holiday
+ * @return Holiday
*
- * @throws \Yasumi\Exception\InvalidDateException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws InvalidDateException
+ * @throws UnknownLocaleException
* @throws \InvalidArgumentException
* @throws \Exception
*/
@@ -311,16 +392,16 @@ public function christmasDay(
* commemorating the birth of Jesus Christ, observed most commonly on December 25 as a religious and cultural
* celebration among billions of people around the world.
*
- * @param int $year the year for which the Second Christmas Day / Boxing Day need to be created
+ * @param int $year the year for which the Second Christmas Day / Boxing Day need to be created
* @param string $timezone the timezone in which the Second Christmas Day / Boxing Day is celebrated
- * @param string $locale the locale for which the Second Christmas Day / Boxing Day need to be displayed in.
- * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
+ * @param string $locale the locale for which the Second Christmas Day / Boxing Day need to be displayed in.
+ * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
* TYPE_SEASON, TYPE_BANK or TYPE_OTHER. By default an official holiday is considered.
*
- * @return \Yasumi\Holiday
+ * @return Holiday
*
- * @throws \Yasumi\Exception\InvalidDateException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws InvalidDateException
+ * @throws UnknownLocaleException
* @throws \InvalidArgumentException
* @throws \Exception
*/
@@ -347,18 +428,18 @@ public function secondChristmasDay(
* after Pentecost in Eastern Catholicism and Eastern Orthodoxy, in honour of all the saints, known and unknown.
* The liturgical celebration begins at Vespers on the evening of 31 October and ends at the close of 1 November.
*
- * @link http://en.wikipedia.org/wiki/All_Saints%27_Day
+ * @link https://en.wikipedia.org/wiki/All_Saints%27_Day
*
- * @param int $year the year for which All Saints' Day need to be created
+ * @param int $year the year for which All Saints' Day need to be created
* @param string $timezone the timezone in which All Saints' Day is celebrated
- * @param string $locale the locale for which All Saints' Day need to be displayed in.
- * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
+ * @param string $locale the locale for which All Saints' Day need to be displayed in.
+ * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
* TYPE_SEASON, TYPE_BANK or TYPE_OTHER. By default an official holiday is considered.
*
- * @return \Yasumi\Holiday
+ * @return Holiday
*
- * @throws \Yasumi\Exception\InvalidDateException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws InvalidDateException
+ * @throws UnknownLocaleException
* @throws \InvalidArgumentException
* @throws \Exception
*/
@@ -378,18 +459,18 @@ public function allSaintsDay(
* of the Virgin Mary into Heaven at the end of her earthly life. In the churches that observe it, the
* Assumption is a major feast day, commonly celebrated on August 15.
*
- * @link http://en.wikipedia.org/wiki/Assumption_of_Mary
+ * @link https://en.wikipedia.org/wiki/Assumption_of_Mary
*
- * @param int $year the year for which the day of the Assumption of Mary need to be created
+ * @param int $year the year for which the day of the Assumption of Mary need to be created
* @param string $timezone the timezone in which the day of the Assumption of Mary is celebrated
- * @param string $locale the locale for which the day of the Assumption of Mary need to be displayed in.
- * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
+ * @param string $locale the locale for which the day of the Assumption of Mary need to be displayed in.
+ * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
* TYPE_SEASON, TYPE_BANK or TYPE_OTHER. By default an official holiday is considered.
*
- * @return \Yasumi\Holiday
+ * @return Holiday
*
- * @throws \Yasumi\Exception\InvalidDateException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws InvalidDateException
+ * @throws UnknownLocaleException
* @throws \InvalidArgumentException
* @throws \Exception
*/
@@ -415,16 +496,16 @@ public function assumptionOfMary(
* Calvary. The holiday is observed during Holy Week as part of the Paschal Triduum on the Friday preceding Easter
* Sunday, and may coincide with the Jewish observance of Passover.
*
- * @param int $year the year for which Good Friday need to be created
+ * @param int $year the year for which Good Friday need to be created
* @param string $timezone the timezone in which Good Friday is celebrated
- * @param string $locale the locale for which Good Friday need to be displayed in.
- * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
+ * @param string $locale the locale for which Good Friday need to be displayed in.
+ * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
* TYPE_SEASON, TYPE_BANK or TYPE_OTHER. By default an official holiday is considered.
*
- * @return \Yasumi\Holiday
+ * @return Holiday
*
- * @throws \Yasumi\Exception\InvalidDateException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws InvalidDateException
+ * @throws UnknownLocaleException
* @throws \InvalidArgumentException
* @throws \Exception
*/
@@ -452,18 +533,18 @@ public function goodFriday(
* for most countries is January 19 because of the 13-day difference today between that calendar and the generally
* used Gregorian calendar.
*
- * @link http://en.wikipedia.org/wiki/Epiphany_(holiday)
+ * @link https://en.wikipedia.org/wiki/Epiphany_(holiday)
*
- * @param int $year the year for which Epiphany need to be created
+ * @param int $year the year for which Epiphany need to be created
* @param string $timezone the timezone in which Epiphany is celebrated
- * @param string $locale the locale for which Epiphany need to be displayed in.
- * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
+ * @param string $locale the locale for which Epiphany need to be displayed in.
+ * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
* TYPE_SEASON, TYPE_BANK or TYPE_OTHER. By default an official holiday is considered.
*
- * @return \Yasumi\Holiday
+ * @return Holiday
*
- * @throws \Yasumi\Exception\InvalidDateException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws InvalidDateException
+ * @throws UnknownLocaleException
* @throws \InvalidArgumentException
* @throws \Exception
*/
@@ -483,18 +564,18 @@ public function epiphany(
* days, if the 6 Sundays, which are not days of fast, are excluded) before Easter and can fall as early as 4
* February or as late as 10 March.
*
- * @link http://en.wikipedia.org/wiki/Ash_Wednesday
+ * @link https://en.wikipedia.org/wiki/Ash_Wednesday
*
- * @param int $year the year for which Ash Wednesday need to be created
+ * @param int $year the year for which Ash Wednesday need to be created
* @param string $timezone the timezone in which Ash Wednesday is celebrated
- * @param string $locale the locale for which Ash Wednesday need to be displayed in.
- * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
+ * @param string $locale the locale for which Ash Wednesday need to be displayed in.
+ * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
* TYPE_SEASON, TYPE_BANK or TYPE_OTHER. By default an official holiday is considered.
*
- * @return \Yasumi\Holiday
+ * @return Holiday
*
- * @throws \Yasumi\Exception\InvalidDateException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws InvalidDateException
+ * @throws UnknownLocaleException
* @throws \InvalidArgumentException
* @throws \Exception
*/
@@ -521,18 +602,18 @@ public function ashWednesday(
* which is celebrated on September 8. It is one of the most important Marian feasts celebrated in the liturgical
* calendar of the Roman Catholic Church.
*
- * @link http://en.wikipedia.org/wiki/Feast_of_the_Immaculate_Conception
+ * @link https://en.wikipedia.org/wiki/Feast_of_the_Immaculate_Conception
*
- * @param int $year the year for which Immaculate Conception need to be created
+ * @param int $year the year for which Immaculate Conception need to be created
* @param string $timezone the timezone in which Immaculate Conception is celebrated
- * @param string $locale the locale for which Immaculate Conception need to be displayed in.
- * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
+ * @param string $locale the locale for which Immaculate Conception need to be displayed in.
+ * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
* TYPE_SEASON, TYPE_BANK or TYPE_OTHER. By default an official holiday is considered.
*
- * @return \Yasumi\Holiday
+ * @return Holiday
*
- * @throws \Yasumi\Exception\InvalidDateException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws InvalidDateException
+ * @throws UnknownLocaleException
* @throws \InvalidArgumentException
* @throws \Exception
*/
@@ -560,18 +641,18 @@ public function immaculateConception(
* December according to that calendar, which places it on 8 January of the Gregorian calendar used in secular
* contexts.
*
- * @link http://en.wikipedia.org/wiki/St._Stephen%27s_Day
+ * @link https://en.wikipedia.org/wiki/St._Stephen%27s_Day
*
- * @param int $year the year for which St. Stephen's Day need to be created
+ * @param int $year the year for which St. Stephen's Day need to be created
* @param string $timezone the timezone in which St. Stephen's Day is celebrated
- * @param string $locale the locale for which St. Stephen's Day need to be displayed in.
- * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
+ * @param string $locale the locale for which St. Stephen's Day need to be displayed in.
+ * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
* TYPE_SEASON, TYPE_BANK or TYPE_OTHER. By default an official holiday is considered.
*
- * @return \Yasumi\Holiday
+ * @return Holiday
*
- * @throws \Yasumi\Exception\InvalidDateException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws InvalidDateException
+ * @throws UnknownLocaleException
* @throws \InvalidArgumentException
* @throws \Exception
*/
@@ -599,18 +680,18 @@ public function stStephensDay(
* Pope St. Pius V extended its use to the entire Roman Rite by his Apostolic Constitution Quo primum
* (July 14, 1570). Since 1969, Episcopal Conferences may, if they wish, transfer it to a date outside Lent.
*
- * @link http://en.wikipedia.org/wiki/St_Joseph's_Day
+ * @link https://en.wikipedia.org/wiki/St_Joseph's_Day
*
- * @param int $year the year for which St. Joseph's Day need to be created
+ * @param int $year the year for which St. Joseph's Day need to be created
* @param string $timezone the timezone in which St. Joseph's Day is celebrated
- * @param string $locale the locale for which St. Joseph's Day need to be displayed in.
- * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
+ * @param string $locale the locale for which St. Joseph's Day need to be displayed in.
+ * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
* TYPE_SEASON, TYPE_BANK or TYPE_OTHER. By default an official holiday is considered.
*
- * @return \Yasumi\Holiday
+ * @return Holiday
*
- * @throws \Yasumi\Exception\InvalidDateException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws InvalidDateException
+ * @throws UnknownLocaleException
* @throws \InvalidArgumentException
* @throws \Exception
*/
@@ -631,18 +712,18 @@ public function stJosephsDay(
* Maundy and Last Supper of Jesus Christ with the Apostles as described in the Canonical gospels. It is the fifth
* day of Holy Week, and is preceded by Holy Wednesday and followed by Good Friday.
*
- * @link http://en.wikipedia.org/wiki/Maundy_Thursday
+ * @link https://en.wikipedia.org/wiki/Maundy_Thursday
*
- * @param int $year the year for which Maundy Thursday need to be created
+ * @param int $year the year for which Maundy Thursday need to be created
* @param string $timezone the timezone in which Maundy Thursday is celebrated
- * @param string $locale the locale for which Maundy Thursday need to be displayed in.
- * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
+ * @param string $locale the locale for which Maundy Thursday need to be displayed in.
+ * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
* TYPE_SEASON, TYPE_BANK or TYPE_OTHER. By default an official holiday is considered.
*
- * @return \Yasumi\Holiday
+ * @return Holiday
*
- * @throws \Yasumi\Exception\InvalidDateException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws InvalidDateException
+ * @throws UnknownLocaleException
* @throws \InvalidArgumentException
* @throws \Exception
*/
@@ -669,18 +750,18 @@ public function maundyThursday(
* celebrated on 23 April, the traditionally accepted date of Saint George's death in 303 AD. For Eastern Orthodox
* Churches (which use the Julian calendar), '23 April' currently falls on 6 May of the Gregorian calendar.
*
- * @link http://en.wikipedia.org/wiki/St_George%27s_Day
+ * @link https://en.wikipedia.org/wiki/St_George%27s_Day
*
- * @param int $year the year for which St. George's Day need to be created
+ * @param int $year the year for which St. George's Day need to be created
* @param string $timezone the timezone in which St. George's Day is celebrated
- * @param string $locale the locale for which St. George's Day need to be displayed in.
- * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
+ * @param string $locale the locale for which St. George's Day need to be displayed in.
+ * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
* TYPE_SEASON, TYPE_BANK or TYPE_OTHER. By default an official holiday is considered.
*
- * @return \Yasumi\Holiday
+ * @return Holiday
*
- * @throws \Yasumi\Exception\InvalidDateException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws InvalidDateException
+ * @throws UnknownLocaleException
* @throws \InvalidArgumentException
* @throws \Exception
*/
@@ -704,16 +785,16 @@ public function stGeorgesDay(
*
* @link https://en.wikipedia.org/wiki/Nativity_of_St_John_the_Baptist
*
- * @param int $year the year for which St. John's Day need to be created
+ * @param int $year the year for which St. John's Day need to be created
* @param string $timezone the timezone in which St. John's Day is celebrated
- * @param string $locale the locale for which St. John's Day need to be displayed in.
- * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
+ * @param string $locale the locale for which St. John's Day need to be displayed in.
+ * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
* TYPE_SEASON, TYPE_BANK or TYPE_OTHER. By default an official holiday is considered.
*
- * @return \Yasumi\Holiday
+ * @return Holiday
*
- * @throws \Yasumi\Exception\InvalidDateException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws InvalidDateException
+ * @throws UnknownLocaleException
* @throws \InvalidArgumentException
* @throws \Exception
*/
@@ -737,16 +818,16 @@ public function stJohnsDay(
*
* @link https://en.wikipedia.org/wiki/Annunciation
*
- * @param int $year the year for which the Annunciation needs to be created
+ * @param int $year the year for which the Annunciation needs to be created
* @param string $timezone the timezone in which the Annunciation is celebrated
- * @param string $locale the locale for which the Annunciation need to be displayed in.
- * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
+ * @param string $locale the locale for which the Annunciation need to be displayed in.
+ * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
* TYPE_SEASON, TYPE_BANK or TYPE_OTHER. By default an official holiday is considered.
*
- * @return \Yasumi\Holiday
+ * @return Holiday
*
- * @throws \Yasumi\Exception\InvalidDateException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws InvalidDateException
+ * @throws UnknownLocaleException
* @throws \InvalidArgumentException
* @throws \Exception
*/
@@ -768,24 +849,24 @@ public function annunciation(
/**
* Calculate the Easter date for Orthodox churches.
*
- * @param int $year the year for which Easter needs to be calculated
+ * @param int $year the year for which Easter needs to be calculated
* @param string $timezone the timezone in which Easter is celebrated
*
- * @return \DateTime date of Orthodox Easter
+ * @return DateTime date of Orthodox Easter
*
- * @link http://php.net/manual/en/function.easter-date.php#83794
- * @link https://en.wikipedia.org/wiki/Computus#Adaptation_for_Western_Easter_of_Meeus.27_Julian_algorithm
* @throws \Exception
+ * @link https://en.wikipedia.org/wiki/Computus#Meeus.27s_Julian_algorithm
+ * @link https://www.php.net/manual/en/function.easter-date.php#83794
*/
- public function calculateOrthodoxEaster(int $year, string $timezone): \DateTime
+ public function calculateOrthodoxEaster(int $year, string $timezone): DateTime
{
- $a = $year % 4;
- $b = $year % 7;
- $c = $year % 19;
- $d = (19 * $c + 15) % 30;
- $e = (2 * $a + 4 * $b - $d + 34) % 7;
+ $a = $year % 4;
+ $b = $year % 7;
+ $c = $year % 19;
+ $d = (19 * $c + 15) % 30;
+ $e = (2 * $a + 4 * $b - $d + 34) % 7;
$month = \floor(($d + $e + 114) / 31);
- $day = (($d + $e + 114) % 31) + 1;
+ $day = (($d + $e + 114) % 31) + 1;
return (new DateTime("$year-$month-$day", new DateTimeZone($timezone)))->add(new DateInterval('P13D'));
}
@@ -805,16 +886,16 @@ public function calculateOrthodoxEaster(int $year, string $timezone): \DateTime
* @link https://en.wikipedia.org/wiki/Reformation_Day
* @link https://de.wikipedia.org/wiki/Reformationstag#Ursprung_und_Geschichte
*
- * @param int $year the year for which St. John's Day need to be created
+ * @param int $year the year for which St. John's Day need to be created
* @param string $timezone the timezone in which St. John's Day is celebrated
- * @param string $locale the locale for which St. John's Day need to be displayed in.
- * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
+ * @param string $locale the locale for which St. John's Day need to be displayed in.
+ * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
* TYPE_SEASON, TYPE_BANK or TYPE_OTHER. By default an official holiday is considered.
*
- * @return \Yasumi\Holiday
+ * @return Holiday
*
- * @throws \Yasumi\Exception\InvalidDateException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws InvalidDateException
+ * @throws UnknownLocaleException
* @throws \InvalidArgumentException
* @throws \Exception
*/
@@ -832,83 +913,4 @@ public function reformationDay(
$type
);
}
-
- /**
- * Calculates the date for Easter.
- *
- * Easter is a festival and holiday celebrating the resurrection of Jesus Christ from the dead. Easter is celebrated
- * on a date based on a certain number of days after March 21st.
- *
- * This function uses the standard PHP 'easter_days' function if the calendar extension is enabled. In case the
- * calendar function is not enabled, a fallback calculation has been implemented that is based on the same
- * 'easter_days' c function.
- *
- * Note: In calendrical calculations, frequently operations called integer division are used.
- *
- * @see easter_days
- *
- * @link https://github.com/php/php-src/blob/c8aa6f3a9a3d2c114d0c5e0c9fdd0a465dbb54a5/ext/calendar/easter.c
- * @link http://www.gmarts.org/index.php?go=415#EasterMallen
- * @link http://www.tondering.dk/claus/cal/easter.php
- *
- * @param int $year the year for which Easter needs to be calculated
- * @param string $timezone the timezone in which Easter is celebrated
- *
- * @return \DateTime date of Easter
- * @throws \Exception
- */
- protected function calculateEaster(int $year, string $timezone): DateTime
- {
- if (\extension_loaded('calendar')) {
- $easter_days = \easter_days($year);
- } else {
- $golden = ($year % 19) + 1; // The Golden Number
-
- // The Julian calendar applies to the original method from 326AD. The Gregorian calendar was first
- // introduced in October 1582 in Italy. Easter algorithms using the Gregorian calendar apply to years
- // 1583 AD to 4099 (A day adjustment is required in or shortly after 4100 AD).
- // After 1752, most western churches have adopted the current algorithm.
- if ($year <= 1752) {
- $dom = ($year + (int)($year / 4) + 5) % 7; // The 'Dominical number' - finding a Sunday
- if ($dom < 0) {
- $dom += 7;
- }
-
- $pfm = (3 - (11 * $golden) - 7) % 30; // Uncorrected date of the Paschal full moon
- if ($pfm < 0) {
- $pfm += 30;
- }
- } else {
- $dom = ($year + (int)($year / 4) - (int)($year / 100) + (int)($year / 400)) % 7; // The 'Dominical number' - finding a Sunday
- if ($dom < 0) {
- $dom += 7;
- }
-
- $solar = (int)(($year - 1600) / 100) - (int)(($year - 1600) / 400); // The solar correction
- $lunar = (int)(((int)(($year - 1400) / 100) * 8) / 25); // The lunar correction
-
- $pfm = (3 - (11 * $golden) + $solar - $lunar) % 30; // Uncorrected date of the Paschal full moon
- if ($pfm < 0) {
- $pfm += 30;
- }
- }
-
- // Corrected date of the Paschal full moon, - days after 21st March
- if (($pfm === 29) || ($pfm === 28 && $golden > 11)) {
- --$pfm;
- }
-
- $tmp = (4 - $pfm - $dom) % 7;
- if ($tmp < 0) {
- $tmp += 7;
- }
-
- $easter_days = $pfm + $tmp + 1; // Easter as the number of days after 21st March
- }
-
- $easter = new DateTime("$year-3-21", new DateTimeZone($timezone));
- $easter->add(new DateInterval('P' . $easter_days . 'D'));
-
- return $easter;
- }
}
diff --git a/src/Yasumi/Provider/CommonHolidays.php b/src/Yasumi/Provider/CommonHolidays.php
index 7c6c62d67..a5481722e 100644
--- a/src/Yasumi/Provider/CommonHolidays.php
+++ b/src/Yasumi/Provider/CommonHolidays.php
@@ -1,4 +1,4 @@
-calculateSummerWinterTime($year, $timezone, true);
+
+ if ($date) {
+ return new Holiday(
+ 'summerTime',
+ [],
+ $date,
+ $locale,
+ $type ?? Holiday::TYPE_SEASON
+ );
+ }
+
+ return null;
+ }
+
/**
* Calculates daylight saving time transitions.
*
@@ -445,11 +481,11 @@ public function internationalWomensDay(
* On the northern hemisphere, summer time starts around March/April. On the southern hemisphere it happens 6
* months later.
*
- * @param int $year the year for which Easter needs to be calculated
+ * @param int $year the year for which Easter needs to be calculated
* @param string $timezone the timezone in which Easter is celebrated
- * @param bool $summer whether to calculate the start of summer or winter time
+ * @param bool $summer whether to calculate the start of summer or winter time
*
- * @return \DateTime|null A DateTime object representing the summer or winter transition time for the given
+ * @return DateTime|null A DateTime object representing the summer or winter transition time for the given
* timezone. If no transition time is found, a null value is returned.
* @throws \Exception
*/
@@ -472,58 +508,24 @@ protected function calculateSummerWinterTime($year, $timezone, $summer): ?DateTi
return null;
}
- /**
- * The beginning of summer time.
- *
- * Summer time is also known as daylight save time.
- *
- * @param int $year the year for which summer time need to be created
- * @param string $timezone the timezone in which summer time transition occurs
- * @param string $locale the locale for which summer time need to be displayed in.
- * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
- * TYPE_SEASON, TYPE_BANK or TYPE_OTHER. By default an official holiday is considered.
- *
- * @return \Yasumi\Holiday|null
- *
- * @throws \Yasumi\Exception\UnknownLocaleException
- * @throws \InvalidArgumentException
- * @throws \Exception
- */
- public function summerTime($year, $timezone, $locale, $type = Holiday::TYPE_SEASON): ?Holiday
- {
- $date = $this->calculateSummerWinterTime($year, $timezone, true);
-
- if ($date) {
- return new Holiday(
- 'summerTime',
- [],
- $date,
- $locale,
- $type
- );
- }
-
- return null;
- }
-
/**
* The beginning of winter time.
*
* Winter time is also known as standard time.
*
- * @param int $year the year for which summer time need to be created
+ * @param int $year the year for which summer time need to be created
* @param string $timezone the timezone in which summer time transition occurs
- * @param string $locale the locale for which summer time need to be displayed in.
- * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
+ * @param string $locale the locale for which summer time need to be displayed in.
+ * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL, TYPE_OBSERVANCE,
* TYPE_SEASON, TYPE_BANK or TYPE_OTHER. By default an official holiday is considered.
*
- * @return \Yasumi\Holiday|null
+ * @return Holiday|null
*
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \InvalidArgumentException
* @throws \Exception
*/
- public function winterTime($year, $timezone, $locale, $type = Holiday::TYPE_SEASON): ?Holiday
+ public function winterTime($year, $timezone, $locale, $type = null): ?Holiday
{
$date = $this->calculateSummerWinterTime($year, $timezone, false);
@@ -533,7 +535,7 @@ public function winterTime($year, $timezone, $locale, $type = Holiday::TYPE_SEAS
[],
$date,
$locale,
- $type
+ $type ?? Holiday::TYPE_SEASON
);
}
diff --git a/src/Yasumi/Provider/Croatia.php b/src/Yasumi/Provider/Croatia.php
index 33fe4b984..c59ae4f2e 100644
--- a/src/Yasumi/Provider/Croatia.php
+++ b/src/Yasumi/Provider/Croatia.php
@@ -1,4 +1,4 @@
-year >= 1941) {
$this->addHoliday(new Holiday('antifascistStruggleDay', [
- 'en_US' => 'Day of Antifascist Struggle',
- 'hr_HR' => 'Dan antifašističke borbe'
+ 'en' => 'Day of Antifascist Struggle',
+ 'hr' => 'Dan antifašističke borbe',
], new DateTime("$this->year-6-22", new DateTimeZone($this->timezone)), $this->locale));
}
@@ -72,8 +74,8 @@ public function initialize(): void
*/
if ($this->year >= 1991) {
$this->addHoliday(new Holiday('statehoodDay', [
- 'en_US' => 'Statehood Day',
- 'hr_HR' => 'Dan državnosti'
+ 'en' => 'Statehood Day',
+ 'hr' => 'Dan državnosti',
], new DateTime("$this->year-6-25", new DateTimeZone($this->timezone)), $this->locale));
}
@@ -82,8 +84,8 @@ public function initialize(): void
*/
if ($this->year >= 1995) {
$this->addHoliday(new Holiday('homelandThanksgiving', [
- 'en_US' => 'Homeland Thanksgiving Day',
- 'hr_HR' => 'Dan domovinske zahvalnosti'
+ 'en' => 'Homeland Thanksgiving Day',
+ 'hr' => 'Dan domovinske zahvalnosti',
], new DateTime("$this->year-8-5", new DateTimeZone($this->timezone)), $this->locale));
}
@@ -92,8 +94,8 @@ public function initialize(): void
*/
if ($this->year >= 1991) {
$this->addHoliday(new Holiday('independenceDay', [
- 'en_US' => 'Independence Day',
- 'hr_HR' => 'Dan neovisnosti'
+ 'en' => 'Independence Day',
+ 'hr' => 'Dan neovisnosti',
], new DateTime("$this->year-10-8", new DateTimeZone($this->timezone)), $this->locale));
}
}
diff --git a/src/Yasumi/Provider/CzechRepublic.php b/src/Yasumi/Provider/CzechRepublic.php
index 40c489242..2e01b3b91 100644
--- a/src/Yasumi/Provider/CzechRepublic.php
+++ b/src/Yasumi/Provider/CzechRepublic.php
@@ -1,4 +1,4 @@
-timezone = 'Europe/Prague';
$this->addHoliday($this->newYearsDay($this->year, $this->timezone, $this->locale));
+ $this->calculateRenewalOfCzechIndependenceDay();
$this->addHoliday($this->goodFriday($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->easterMonday($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->internationalWorkersDay($this->year, $this->timezone, $this->locale));
@@ -59,6 +62,29 @@ public function initialize(): void
$this->addHoliday($this->secondChristmasDay($this->year, $this->timezone, $this->locale));
}
+ /**
+ * Day of renewal of independent Czech state
+ *
+ * @see https://en.wikipedia.org/wiki/Public_holidays_in_the_Czech_Republic
+ *
+ * @throws InvalidDateException
+ * @throws \InvalidArgumentException
+ * @throws UnknownLocaleException
+ * @throws \Exception
+ */
+ private function calculateRenewalOfCzechIndependenceDay(): void
+ {
+ $this->addHoliday(new Holiday(
+ 'czechRenewalOfIndependentStateDay',
+ [
+ 'cs' => 'Den obnovy samostatného českého státu',
+ 'en' => 'Day of renewal of the independent Czech state',
+ ],
+ new DateTime($this->year . '-01-01', new \DateTimeZone($this->timezone)),
+ $this->locale
+ ));
+ }
+
/**
* Saints Cyril and Methodius Day
*
@@ -75,16 +101,19 @@ public function initialize(): void
* @see https://en.wikipedia.org/wiki/Saints_Cyril_and_Methodius
* @see https://en.wikipedia.org/wiki/Public_holidays_in_the_Czech_Republic
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateSaintsCyrilAndMethodiusDay(): void
+ private function calculateSaintsCyrilAndMethodiusDay(): void
{
$this->addHoliday(new Holiday(
'saintsCyrilAndMethodiusDay',
- ['cs_CZ' => 'Den slovanských věrozvěstů Cyrila a Metoděje', 'en_US' => 'Saints Cyril and Methodius Day'],
+ [
+ 'cs' => 'Den slovanských věrozvěstů Cyrila a Metoděje',
+ 'en' => 'Saints Cyril and Methodius Day',
+ ],
new DateTime($this->year . '-07-5', new \DateTimeZone($this->timezone)),
$this->locale
));
@@ -100,16 +129,16 @@ public function calculateSaintsCyrilAndMethodiusDay(): void
* @see https://en.wikipedia.org/wiki/Jan_Hus
* @see https://en.wikipedia.org/wiki/Public_holidays_in_the_Czech_Republic
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateJanHusDay(): void
+ private function calculateJanHusDay(): void
{
$this->addHoliday(new Holiday(
'janHusDay',
- ['cs_CZ' => 'Den upálení mistra Jana Husa', 'en_US' => 'Jan Hus Day'],
+ ['cs' => 'Den upálení mistra Jana Husa', 'en' => 'Jan Hus Day'],
new DateTime($this->year . '-07-6', new \DateTimeZone($this->timezone)),
$this->locale
));
@@ -128,16 +157,19 @@ public function calculateJanHusDay(): void
* @see https://en.wikipedia.org/wiki/Wenceslaus_I,_Duke_of_Bohemia
* @see https://en.wikipedia.org/wiki/Public_holidays_in_the_Czech_Republic
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateCzechStatehoodDay(): void
+ private function calculateCzechStatehoodDay(): void
{
$this->addHoliday(new Holiday(
'czechStateHoodDay',
- ['cs_CZ' => 'Den české státnosti', 'en_US' => 'St. Wenceslas Day (Czech Statehood Day)'],
+ [
+ 'cs' => 'Den české státnosti',
+ 'en' => 'St. Wenceslas Day (Czech Statehood Day)',
+ ],
new DateTime($this->year . '-09-28', new \DateTimeZone($this->timezone)),
$this->locale
));
@@ -148,16 +180,16 @@ public function calculateCzechStatehoodDay(): void
*
* @see https://en.wikipedia.org/wiki/Public_holidays_in_the_Czech_Republic
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateIndependentCzechoslovakStateDay(): void
+ private function calculateIndependentCzechoslovakStateDay(): void
{
$this->addHoliday(new Holiday('independentCzechoslovakStateDay', [
- 'cs_CZ' => 'Den vzniku samostatného československého státu',
- 'en_US' => 'Independent Czechoslovak State Day'
+ 'cs' => 'Den vzniku samostatného československého státu',
+ 'en' => 'Independent Czechoslovak State Day',
], new DateTime($this->year . '-10-28', new \DateTimeZone($this->timezone)), $this->locale));
}
@@ -166,16 +198,19 @@ public function calculateIndependentCzechoslovakStateDay(): void
*
* @see https://en.wikipedia.org/wiki/Public_holidays_in_the_Czech_Republic
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateStruggleForFreedomAndDemocracyDay(): void
+ private function calculateStruggleForFreedomAndDemocracyDay(): void
{
$this->addHoliday(new Holiday(
'struggleForFreedomAndDemocracyDay',
- ['cs_CZ' => 'Den boje za svobodu a demokracii', 'en_US' => 'Struggle for Freedom and Democracy Day'],
+ [
+ 'cs' => 'Den boje za svobodu a demokracii',
+ 'en' => 'Struggle for Freedom and Democracy Day',
+ ],
new DateTime($this->year . '-11-17', new \DateTimeZone($this->timezone)),
$this->locale
));
diff --git a/src/Yasumi/Provider/Denmark.php b/src/Yasumi/Provider/Denmark.php
index c1146fbcc..689b21deb 100644
--- a/src/Yasumi/Provider/Denmark.php
+++ b/src/Yasumi/Provider/Denmark.php
@@ -1,4 +1,4 @@
-calculateConstitutionDay();
$summerTime = $this->summerTime($this->year, $this->timezone, $this->locale);
- if ($summerTime !== null) {
+ if ($summerTime instanceof Holiday) {
$this->addHoliday($summerTime);
}
$winterTime = $this->winterTime($this->year, $this->timezone, $this->locale);
- if ($winterTime !== null) {
+ if ($winterTime instanceof Holiday) {
$this->addHoliday($winterTime);
}
}
@@ -83,19 +85,19 @@ public function initialize(): void
*
* @link https://en.wikipedia.org/wiki/Store_Bededag
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateGreatPrayerDay(): void
+ private function calculateGreatPrayerDay(): void
{
$easter = $this->calculateEaster($this->year, $this->timezone)->format('Y-m-d');
if ($this->year >= 1686) {
$this->addHoliday(new Holiday(
'greatPrayerDay',
- ['da_DK' => 'Store bededag'],
+ ['da' => 'Store bededag'],
new DateTime("fourth friday $easter", new DateTimeZone($this->timezone)),
$this->locale
));
@@ -113,17 +115,17 @@ public function calculateGreatPrayerDay(): void
*
* @link https://en.wikipedia.org/wiki/Constitution_Day_(Denmark)
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateConstitutionDay(): void
+ private function calculateConstitutionDay(): void
{
if ($this->year >= 1849) {
$this->addHoliday(new Holiday(
'constitutionDay',
- ['da_DK' => 'Grundlovsdag'],
+ ['da' => 'Grundlovsdag'],
new DateTime("$this->year-6-5", new DateTimeZone($this->timezone)),
$this->locale,
Holiday::TYPE_OBSERVANCE
diff --git a/src/Yasumi/Provider/Estonia.php b/src/Yasumi/Provider/Estonia.php
index 5fab5188d..3a51713c7 100644
--- a/src/Yasumi/Provider/Estonia.php
+++ b/src/Yasumi/Provider/Estonia.php
@@ -1,4 +1,4 @@
-year >= self::DECLARATION_OF_INDEPENDENCE_YEAR) {
$this->addHoliday(new Holiday('independenceDay', [
- 'en_US' => 'Independence Day',
- 'et_EE' => 'Iseseisvuspäev'
+ 'en' => 'Independence Day',
+ 'et' => 'Iseseisvuspäev',
], new \DateTime("{$this->year}-02-24", new \DateTimeZone($this->timezone))));
}
}
@@ -83,8 +83,8 @@ private function addVictoryDay(): void
{
if ($this->year >= self::VICTORY_DAY_START_YEAR) {
$this->addHoliday(new Holiday('victoryDay', [
- 'en_US' => 'Victory Day',
- 'et_EE' => 'Võidupüha'
+ 'en' => 'Victory Day',
+ 'et' => 'Võidupüha',
], new \DateTime("{$this->year}-06-23", new \DateTimeZone($this->timezone))));
}
}
@@ -97,8 +97,8 @@ private function addRestorationOfIndependenceDay(): void
{
if ($this->year >= self::RESTORATION_OF_INDEPENDENCE_YEAR) {
$this->addHoliday(new Holiday('restorationOfIndependenceDay', [
- 'en_US' => 'Day of Restoration of Independence',
- 'et_EE' => 'Tasiseseisvumispäev'
+ 'en' => 'Day of Restoration of Independence',
+ 'et' => 'Tasiseseisvumispäev',
], new \DateTime("{$this->year}-08-20", new \DateTimeZone($this->timezone))));
}
}
diff --git a/src/Yasumi/Provider/Finland.php b/src/Yasumi/Provider/Finland.php
index 4ecaa0b84..00f861a9c 100644
--- a/src/Yasumi/Provider/Finland.php
+++ b/src/Yasumi/Provider/Finland.php
@@ -1,4 +1,4 @@
- 'Juhannuspäivä'];
- $shortName = 'stJohnsDay';
- $date = new DateTime("$this->year-6-24", new DateTimeZone($this->timezone)); // Default date
-
- if ($this->year < 1955) {
- $this->addHoliday(new Holiday($shortName, $translation, $date, $this->locale));
- } else {
-
- // Check between the 20th and 26th day which one is a Saturday
- for ($d = 20; $d <= 26; ++$d) {
- $date->setDate($this->year, 6, $d);
- if ($date->format('l') === 'Saturday') {
- break;
- }
- }
-
- $this->addHoliday(new Holiday($shortName, $translation, $date, $this->locale));
- }
+ $stJohnsDay = ($this->year < 1955) ? "$this->year-6-24" : "$this->year-6-20 this saturday";
+
+ $this->addHoliday(new Holiday(
+ 'stJohnsDay',
+ [],
+ new DateTime($stJohnsDay, new DateTimeZone($this->timezone)),
+ $this->locale
+ ));
}
/**
@@ -121,24 +112,19 @@ public function calculateStJohnsDay(): void
* @link https://en.wikipedia.org/wiki/All_Saints%27_Day
* @link https://fi.wikipedia.org/wiki/Pyh%C3%A4inp%C3%A4iv%C3%A4
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
private function calculateAllSaintsDay(): void
{
- $date = new DateTime("$this->year-10-31", new DateTimeZone($this->timezone));
-
- // Check between 31 October and 6th of November the day that is a Saturday
- for ($d = 0; $d <= 7; ++$d) {
- if ($date->format('l') === 'Saturday') {
- break;
- }
- $date->add(new DateInterval('P1D'));
- }
-
- $this->addHoliday(new Holiday('allSaintsDay', [], $date, $this->locale));
+ $this->addHoliday(new Holiday(
+ 'allSaintsDay',
+ [],
+ new DateTime("$this->year-10-31 this saturday", new DateTimeZone($this->timezone)),
+ $this->locale
+ ));
}
/**
@@ -154,17 +140,17 @@ private function calculateAllSaintsDay(): void
*
* @link https://en.wikipedia.org/wiki/Independence_Day_(Finland)
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateIndependenceDay(): void
+ private function calculateIndependenceDay(): void
{
if ($this->year >= 1917) {
$this->addHoliday(new Holiday(
'independenceDay',
- ['fi_FI' => 'Itsenäisyyspäivä'],
+ ['fi' => 'Itsenäisyyspäivä'],
new DateTime("$this->year-12-6", new DateTimeZone($this->timezone)),
$this->locale
));
diff --git a/src/Yasumi/Provider/France.php b/src/Yasumi/Provider/France.php
index ed3603238..b6668b6a9 100755
--- a/src/Yasumi/Provider/France.php
+++ b/src/Yasumi/Provider/France.php
@@ -1,4 +1,4 @@
-year >= 1790) {
$this->addHoliday(new Holiday('bastilleDay', [
- 'en_US' => 'Bastille Day',
- 'fr_FR' => 'La Fête nationale',
+ 'en' => 'Bastille Day',
+ 'fr' => 'La Fête nationale',
], new DateTime("$this->year-7-14", new DateTimeZone($this->timezone)), $this->locale));
}
}
diff --git a/src/Yasumi/Provider/France/BasRhin.php b/src/Yasumi/Provider/France/BasRhin.php
index 4642c5281..bd4fbb1a7 100755
--- a/src/Yasumi/Provider/France/BasRhin.php
+++ b/src/Yasumi/Provider/France/BasRhin.php
@@ -1,4 +1,4 @@
-addHoliday($this->easterMonday($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->goodFriday($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->internationalWorkersDay($this->year, $this->timezone, $this->locale));
- $this->addHoliday($this->newYearsDay($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->pentecostMonday($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->secondChristmasDay($this->year, $this->timezone, $this->locale));
@@ -58,7 +59,7 @@ public function initialize(): void
$this->calculateGermanUnityDay();
// Note: all German states have agreed this to be a nationwide holiday in 2017 to celebrate the 500th anniversary.
- if ($this->year === 2017) {
+ if (2017 === $this->year) {
$this->addHoliday($this->reformationDay($this->year, $this->timezone, $this->locale));
}
}
@@ -75,17 +76,17 @@ public function initialize(): void
*
* @link https://en.wikipedia.org/wiki/German_Unity_Day
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateGermanUnityDay(): void
+ private function calculateGermanUnityDay(): void
{
if ($this->year >= 1990) {
$this->addHoliday(new Holiday(
'germanUnityDay',
- ['de_DE' => 'Tag der Deutschen Einheit'],
+ ['de' => 'Tag der Deutschen Einheit'],
new DateTime($this->year . '-10-3', new \DateTimeZone($this->timezone)),
$this->locale
));
diff --git a/src/Yasumi/Provider/Germany/BadenWurttemberg.php b/src/Yasumi/Provider/Germany/BadenWurttemberg.php
index 593ee50fc..288b6d7f4 100755
--- a/src/Yasumi/Provider/Germany/BadenWurttemberg.php
+++ b/src/Yasumi/Provider/Germany/BadenWurttemberg.php
@@ -1,4 +1,4 @@
-year >= 1995) {
$this->addHoliday(new Holiday(
'repentanceAndPrayerDay',
- ['de_DE' => 'Buß- und Bettag'],
+ ['de' => 'Buß- und Bettag'],
new DateTime("next wednesday $this->year-11-15", new DateTimeZone($this->timezone)),
$this->locale,
Holiday::TYPE_OFFICIAL
diff --git a/src/Yasumi/Provider/Germany/SaxonyAnhalt.php b/src/Yasumi/Provider/Germany/SaxonyAnhalt.php
index b946c5bae..5df91305a 100755
--- a/src/Yasumi/Provider/Germany/SaxonyAnhalt.php
+++ b/src/Yasumi/Provider/Germany/SaxonyAnhalt.php
@@ -1,4 +1,4 @@
-addHoliday(new Holiday(
'threeHolyHierarchs',
- ['el_GR' => 'Τριών Ιεραρχών'],
+ ['el' => 'Τριών Ιεραρχών'],
new DateTime("$this->year-1-30", new DateTimeZone($this->timezone)),
$this->locale,
Holiday::TYPE_OTHER
@@ -99,16 +101,16 @@ public function calculateThreeHolyHierarchs(): void
*
* @see https://en.wikipedia.org/wiki/Clean_Monday
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateCleanMonday(): void
+ private function calculateCleanMonday(): void
{
$this->addHoliday(new Holiday(
'cleanMonday',
- ['el_GR' => 'Καθαρά Δευτέρα'],
+ ['el' => 'Καθαρά Δευτέρα'],
$this->calculateEaster($this->year, $this->timezone)->sub(new DateInterval('P48D')),
$this->locale
));
@@ -117,14 +119,14 @@ public function calculateCleanMonday(): void
/**
* Orthodox Easter
*
- * @param int $year
+ * @param int $year
* @param string $timezone
*
- * @return \DateTime
+ * @return DateTime
*
* @throws \Exception
*/
- public function calculateEaster($year, $timezone): DateTime
+ private function calculateEaster($year, $timezone): DateTime
{
return $this->calculateOrthodoxEaster($year, $timezone);
}
@@ -136,18 +138,18 @@ public function calculateEaster($year, $timezone): DateTime
*
* @link https://en.wikipedia.org/wiki/Greek_War_of_Independence
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateIndependenceDay(): void
+ private function calculateIndependenceDay(): void
{
if ($this->year >= 1821) {
$this->addHoliday(new Holiday(
'independenceDay',
- ['el_GR' => 'Εικοστή Πέμπτη Μαρτίου'],
+ ['el' => 'Εικοστή Πέμπτη Μαρτίου'],
new DateTime("$this->year-3-25", new DateTimeZone($this->timezone)),
$this->locale
));
@@ -161,17 +163,17 @@ public function calculateIndependenceDay(): void
*
* @link https://en.wikipedia.org/wiki/Ohi_Day
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateOhiDay(): void
+ private function calculateOhiDay(): void
{
if ($this->year >= 1940) {
$this->addHoliday(new Holiday(
'ohiDay',
- ['el_GR' => 'Επέτειος του Όχι'],
+ ['el' => 'Επέτειος του Όχι'],
new DateTime("$this->year-10-28", new DateTimeZone($this->timezone)),
$this->locale
));
@@ -185,17 +187,17 @@ public function calculateOhiDay(): void
*
* @link https://en.wikipedia.org/wiki/Athens_Polytechnic_uprising
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculatePolytechnio(): void
+ private function calculatePolytechnio(): void
{
if ($this->year >= 1973) {
$this->addHoliday(new Holiday(
'polytechnio',
- ['el_GR' => 'Πολυτεχνείο'],
+ ['el' => 'Πολυτεχνείο'],
new DateTime("$this->year-11-17", new DateTimeZone($this->timezone)),
$this->locale,
Holiday::TYPE_OTHER
diff --git a/src/Yasumi/Provider/Hungary.php b/src/Yasumi/Provider/Hungary.php
index 13bffbcee..73c36cc53 100644
--- a/src/Yasumi/Provider/Hungary.php
+++ b/src/Yasumi/Provider/Hungary.php
@@ -1,4 +1,4 @@
-year >= 1927) {
$this->addHoliday(new Holiday('memorialDay1848', [
- 'en_US' => 'Memorial day of the 1848 Revolution',
- 'hu_HU' => 'Az 1848-as forradalom ünnepe',
+ 'en' => 'Memorial day of the 1848 Revolution',
+ 'hu' => 'Az 1848-as forradalom ünnepe',
], new DateTime("$this->year-3-15", new DateTimeZone($this->timezone)), $this->locale));
}
@@ -74,8 +76,8 @@ public function initialize(): void
*/
if ($this->year >= 1891) {
$this->addHoliday(new Holiday('stateFoundation', [
- 'en_US' => 'State Foundation Day',
- 'hu_HU' => 'Az államalapítás ünnepe',
+ 'en' => 'State Foundation Day',
+ 'hu' => 'Az államalapítás ünnepe',
], new DateTime("$this->year-8-20", new DateTimeZone($this->timezone)), $this->locale));
}
@@ -84,8 +86,8 @@ public function initialize(): void
*/
if ($this->year >= 1991) {
$this->addHoliday(new Holiday('memorialDay1956', [
- 'en_US' => 'Memorial day of the 1956 Revolution',
- 'hu_HU' => 'Az 1956-os forradalom ünnepe',
+ 'en' => 'Memorial day of the 1956 Revolution',
+ 'hu' => 'Az 1956-os forradalom ünnepe',
], new DateTime("$this->year-10-23", new DateTimeZone($this->timezone)), $this->locale));
}
}
diff --git a/src/Yasumi/Provider/Ireland.php b/src/Yasumi/Provider/Ireland.php
index 739a64e8f..0fd211222 100644
--- a/src/Yasumi/Provider/Ireland.php
+++ b/src/Yasumi/Provider/Ireland.php
@@ -1,4 +1,4 @@
-calculateJuneHoliday();
$this->addHoliday(new Holiday(
'augustHoliday',
- ['en_IE' => 'August Holiday', 'ga_IE' => 'Lá Saoire i mí Lúnasa'],
+ ['en' => 'August Holiday', 'ga' => 'Lá Saoire i mí Lúnasa'],
new DateTime("next monday $this->year-7-31", new DateTimeZone($this->timezone)),
$this->locale
));
@@ -79,19 +82,19 @@ public function initialize(): void
* Ireland. It became a public holiday following the Holidays (Employees) Act 1973. The public holiday was first
* observed in 1974.
*
- * @link http://www.timeanddate.com/holidays/ireland/new-year-day
+ * @link https://www.timeanddate.com/holidays/ireland/new-year-day
* @link http://www.irishstatutebook.ie/eli/1974/si/341
*
* @TODO : Check substitution of New Years Day when it falls on a Saturday. The Holidays (Employees) Act 1973
* states that New Years Day is substituted the *next* day if it does not fall on a weekday. So what if it
* falls on a Saturday?
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateNewYearsDay(): void
+ private function calculateNewYearsDay(): void
{
if ($this->year < 1974) {
return;
@@ -102,12 +105,15 @@ public function calculateNewYearsDay(): void
// Substitute holiday is on the next available weekday if a holiday falls on a Sunday.
if (0 === (int)$holiday->format('w')) {
- $substituteHoliday = clone $holiday;
- $substituteHoliday->modify('next monday');
-
- $this->addHoliday(new Holiday('substituteHoliday:' . $substituteHoliday->shortName, [
- 'en_IE' => $substituteHoliday->getName() . ' observed',
- ], $substituteHoliday, $this->locale));
+ $date = clone $holiday;
+ $date->modify('next monday');
+
+ $this->addHoliday(new SubstituteHoliday(
+ $holiday,
+ [],
+ $date,
+ $this->locale
+ ));
}
}
@@ -119,12 +125,12 @@ public function calculateNewYearsDay(): void
* @link http://www.irishstatutebook.ie/eli/1939/act/1/section/8/enacted/en/html
* @link http://www.irishstatutebook.ie/eli/1973/act/25/schedule/1/enacted/en/html#sched1
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculatePentecostMonday(): void
+ private function calculatePentecostMonday(): void
{
if ($this->year > 1973) {
return;
@@ -141,17 +147,17 @@ public function calculatePentecostMonday(): void
*
* @link http://www.irishstatutebook.ie/eli/1973/act/25/schedule/1/enacted/en/html#sched1
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
* @throws \Exception
*/
- public function calculateChristmasDay(): void
+ private function calculateChristmasDay(): void
{
$holiday = new Holiday(
'christmasDay',
- ['en_IE' => 'Christmas Day', 'ga_IE' => 'Lá Nollag'],
+ ['en' => 'Christmas Day', 'ga' => 'Lá Nollag'],
new DateTime($this->year . '-12-25', new DateTimeZone($this->timezone)),
$this->locale
);
@@ -160,12 +166,15 @@ public function calculateChristmasDay(): void
// Whenever Christmas Day does not fall on a weekday, the Tuesday following on it shall be a public holiday.
if (\in_array((int)$holiday->format('w'), [0, 6], true)) {
- $substituteHoliday = clone $holiday;
- $substituteHoliday->modify('next tuesday');
-
- $this->addHoliday(new Holiday('substituteHoliday:' . $substituteHoliday->shortName, [
- 'en_IE' => $substituteHoliday->getName() . ' observed',
- ], $substituteHoliday, $this->locale));
+ $date = clone $holiday;
+ $date->modify('next tuesday');
+
+ $this->addHoliday(new SubstituteHoliday(
+ $holiday,
+ [],
+ $date,
+ $this->locale
+ ));
}
}
@@ -178,13 +187,13 @@ public function calculateChristmasDay(): void
* @link https://en.wikipedia.org/wiki/St._Stephen%27s_Day
* @see ChristianHolidays
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
* @throws \Exception
*/
- public function calculateStStephensDay(): void
+ private function calculateStStephensDay(): void
{
$holiday = new Holiday(
'stStephensDay',
@@ -197,12 +206,15 @@ public function calculateStStephensDay(): void
// Whenever St. Stephens Day does not fall on a weekday, the Monday following on it shall be a public holiday.
if (\in_array((int)$holiday->format('w'), [0, 6], true)) {
- $substituteHoliday = clone $holiday;
- $substituteHoliday->modify('next monday');
-
- $this->addHoliday(new Holiday('substituteHoliday:' . $substituteHoliday->shortName, [
- 'en_IE' => $substituteHoliday->getName() . ' observed',
- ], $substituteHoliday, $this->locale));
+ $date = clone $holiday;
+ $date->modify('next monday');
+
+ $this->addHoliday(new SubstituteHoliday(
+ $holiday,
+ [],
+ $date,
+ $this->locale
+ ));
}
}
@@ -217,20 +229,20 @@ public function calculateStStephensDay(): void
*
* @link https://en.wikipedia.org/wiki/Saint_Patrick%27s_Day
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
* @throws \Exception
*/
- public function calculateStPatricksDay(): void
+ private function calculateStPatricksDay(): void
{
if ($this->year < 1903) {
return;
}
$holiday = new Holiday(
'stPatricksDay',
- ['en_IE' => 'St. Patrick\'s Day', 'ga_IE' => 'Lá Fhéile Pádraig'],
+ ['en' => 'St. Patrick\'s Day', 'ga' => 'Lá Fhéile Pádraig'],
new DateTime($this->year . '-3-17', new DateTimeZone($this->timezone)),
$this->locale
);
@@ -239,12 +251,15 @@ public function calculateStPatricksDay(): void
// Substitute holiday is on the next available weekday if a holiday falls on a Saturday or Sunday
if (\in_array((int)$holiday->format('w'), [0, 6], true)) {
- $substituteHoliday = clone $holiday;
- $substituteHoliday->modify('next monday');
-
- $this->addHoliday(new Holiday('substituteHoliday:' . $substituteHoliday->shortName, [
- 'en_IE' => $substituteHoliday->getName() . ' observed',
- ], $substituteHoliday, $this->locale));
+ $date = clone $holiday;
+ $date->modify('next monday');
+
+ $this->addHoliday(new SubstituteHoliday(
+ $holiday,
+ [],
+ $date,
+ $this->locale
+ ));
}
}
@@ -259,13 +274,13 @@ public function calculateStPatricksDay(): void
*
* @link https://en.wikipedia.org/wiki/May_Day
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
* @throws \Exception
*/
- public function calculateMayDay(): void
+ private function calculateMayDay(): void
{
if ($this->year < 1994) {
return;
@@ -273,7 +288,7 @@ public function calculateMayDay(): void
$this->addHoliday(new Holiday(
'mayDay',
- ['en_IE' => 'May Day', 'ga_IE' => 'Lá Bealtaine'],
+ ['en' => 'May Day', 'ga' => 'Lá Bealtaine'],
new DateTime("next monday $this->year-4-30", new DateTimeZone($this->timezone)),
$this->locale
));
@@ -287,13 +302,13 @@ public function calculateMayDay(): void
*
* @link http://www.irishstatutebook.ie/eli/1961/act/33/section/8/enacted/en/html
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
* @throws \Exception
*/
- public function calculateJuneHoliday(): void
+ private function calculateJuneHoliday(): void
{
if ($this->year < 1974) {
return;
@@ -301,7 +316,7 @@ public function calculateJuneHoliday(): void
$this->addHoliday(new Holiday(
'juneHoliday',
- ['en_IE' => 'June Holiday', 'ga_IE' => 'Lá Saoire i mí an Mheithimh'],
+ ['en' => 'June Holiday', 'ga' => 'Lá Saoire i mí an Mheithimh'],
new DateTime("next monday $this->year-5-31", new DateTimeZone($this->timezone)),
$this->locale
));
@@ -314,13 +329,13 @@ public function calculateJuneHoliday(): void
*
* @link http://www.irishstatutebook.ie/eli/1973/act/25/schedule/1/enacted/en/html#sched1
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
* @throws \Exception
*/
- public function calculateOctoberHoliday(): void
+ private function calculateOctoberHoliday(): void
{
if ($this->year < 1977) {
return;
@@ -328,7 +343,7 @@ public function calculateOctoberHoliday(): void
$this->addHoliday(new Holiday(
'octoberHoliday',
- ['en_IE' => 'October Holiday', 'ga_IE' => 'Lá Saoire i mí Dheireadh Fómhair'],
+ ['en' => 'October Holiday', 'ga' => 'Lá Saoire i mí Dheireadh Fómhair'],
new DateTime("previous monday $this->year-11-01", new DateTimeZone($this->timezone)),
$this->locale
));
diff --git a/src/Yasumi/Provider/Italy.php b/src/Yasumi/Provider/Italy.php
index 537019937..1e4bd58ac 100755
--- a/src/Yasumi/Provider/Italy.php
+++ b/src/Yasumi/Provider/Italy.php
@@ -1,4 +1,4 @@
-year >= 1949) {
$this->addHoliday(new Holiday(
'liberationDay',
- ['it_IT' => 'Festa della Liberazione'],
+ ['it' => 'Festa della Liberazione'],
new DateTime("$this->year-4-25", new DateTimeZone($this->timezone)),
$this->locale
));
@@ -97,20 +99,20 @@ public function calculateLiberationDay(): void
* in 1946, in which the Italian people were called to the polls to decide on the form of government, following
* the Second World War and the fall of Fascism.
*
- * @link http://en.wikipedia.org/wiki/Festa_della_Repubblica
+ * @link https://en.wikipedia.org/wiki/Festa_della_Repubblica
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
* @throws \Exception
*/
- public function calculateRepublicDay(): void
+ private function calculateRepublicDay(): void
{
if ($this->year >= 1946) {
$this->addHoliday(new Holiday(
'republicDay',
- ['it_IT' => 'Festa della Republica'],
+ ['it' => 'Festa della Repubblica'],
new DateTime("$this->year-6-2", new DateTimeZone($this->timezone)),
$this->locale
));
diff --git a/src/Yasumi/Provider/Japan.php b/src/Yasumi/Provider/Japan.php
index d8345bde9..60f187909 100755
--- a/src/Yasumi/Provider/Japan.php
+++ b/src/Yasumi/Provider/Japan.php
@@ -1,4 +1,4 @@
-calculateChildrensDay();
$this->calculateCultureDay();
$this->calculateLaborThanksgivingDay();
- $this->calculateEmporersBirthday();
+ $this->calculateEmperorsBirthday();
$this->calculateVernalEquinoxDay();
$this->calculateComingOfAgeDay();
$this->calculateGreeneryDay();
$this->calculateMarineDay();
$this->calculateMountainDay();
$this->calculateRespectForTheAgeDay();
- $this->calculateHealthAndSportsDay();
+ $this->calculateSportsDay();
$this->calculateAutumnalEquinoxDay();
$this->calculateSubstituteHolidays();
+ $this->calculateCoronationDay();
+ $this->calculateEnthronementProclamationCeremony();
$this->calculateBridgeHolidays();
}
@@ -118,7 +119,10 @@ private function calculateNationalFoundationDay(): void
if ($this->year >= 1966) {
$this->addHoliday(new Holiday(
'nationalFoundationDay',
- ['en_US' => 'National Foundation Day', 'ja_JP' => '建国記念の日'],
+ [
+ 'en' => 'National Foundation Day',
+ 'ja' => '建国記念の日',
+ ],
new DateTime("$this->year-2-11", new DateTimeZone($this->timezone)),
$this->locale
));
@@ -135,7 +139,10 @@ private function calculateShowaDay(): void
if ($this->year >= 2007) {
$this->addHoliday(new Holiday(
'showaDay',
- ['en_US' => 'Showa Day', 'ja_JP' => '昭和の日'],
+ [
+ 'en' => 'Showa Day',
+ 'ja' => '昭和の日',
+ ],
new DateTime("$this->year-4-29", new DateTimeZone($this->timezone)),
$this->locale
));
@@ -152,12 +159,16 @@ private function calculateConstitutionMemorialDay(): void
if ($this->year >= 1948) {
$this->addHoliday(new Holiday(
'constitutionMemorialDay',
- ['en_US' => 'Constitution Memorial Day', 'ja_JP' => '憲法記念日'],
+ [
+ 'en' => 'Constitution Memorial Day',
+ 'ja' => '憲法記念日',
+ ],
new DateTime("$this->year-5-3", new DateTimeZone($this->timezone)),
$this->locale
));
}
}
+
/**
* Children's Day. Children's Day is held on May 5th and established since 1948.
*
@@ -168,7 +179,10 @@ private function calculateChildrensDay(): void
if ($this->year >= 1948) {
$this->addHoliday(new Holiday(
'childrensDay',
- ['en_US' => 'Children\'s Day', 'ja_JP' => 'こどもの日'],
+ [
+ 'en' => 'Children\'s Day',
+ 'ja' => 'こどもの日',
+ ],
new DateTime("$this->year-5-5", new DateTimeZone($this->timezone)),
$this->locale
));
@@ -185,7 +199,7 @@ private function calculateCultureDay(): void
if ($this->year >= 1948) {
$this->addHoliday(new Holiday(
'cultureDay',
- ['en_US' => 'Culture Day', 'ja_JP' => '文化の日'],
+ ['en' => 'Culture Day', 'ja' => '文化の日'],
new DateTime("$this->year-11-3", new DateTimeZone($this->timezone)),
$this->locale
));
@@ -202,7 +216,7 @@ private function calculateLaborThanksgivingDay(): void
if ($this->year >= 1948) {
$this->addHoliday(new Holiday(
'laborThanksgivingDay',
- ['en_US' => 'Labor Thanksgiving Day', 'ja_JP' => '勤労感謝の日'],
+ ['en' => 'Labor Thanksgiving Day', 'ja' => '勤労感謝の日'],
new DateTime("$this->year-11-23", new DateTimeZone($this->timezone)),
$this->locale
));
@@ -210,18 +224,29 @@ private function calculateLaborThanksgivingDay(): void
}
/**
- * Emperors Birthday. The Emperors Birthday is on December 23rd and celebrated as such since 1989.
- * Prior to the death of Emperor Hirohito in 1989, this holiday was celebrated on April 29. See also "Shōwa Day".
+ * Emperors Birthday.
+ * The Emperors Birthday is on April 29rd and celebrated as such since 1949 to 1988.
+ * December 23rd and celebrated as such since 1989 to 2018.
+ * February 23rd and celebrated as such since 2020.(Coronation Day of the new Emperor, May 1, 2019)
*
* @throws \Exception
*/
- private function calculateEmporersBirthday(): void
+ private function calculateEmperorsBirthday(): void
{
- if ($this->year >= 1989) {
+ $emperorsBirthday = false;
+ if ($this->year >= 2020) {
+ $emperorsBirthday = "$this->year-2-23";
+ } elseif ($this->year >= 1989 && $this->year < 2019) {
+ $emperorsBirthday = "$this->year-12-23";
+ } elseif ($this->year >= 1949 && $this->year < 1988) {
+ $emperorsBirthday = "$this->year-4-29";
+ }
+
+ if (\is_string($emperorsBirthday)) {
$this->addHoliday(new Holiday(
'emperorsBirthday',
- ['en_US' => 'Emperors Birthday', 'ja_JP' => '天皇誕生日'],
- new DateTime("$this->year-12-23", new DateTimeZone($this->timezone)),
+ ['en' => 'Emperors Birthday', 'ja' => '天皇誕生日'],
+ new DateTime($emperorsBirthday, new DateTimeZone($this->timezone)),
$this->locale
));
}
@@ -236,9 +261,9 @@ private function calculateEmporersBirthday(): void
*
* @link http://www.h3.dion.ne.jp/~sakatsu/holiday_topic.htm (in Japanese)
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
private function calculateVernalEquinoxDay(): void
@@ -254,10 +279,10 @@ private function calculateVernalEquinoxDay(): void
$day = \floor(self::VERNAL_EQUINOX_PARAM_2150 + self::EQUINOX_GRADIENT * ($this->year - 1980) - \floor(($this->year - 1980) / 4));
}
- if (null !== $day) {
+ if (\is_numeric($day)) {
$this->addHoliday(new Holiday(
'vernalEquinoxDay',
- ['en_US' => 'Vernal Equinox Day', 'ja_JP' => '春分の日'],
+ ['en' => 'Vernal Equinox Day', 'ja' => '春分の日'],
new DateTime("$this->year-3-$day", new DateTimeZone($this->timezone)),
$this->locale
));
@@ -270,9 +295,9 @@ private function calculateVernalEquinoxDay(): void
* Coming of Age Day was established after 1948 on January 15th. After 2000 it was changed to be the second monday
* of January.
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
* @throws \Exception
*/
@@ -285,10 +310,10 @@ private function calculateComingOfAgeDay(): void
$date = new DateTime("$this->year-1-15", new DateTimeZone($this->timezone));
}
- if (null !== $date) {
+ if ($date instanceof DateTimeInterface) {
$this->addHoliday(new Holiday(
'comingOfAgeDay',
- ['en_US' => 'Coming of Age Day', 'ja_JP' => '成人の日'],
+ ['en' => 'Coming of Age Day', 'ja' => '成人の日'],
$date,
$this->locale
));
@@ -300,9 +325,9 @@ private function calculateComingOfAgeDay(): void
*
* Greenery Day was established from 1989 on April 29th. After 2007 it was changed to be May 4th.
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
* @throws \Exception
*/
@@ -315,10 +340,10 @@ private function calculateGreeneryDay(): void
$date = new DateTime("$this->year-4-29", new DateTimeZone($this->timezone));
}
- if (null !== $date) {
+ if ($date instanceof DateTimeInterface) {
$this->addHoliday(new Holiday(
'greeneryDay',
- ['en_US' => 'Greenery Day', 'ja_JP' => 'みどりの日'],
+ ['en' => 'Greenery Day', 'ja' => 'みどりの日'],
$date,
$this->locale
));
@@ -331,9 +356,9 @@ private function calculateGreeneryDay(): void
* Marine Day was established since 1996 on July 20th. After 2003 it was changed to be the third monday of July.In
* 2020 is July 23th.
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
* @throws \Exception
* @throws \Exception
@@ -341,7 +366,7 @@ private function calculateGreeneryDay(): void
private function calculateMarineDay(): void
{
$date = null;
- if ($this->year === 2020) {
+ if (2020 === $this->year) {
$date = new DateTime("$this->year-7-23", new DateTimeZone($this->timezone));
} elseif ($this->year >= 2003) {
$date = new DateTime("third monday of july $this->year", new DateTimeZone($this->timezone));
@@ -349,10 +374,10 @@ private function calculateMarineDay(): void
$date = new DateTime("$this->year-7-20", new DateTimeZone($this->timezone));
}
- if (null !== $date) {
+ if ($date instanceof DateTimeInterface) {
$this->addHoliday(new Holiday(
'marineDay',
- ['en_US' => 'Marine Day', 'ja_JP' => '海の日'],
+ ['en' => 'Marine Day', 'ja' => '海の日'],
$date,
$this->locale
));
@@ -365,23 +390,23 @@ private function calculateMarineDay(): void
* Mountain Day. Mountain Day is held on August 11th and established since 2016.In 2020 is August 10th.
*
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
* @throws \Exception
*/
private function calculateMountainDay(): void
{
$date = null;
- if ($this->year === 2020) {
+ if (2020 === $this->year) {
$date = new DateTime("$this->year-8-10", new DateTimeZone($this->timezone));
} elseif ($this->year >= 2016) {
$date = new DateTime("$this->year-8-11", new DateTimeZone($this->timezone));
}
- if (null !== $date) {
+ if ($date instanceof DateTimeInterface) {
$this->addHoliday(new Holiday(
'mountainDay',
- ['en_US' => 'Mountain Day', 'ja_JP' => '山の日'],
+ ['en' => 'Mountain Day', 'ja' => '山の日'],
$date,
$this->locale
));
@@ -394,9 +419,9 @@ private function calculateMountainDay(): void
* Respect for the Age Day was established since 1996 on September 15th. After 2003 it was changed to be the third
* monday of September.
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
* @throws \Exception
*/
@@ -409,10 +434,10 @@ private function calculateRespectForTheAgeDay(): void
$date = new DateTime("$this->year-9-15", new DateTimeZone($this->timezone));
}
- if (null !== $date) {
+ if ($date instanceof DateTimeInterface) {
$this->addHoliday(new Holiday(
'respectfortheAgedDay',
- ['en_US' => 'Respect for the Aged Day', 'ja_JP' => '敬老の日'],
+ ['en' => 'Respect for the Aged Day', 'ja' => '敬老の日'],
$date,
$this->locale
));
@@ -425,17 +450,17 @@ private function calculateRespectForTheAgeDay(): void
* Health And Sports Day was established since 1966 on October 10th. After 2000 it was changed to be the second
* monday of October.In 2020 is July 24th.
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
* @throws \Exception
* @throws \Exception
*/
- private function calculateHealthAndSportsDay(): void
+ private function calculateSportsDay(): void
{
$date = null;
- if ($this->year === 2020) {
+ if (2020 === $this->year) {
$date = new DateTime("$this->year-7-24", new DateTimeZone($this->timezone));
} elseif ($this->year >= 2000) {
$date = new DateTime("second monday of october $this->year", new DateTimeZone($this->timezone));
@@ -443,10 +468,15 @@ private function calculateHealthAndSportsDay(): void
$date = new DateTime("$this->year-10-10", new DateTimeZone($this->timezone));
}
- if (null !== $date) {
+ $holiday_name = ['en' => 'Health And Sports Day', 'ja' => '体育の日'];
+ if ($this->year >= 2020) {
+ $holiday_name = ['en' => 'Sports Day', 'ja' => 'スポーツの日'];
+ }
+
+ if ($date instanceof DateTimeInterface) {
$this->addHoliday(new Holiday(
- 'healthandSportsDay',
- ['en_US' => 'Health And Sports Day', 'ja_JP' => '体育の日'],
+ 'sportsDay',
+ $holiday_name,
$date,
$this->locale
));
@@ -462,9 +492,9 @@ private function calculateHealthAndSportsDay(): void
*
* @link http://www.h3.dion.ne.jp/~sakatsu/holiday_topic.htm (in Japanese)
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
private function calculateAutumnalEquinoxDay(): void
@@ -480,10 +510,10 @@ private function calculateAutumnalEquinoxDay(): void
$day = \floor(self::AUTUMNAL_EQUINOX_PARAM_2150 + self::EQUINOX_GRADIENT * ($this->year - 1980) - \floor(($this->year - 1980) / 4));
}
- if (null !== $day) {
+ if (\is_numeric($day)) {
$this->addHoliday(new Holiday(
'autumnalEquinoxDay',
- ['en_US' => 'Autumnal Equinox Day', 'ja_JP' => '秋分の日'],
+ ['en' => 'Autumnal Equinox Day', 'ja' => '秋分の日'],
new DateTime("$this->year-9-$day", new DateTimeZone($this->timezone)),
$this->locale
));
@@ -496,9 +526,9 @@ private function calculateAutumnalEquinoxDay(): void
* Generally if a national holiday falls on a Sunday, the holiday is observed the next working day (not being
* another holiday).
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
private function calculateSubstituteHolidays(): void
@@ -507,20 +537,20 @@ private function calculateSubstituteHolidays(): void
$dates = $this->getHolidayDates();
// Loop through all holidays
- foreach ($this->getHolidays() as $shortName => $date) {
- $substituteDay = clone $date;
+ foreach ($this->getHolidays() as $shortName => $holiday) {
+ $date = clone $holiday;
// If holidays falls on a Sunday
- if (0 === (int)$date->format('w')) {
+ if (0 === (int)$holiday->format('w')) {
if ($this->year >= 2007) {
// Find next week day (not being another holiday)
- while (\in_array($substituteDay, $dates, false)) {
- $substituteDay->add(new DateInterval('P1D'));
+ while (\in_array($date, $dates, false)) {
+ $date->add(new DateInterval('P1D'));
continue;
}
- } elseif ($date >= '1973-04-12') {
- $substituteDay->add(new DateInterval('P1D'));
- if (\in_array($substituteDay, $dates, false)) {
+ } elseif ($holiday >= '1973-04-12') {
+ $date->add(new DateInterval('P1D'));
+ if (\in_array($date, $dates, false)) {
continue; // @codeCoverageIgnore
}
} else {
@@ -528,24 +558,62 @@ private function calculateSubstituteHolidays(): void
}
// Add a new holiday that is substituting the original holiday
- $substituteHoliday = new Holiday('substituteHoliday:' . $shortName, [
- 'en_US' => $date->translations['en_US'] . ' Observed',
- 'ja_JP' => '振替休日 (' . $date->translations['ja_JP'] . ')',
- ], $substituteDay, $this->locale);
-
- $this->addHoliday($substituteHoliday);
+ $substitute = new SubstituteHoliday(
+ $holiday,
+ [],
+ $date,
+ $this->locale
+ );
+
+ $this->addHoliday($substitute);
}
}
}
+ /**
+ * Coronation Day. Coronation Day is The new Emperor Coronation.
+ * This holiday is only 2019.
+ *
+ * @throws \Exception
+ */
+ private function calculateCoronationDay(): void
+ {
+ if (2019 === $this->year) {
+ $this->addHoliday(new Holiday(
+ 'coronationDay',
+ ['en' => 'Coronation Day', 'ja' => '即位の日'],
+ new DateTime("$this->year-5-1", new DateTimeZone($this->timezone)),
+ $this->locale
+ ));
+ }
+ }
+
+ /**
+ * Enthronement Proclamation Ceremony. Enthronement Proclamation Ceremony is The New Emperor enthronement ceremony.
+ * This holiday only 2019.
+ *
+ * @throws \Exception
+ */
+ private function calculateEnthronementProclamationCeremony(): void
+ {
+ if (2019 === $this->year) {
+ $this->addHoliday(new Holiday(
+ 'enthronementProclamationCeremony',
+ ['en' => 'Enthronement Proclamation Ceremony', 'ja' => '即位礼正殿の儀'],
+ new DateTime("$this->year-10-22", new DateTimeZone($this->timezone)),
+ $this->locale
+ ));
+ }
+ }
+
/**
* Calculate public bridge holidays.
*
* Any day that falls between two other national holidays also becomes a holiday, known as a bridge holiday.
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
private function calculateBridgeHolidays(): void
@@ -553,6 +621,7 @@ private function calculateBridgeHolidays(): void
// Get initial list of holidays and iterator
$datesIterator = $this->getIterator();
+ $counter = 1;
// Loop through all defined holidays
while ($datesIterator->valid()) {
$previous = $datesIterator->current();
@@ -568,10 +637,11 @@ private function calculateBridgeHolidays(): void
$bridgeDate = clone $previous;
$bridgeDate->add(new DateInterval('P1D'));
- $this->addHoliday(new Holiday('bridgeDay', [
- 'en_US' => 'Bridge Public holiday',
- 'ja_JP' => '国民の休日',
+ $this->addHoliday(new Holiday('bridgeDay' . $counter, [
+ 'en' => 'Bridge Public holiday',
+ 'ja' => '国民の休日',
], $bridgeDate, $this->locale));
+ $counter++;
}
}
}
diff --git a/src/Yasumi/Provider/Latvia.php b/src/Yasumi/Provider/Latvia.php
index ae2eec0e7..89b81bf0b 100644
--- a/src/Yasumi/Provider/Latvia.php
+++ b/src/Yasumi/Provider/Latvia.php
@@ -1,4 +1,4 @@
-year >= self::RESTORATION_OF_INDEPENDENCE_YEAR) {
$date = new \DateTime("{$this->year}-05-04", new \DateTimeZone($this->timezone));
- if (! $this->isWorkingDay($date)) {
+ if (!$this->isWorkingDay($date)) {
$date->modify('next monday');
}
$this->addHoliday(new Holiday('restorationOfIndependenceOfLatviaDay', [
- 'en_US' => 'Restoration of Independence day',
- 'lv_LV' => 'Latvijas Republikas Neatkarības atjaunošanas diena'
+ 'en' => 'Restoration of Independence day',
+ 'lv' => 'Latvijas Republikas Neatkarības atjaunošanas diena',
], $date));
}
}
@@ -90,8 +90,8 @@ private function addRestorationOfIndependenceDay(): void
private function addMidsummerEveDay(): void
{
$this->addHoliday(new Holiday('midsummerEveDay', [
- 'en_US' => 'Midsummer Eve',
- 'lv_LV' => 'Līgo Diena'
+ 'en' => 'Midsummer Eve',
+ 'lv' => 'Līgo Diena',
], new \DateTime("{$this->year}-06-23", new \DateTimeZone($this->timezone))));
}
@@ -107,13 +107,13 @@ private function addProclamationDay(): void
if ($this->year >= self::PROCLAMATION_OF_INDEPENDENCE_YEAR) {
$date = new \DateTime("{$this->year}-11-18", new \DateTimeZone($this->timezone));
- if (! $this->isWorkingDay($date)) {
+ if (!$this->isWorkingDay($date)) {
$date->modify('next monday');
}
$this->addHoliday(new Holiday('proclamationOfTheRepublicOfLatviaDay', [
- 'en_US' => 'Proclamation Day of the Republic of Latvia',
- 'lv_LV' => 'Latvijas Republikas proklamēšanas diena'
+ 'en' => 'Proclamation Day of the Republic of Latvia',
+ 'lv' => 'Latvijas Republikas proklamēšanas diena',
], $date));
}
}
diff --git a/src/Yasumi/Provider/Lithuania.php b/src/Yasumi/Provider/Lithuania.php
index a64a1f109..c112f4418 100644
--- a/src/Yasumi/Provider/Lithuania.php
+++ b/src/Yasumi/Provider/Lithuania.php
@@ -1,4 +1,4 @@
-year >= self::RESTORATION_OF_THE_STATE_YEAR) {
$this->addHoliday(new Holiday('restorationOfTheStateOfLithuaniaDay', [
- 'en_US' => 'Day of Restoration of the State of Lithuania',
- 'lt_LT' => 'Lietuvos valstybės atkūrimo diena'
+ 'en' => 'Day of Restoration of the State of Lithuania',
+ 'lt' => 'Lietuvos valstybės atkūrimo diena',
], new \DateTime("{$this->year}-02-16", new \DateTimeZone($this->timezone))));
}
}
@@ -97,8 +97,8 @@ private function addRestorationOfIndependenceDay(): void
{
if ($this->year >= self::RESTORATION_OF_INDEPENDENCE_YEAR) {
$this->addHoliday(new Holiday('restorationOfIndependenceOfLithuaniaDay', [
- 'en_US' => 'Day of Restoration of Independence of Lithuania',
- 'lt_LT' => 'Lietuvos nepriklausomybės atkūrimo diena'
+ 'en' => 'Day of Restoration of Independence of Lithuania',
+ 'lt' => 'Lietuvos nepriklausomybės atkūrimo diena',
], new \DateTime("{$this->year}-03-11", new \DateTimeZone($this->timezone))));
}
}
@@ -114,8 +114,8 @@ private function addStatehoodDay(): void
{
if ($this->year >= self::STATEHOOD_YEAR) {
$this->addHoliday(new Holiday('statehoodDay', [
- 'en_US' => 'Statehood Day (Lithuania)',
- 'lt_LT' => 'Valstybės (Lietuvos karaliaus Mindaugo karūnavimo) diena'
+ 'en' => 'Statehood Day (Lithuania)',
+ 'lt' => 'Valstybės (Lietuvos karaliaus Mindaugo karūnavimo) diena',
], new \DateTime("{$this->year}-07-06", new \DateTimeZone($this->timezone)), $this->locale));
}
}
diff --git a/src/Yasumi/Provider/Netherlands.php b/src/Yasumi/Provider/Netherlands.php
index 2c301b997..e589e62d3 100755
--- a/src/Yasumi/Provider/Netherlands.php
+++ b/src/Yasumi/Provider/Netherlands.php
@@ -1,4 +1,4 @@
-addHoliday($this->christmasDay($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->secondChristmasDay($this->year, $this->timezone, $this->locale));
- /**
- * Commemoration Day and Liberation Day. Instituted after WWII in 1947.
- */
- if ($this->year >= 1947) {
- $this->addHoliday(new Holiday(
- 'commemorationDay',
- ['en_US' => 'Commemoration Day', 'nl_NL' => 'Dodenherdenking'],
- new DateTime("$this->year-5-4", new DateTimeZone($this->timezone)),
- $this->locale,
- Holiday::TYPE_OBSERVANCE
- ));
- $this->addHoliday(new Holiday(
- 'liberationDay',
- ['en_US' => 'Liberation Day', 'nl_NL' => 'Bevrijdingsdag'],
- new DateTime("$this->year-5-5", new DateTimeZone($this->timezone)),
- $this->locale,
- Holiday::TYPE_OBSERVANCE
- ));
- }
-
- /**
- * Kings Day.
- *
- * King's Day is celebrated from 2014 onwards on April 27th. If this happens to be on a Sunday, it will be
- * celebrated the day before instead.
- */
- if ($this->year >= 2014) {
- $date = new DateTime("$this->year-4-27", new DateTimeZone($this->timezone));
-
- if (0 === (int)$date->format('w')) {
- $date->sub(new DateInterval('P1D'));
- }
-
- $this->addHoliday(new Holiday(
- 'kingsDay',
- ['en_US' => 'Kings Day', 'nl_NL' => 'Koningsdag'],
- $date,
- $this->locale
- ));
- }
-
- /**
- * Queen's Day.
- *
- * Queen's Day was celebrated between 1891 and 1948 (inclusive) on August 31. Between 1949 and 2013 (inclusive) it
- * was celebrated April 30. If these dates are on a Sunday, Queen's Day was celebrated one day later until 1980
- * (on the following Monday), starting 1980 one day earlier (on the preceding Saturday).
- */
- if ($this->year >= 1891 && $this->year <= 2013) {
- $date = new DateTime("$this->year-4-30", new DateTimeZone($this->timezone));
- if ($this->year <= 1948) {
- $date = new DateTime("$this->year-8-31", new DateTimeZone($this->timezone));
- }
-
- // Determine substitution day
- if (0 === (int)$date->format('w')) {
- ($this->year < 1980) ? $date->add(new DateInterval('P1D')) : $date->sub(new DateInterval('P1D'));
- }
-
- $this->addHoliday(new Holiday(
- 'queensDay',
- ['en_US' => 'Queen\'s Day', 'nl_NL' => 'Koninginnedag'],
- $date,
- $this->locale
- ));
- }
+ // Calculate other holidays
+ $this->calculateCarnival();
+ $this->calculateWinterTime();
+ $this->calculateSummerTime();
+ $this->calculateStNicholasDay();
+ $this->calculateHalloween();
+ $this->calculatePrincesDay();
+ $this->calculateQueensday();
+ $this->calculateKingsday();
+ $this->calculateCommemorationLiberationDay();
+ }
- /**
- * Prince's Day.
- *
- * Prinsjesdag (English: Prince's Day) is the day on which the reigning monarch of the Netherlands addresses a joint
- * session of the Dutch Senate and House of Representatives.
- */
+ /**
+ * Carnival.
+ *
+ * Carnival (Dutch: Carnaval) is originally an European Pagan spring festival, with an emphasis on role-reversal
+ * and suspension of social norms. The feast became assimilated by the Catholic Church and was celebrated in the
+ * three days preceding Ash Wednesday and Lent.
+ *
+ * @throws \Exception
+ */
+ private function calculateCarnival(): void
+ {
+ $easter = $this->calculateEaster($this->year, $this->timezone);
+ $carnivalDay1 = clone $easter;
$this->addHoliday(new Holiday(
- 'princesDay',
- ['en_US' => 'Prince\'s Day', 'nl_NL' => 'Prinsjesdag'],
- new DateTime("third tuesday of september $this->year", new DateTimeZone($this->timezone)),
+ 'carnivalDay',
+ ['en' => 'Carnival', 'nl' => 'Carnaval'],
+ $carnivalDay1->sub(new DateInterval('P49D')),
$this->locale,
- Holiday::TYPE_OTHER
+ Holiday::TYPE_OBSERVANCE
));
/**
- * Halloween
+ * Second Day of Carnival.
*/
+ $carnivalDay2 = clone $easter;
$this->addHoliday(new Holiday(
- 'halloween',
- ['en_US' => 'Halloween', 'nl_NL' => 'Halloween'],
- new DateTime("$this->year-10-31", new DateTimeZone($this->timezone)),
+ 'secondCarnivalDay',
+ ['en' => 'Carnival', 'nl' => 'Carnaval'],
+ $carnivalDay2->sub(new DateInterval('P48D')),
$this->locale,
Holiday::TYPE_OBSERVANCE
));
/**
- * St. Nicholas' Day
+ * Third Day of Carnival.
*/
+ $carnivalDay3 = clone $easter;
$this->addHoliday(new Holiday(
- 'stNicholasDay',
- ['en_US' => 'St. Nicholas\' Day', 'nl_NL' => 'Sinterklaas'],
- new DateTime("$this->year-12-5", new DateTimeZone($this->timezone)),
+ 'thirdCarnivalDay',
+ ['en' => 'Carnival', 'nl' => 'Carnaval'],
+ $carnivalDay3->sub(new DateInterval('P47D')),
$this->locale,
Holiday::TYPE_OBSERVANCE
));
+ }
- $summerTime = $this->summerTime($this->year, $this->timezone, $this->locale);
- if ($summerTime !== null) {
- $this->addHoliday($summerTime);
- }
-
+ /**
+ * Winter Time.
+ *
+ * The beginning of winter time. Winter time is also known as standard time.
+ *
+ * @throws \Exception
+ * @see \Yasumi\Provider\CommonHolidays::winterTime()
+ *
+ */
+ private function calculateWinterTime(): void
+ {
$winterTime = $this->winterTime($this->year, $this->timezone, $this->locale);
- if ($winterTime !== null) {
+ if ($winterTime instanceof Holiday) {
$this->addHoliday($winterTime);
}
+ }
+ /**
+ * Summer Time.
+ *
+ * The beginning of summer time. Summer time is also known as day lights saving time.
+ *
+ * @throws \Exception
+ * @see \Yasumi\Provider\CommonHolidays::summerTime()
+ *
+ */
+ private function calculateSummerTime(): void
+ {
+ $summerTime = $this->summerTime($this->year, $this->timezone, $this->locale);
+ if ($summerTime instanceof Holiday) {
+ $this->addHoliday($summerTime);
+ }
+ }
+
+ /**
+ * St. Nicholas' Day
+ *
+ * The feast of Sinterklaas celebrates the name day of Saint Nicholas on 6 December.
+ * The feast is celebrated annually with the giving of gifts on St. Nicholas' Eve (5 December) in the Netherlands
+ * and on the morning of 6 December, Saint Nicholas Day, in Belgium, Luxembourg and northern France
+ * (French Flanders, Lorraine and Artois).
+ *
+ * @link https://en.wikipedia.org/wiki/Sinterklaas
+ *
+ * @throws \Exception
+ */
+ private function calculateStNicholasDay(): void
+ {
/**
- * Carnival.
- *
- * Carnival (Dutch: Carnaval) is originally an European Pagan spring festival, with an emphasis on role-reversal
- * and suspension of social norms. The feast became assimilated by the Catholic Church and was celebrated in the
- * three days preceding Ash Wednesday and Lent.
+ * St. Nicholas' Day
*/
- $easter = $this->calculateEaster($this->year, $this->timezone);
- $carnivalDay1 = clone $easter;
$this->addHoliday(new Holiday(
- 'carnivalDay',
- ['en_US' => 'Carnival', 'nl_NL' => 'Carnaval'],
- $carnivalDay1->sub(new DateInterval('P49D')),
+ 'stNicholasDay',
+ ['en' => 'St. Nicholas\' Day', 'nl' => 'Sinterklaas'],
+ new DateTime("$this->year-12-5", new DateTimeZone($this->timezone)),
$this->locale,
Holiday::TYPE_OBSERVANCE
));
+ }
- /**
- * Second Day of Carnival.
- */
- $carnivalDay2 = clone $easter;
+ /**
+ * Halloween
+ *
+ * Halloween or Hallowe'en (a contraction of Hallows' Even or Hallows' Evening), is a celebration observed in
+ * several countries on 31 October, the eve of the Western Christian feast of All Hallows' Day.
+ * It begins the three-day observance of Allhallowtide, the time in the liturgical year dedicated to remembering the
+ * dead, including saints (hallows), martyrs, and all the faithful departed.
+ *
+ * @link https://en.wikipedia.org/wiki/Halloween
+ *
+ * @throws \Exception
+ */
+ private function calculateHalloween(): void
+ {
$this->addHoliday(new Holiday(
- 'secondCarnivalDay',
- ['en_US' => 'Carnival', 'nl_NL' => 'Carnaval'],
- $carnivalDay2->sub(new DateInterval('P48D')),
+ 'halloween',
+ ['en' => 'Halloween', 'nl' => 'Halloween'],
+ new DateTime("$this->year-10-31", new DateTimeZone($this->timezone)),
$this->locale,
Holiday::TYPE_OBSERVANCE
));
+ }
- /**
- * Third Day of Carnival.
- */
- $carnivalDay3 = clone $easter;
+ /**
+ * Prince's Day.
+ *
+ * Prinsjesdag (English: Prince's Day) is the day on which the reigning monarch of the Netherlands addresses a joint
+ * session of the Dutch Senate and House of Representatives.
+ *
+ * @throws \Exception
+ */
+ private function calculatePrincesDay(): void
+ {
$this->addHoliday(new Holiday(
- 'thirdCarnivalDay',
- ['en_US' => 'Carnival', 'nl_NL' => 'Carnaval'],
- $carnivalDay3->sub(new DateInterval('P47D')),
+ 'princesDay',
+ ['en' => 'Prince\'s Day', 'nl' => 'Prinsjesdag'],
+ new DateTime("third tuesday of september $this->year", new DateTimeZone($this->timezone)),
$this->locale,
- Holiday::TYPE_OBSERVANCE
+ Holiday::TYPE_OTHER
));
}
+
+ /**
+ * Queen's Day.
+ *
+ * Queen's Day was celebrated between 1891 and 1948 (inclusive) on August 31. Between 1949 and 2013 (inclusive) it
+ * was celebrated April 30. If these dates are on a Sunday, Queen's Day was celebrated one day later until 1980
+ * (on the following Monday), starting 1980 one day earlier (on the preceding Saturday).
+ *
+ * @throws \Exception
+ */
+ private function calculateQueensday(): void
+ {
+ if ($this->year >= 1891 && $this->year <= 2013) {
+ $date = new DateTime("$this->year-4-30", new DateTimeZone($this->timezone));
+ if ($this->year <= 1948) {
+ $date = new DateTime("$this->year-8-31", new DateTimeZone($this->timezone));
+ }
+
+ // Determine substitution day
+ if (0 === (int)$date->format('w')) {
+ $this->year < 1980 ? $date->add(new DateInterval('P1D')) : $date->sub(new DateInterval('P1D'));
+ }
+
+ $this->addHoliday(new Holiday(
+ 'queensDay',
+ ['en' => 'Queen\'s Day', 'nl' => 'Koninginnedag'],
+ $date,
+ $this->locale
+ ));
+ }
+ }
+
+ /**
+ * Kings Day.
+ *
+ * King's Day is celebrated from 2014 onwards on April 27th. If this happens to be on a Sunday, it will be
+ * celebrated the day before instead.
+ *
+ * @throws \Exception
+ */
+ private function calculateKingsday(): void
+ {
+ if ($this->year >= 2014) {
+ $date = new DateTime("$this->year-4-27", new DateTimeZone($this->timezone));
+
+ if (0 === (int)$date->format('w')) {
+ $date->sub(new DateInterval('P1D'));
+ }
+
+ $this->addHoliday(new Holiday(
+ 'kingsDay',
+ ['en' => 'Kings Day', 'nl' => 'Koningsdag'],
+ $date,
+ $this->locale
+ ));
+ }
+ }
+
+ /**
+ * Commemoration Day and Liberation Day.
+ *
+ * Instituted after WWII in 1947.
+ *
+ * @throws \Exception
+ */
+ private function calculateCommemorationLiberationDay(): void
+ {
+ if ($this->year >= 1947) {
+ $this->addHoliday(new Holiday(
+ 'commemorationDay',
+ ['en' => 'Commemoration Day', 'nl' => 'Dodenherdenking'],
+ new DateTime("$this->year-5-4", new DateTimeZone($this->timezone)),
+ $this->locale,
+ Holiday::TYPE_OBSERVANCE
+ ));
+ $this->addHoliday(new Holiday(
+ 'liberationDay',
+ ['en' => 'Liberation Day', 'nl' => 'Bevrijdingsdag'],
+ new DateTime("$this->year-5-5", new DateTimeZone($this->timezone)),
+ $this->locale,
+ Holiday::TYPE_OFFICIAL
+ ));
+ }
+ }
}
diff --git a/src/Yasumi/Provider/NewZealand.php b/src/Yasumi/Provider/NewZealand.php
index a70280234..f190cc6fe 100644
--- a/src/Yasumi/Provider/NewZealand.php
+++ b/src/Yasumi/Provider/NewZealand.php
@@ -1,4 +1,4 @@
-year-01-01", new DateTimeZone($this->timezone));
+ $newYearsDay = new DateTime("$this->year-01-01", new DateTimeZone($this->timezone));
$dayAfterNewYearsDay = new DateTime("$this->year-01-02", new DateTimeZone($this->timezone));
switch ($newYearsDay->format('w')) {
@@ -104,14 +106,14 @@ public function calculateNewYearHolidays(): void
* the Monday that immediately follows becomes a public holiday.
*
* @link https://en.wikipedia.org/wiki/Waitangi_Day
- * @link http://employment.govt.nz/er/holidaysandleave/publicholidays/mondayisation.asp
+ * @link https://www.employment.govt.nz/leave-and-holidays/public-holidays/public-holidays-falling-on-a-weekend/
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateWaitangiDay(): void
+ private function calculateWaitangiDay(): void
{
if ($this->year < 1974) {
return;
@@ -119,7 +121,7 @@ public function calculateWaitangiDay(): void
$date = new DateTime("$this->year-02-6", new DateTimeZone($this->timezone));
- if ($this->year >= 2015 && ! $this->isWorkingDay($date)) {
+ if ($this->year >= 2015 && !$this->isWorkingDay($date)) {
$date->modify('next monday');
}
@@ -134,14 +136,14 @@ public function calculateWaitangiDay(): void
* Observed on 25 April each year.
*
* @link https://en.wikipedia.org/wiki/Anzac_Day
- * @link http://employment.govt.nz/er/holidaysandleave/publicholidays/mondayisation.asp
+ * @link https://www.employment.govt.nz/leave-and-holidays/public-holidays/public-holidays-falling-on-a-weekend/
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateAnzacDay(): void
+ private function calculateAnzacDay(): void
{
if ($this->year < 1921) {
return;
@@ -149,7 +151,7 @@ public function calculateAnzacDay(): void
$date = new DateTime("$this->year-04-25", new DateTimeZone($this->timezone));
- if ($this->year >= 2015 && ! $this->isWorkingDay($date)) {
+ if ($this->year >= 2015 && !$this->isWorkingDay($date)) {
$date->modify('next monday');
}
@@ -167,14 +169,14 @@ public function calculateAnzacDay(): void
*
* Her actual birthday is on April 21, but it's celebrated as a public holiday on the first Monday of June.
*
- * @link http://www.timeanddate.com/holidays/new-zealand/queen-birthday
+ * @link https://www.timeanddate.com/holidays/new-zealand/queen-birthday
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateQueensBirthday(): void
+ private function calculateQueensBirthday(): void
{
if ($this->year < 1952) {
return;
@@ -182,7 +184,7 @@ public function calculateQueensBirthday(): void
$this->addHoliday(new Holiday(
'queensBirthday',
- ['en_NZ' => 'Queens Birthday'],
+ ['en' => 'Queens Birthday'],
new DateTime("first monday of june $this->year", new DateTimeZone($this->timezone)),
$this->locale
));
@@ -200,21 +202,21 @@ public function calculateQueensBirthday(): void
* second Wednesday in October in 1900. The holiday was moved to the fourth Monday of October in 1910
* has remained on this date since then.
*
- * @link http://www.timeanddate.com/holidays/new-zealand/labour-day
+ * @link https://www.timeanddate.com/holidays/new-zealand/labour-day
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateLabourDay(): void
+ private function calculateLabourDay(): void
{
if ($this->year < 1900) {
return;
}
$date = new DateTime(
- (($this->year < 1910) ? 'second wednesday of october' : 'fourth monday of october') . " $this->year",
+ ($this->year < 1910 ? 'second wednesday of october' : 'fourth monday of october') . " $this->year",
new DateTimeZone($this->timezone)
);
@@ -227,19 +229,19 @@ public function calculateLabourDay(): void
* Christmas day, and Boxing day are public holidays in New Zealand,
* they are subject to mondayisation rules.
*
- * @link http://www.timeanddate.com/holidays/new-zealand/boxing-day
- * @link http://www.timeanddate.com/holidays/new-zealand/christmas-day
- * @link http://employment.govt.nz/er/holidaysandleave/publicholidays/mondayisation.asp
+ * @link https://www.timeanddate.com/holidays/new-zealand/boxing-day
+ * @link https://www.timeanddate.com/holidays/new-zealand/christmas-day
+ * @link https://www.employment.govt.nz/leave-and-holidays/public-holidays/public-holidays-falling-on-a-weekend/
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateChristmasHolidays(): void
+ private function calculateChristmasHolidays(): void
{
$christmasDay = new DateTime("$this->year-12-25", new DateTimeZone($this->timezone));
- $boxingDay = new DateTime("$this->year-12-26", new DateTimeZone($this->timezone));
+ $boxingDay = new DateTime("$this->year-12-26", new DateTimeZone($this->timezone));
switch ($christmasDay->format('w')) {
case 0:
diff --git a/src/Yasumi/Provider/Norway.php b/src/Yasumi/Provider/Norway.php
index 03b42364e..39e02ba38 100644
--- a/src/Yasumi/Provider/Norway.php
+++ b/src/Yasumi/Provider/Norway.php
@@ -1,4 +1,4 @@
-year >= 1836) {
$this->addHoliday(new Holiday(
'constitutionDay',
- ['nb_NO' => 'Grunnlovsdagen'],
+ ['nb' => 'Grunnlovsdagen'],
new DateTime("$this->year-5-17", new DateTimeZone($this->timezone)),
$this->locale
));
diff --git a/src/Yasumi/Provider/Poland.php b/src/Yasumi/Provider/Poland.php
index 4801f45a5..8794aa0c1 100755
--- a/src/Yasumi/Provider/Poland.php
+++ b/src/Yasumi/Provider/Poland.php
@@ -1,4 +1,4 @@
-addHoliday($this->allSaintsDay($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->assumptionOfMary($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->christmasDay($this->year, $this->timezone, $this->locale));
- $this->addHoliday($this->corpusChristi($this->year, $this->timezone, $this->locale));
+ $this->addHoliday($this->corpusChristi($this->year, $this->timezone, $this->locale, Holiday::TYPE_OFFICIAL));
$this->addHoliday($this->easter($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->easterMonday($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->epiphany($this->year, $this->timezone, $this->locale));
@@ -71,21 +73,21 @@ public function initialize(): void
*
* @link https://en.wikipedia.org/wiki/May_3rd_Constitution_Day
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateIndependenceDay(): void
+ private function calculateIndependenceDay(): void
{
if ($this->year < 1918) {
return;
}
$this->addHoliday(new Holiday('independenceDay', [
- 'en_US' => 'Independence Day',
- 'pl_PL' => 'Narodowe Święto Niepodległości'
+ 'en' => 'Independence Day',
+ 'pl' => 'Narodowe Święto Niepodległości',
], new DateTime("$this->year-11-11", new DateTimeZone($this->timezone)), $this->locale));
}
@@ -99,21 +101,21 @@ public function calculateIndependenceDay(): void
*
* @link https://en.wikipedia.org/wiki/National_Independence_Day_(Poland)
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateConstitutionDay(): void
+ private function calculateConstitutionDay(): void
{
if ($this->year < 1791) {
return;
}
$this->addHoliday(new Holiday('constitutionDay', [
- 'en_US' => 'Constitution Day',
- 'pl_PL' => 'Święto Narodowe Trzeciego Maja'
+ 'en' => 'Constitution Day',
+ 'pl' => 'Święto Narodowe Trzeciego Maja',
], new DateTime("$this->year-5-3", new DateTimeZone($this->timezone)), $this->locale));
}
}
diff --git a/src/Yasumi/Provider/Portugal.php b/src/Yasumi/Provider/Portugal.php
index 77294a0aa..f0dc6873b 100644
--- a/src/Yasumi/Provider/Portugal.php
+++ b/src/Yasumi/Provider/Portugal.php
@@ -1,4 +1,4 @@
-year >= 1974) {
$this->addHoliday(new Holiday(
'25thApril',
- ['pt_PT' => 'Dia da Liberdade'],
+ ['pt' => 'Dia da Liberdade'],
new DateTime("$this->year-04-25", new DateTimeZone($this->timezone)),
$this->locale,
Holiday::TYPE_OFFICIAL
@@ -98,14 +100,14 @@ public function calculateCarnationRevolutionDay(): void
* In Portugal, between 2013 andd 2015 (inclusive) this holiday did not happen due to government deliberation.
* It was restored in 2016.
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateCorpusChristi(): void
+ private function calculateCorpusChristi(): void
{
- if ($this->year <= 2013 || $this->year >= 2016) {
+ if ($this->year <= 2012 || $this->year >= 2016) {
$this->addHoliday($this->corpusChristi($this->year, $this->timezone, $this->locale));
}
}
@@ -123,17 +125,17 @@ public function calculateCorpusChristi(): void
*
* @link https://en.wikipedia.org/wiki/Portugal_Day
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculatePortugalDay(): void
+ private function calculatePortugalDay(): void
{
if ($this->year <= 1932 || $this->year >= 1974) {
$this->addHoliday(new Holiday(
'portugalDay',
- ['pt_PT' => 'Dia de Portugal'],
+ ['pt' => 'Dia de Portugal'],
new DateTime("$this->year-06-10", new DateTimeZone($this->timezone)),
$this->locale
));
@@ -153,19 +155,21 @@ public function calculatePortugalDay(): void
* presented itself as the only one that had a programme that was capable of returning to the country its lost
* status and place Portugal on the way of progress.
*
+ * The holiday was revoked in 2013 due to government deliberation. It was restored in 2016.
+ *
* @link https://en.wikipedia.org/wiki/5_October_1910_revolution
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculatePortugueseRepublicDay(): void
+ private function calculatePortugueseRepublicDay(): void
{
- if ($this->year >= 1910) {
+ if (($this->year >= 1910 && $this->year <= 2012) || $this->year >= 2016) {
$this->addHoliday(new Holiday(
'portugueseRepublic',
- ['pt_PT' => 'Implantação da República Portuguesa'],
+ ['pt' => 'Implantação da República Portuguesa'],
new DateTime("$this->year-10-05", new DateTimeZone($this->timezone)),
$this->locale
));
@@ -173,17 +177,17 @@ public function calculatePortugueseRepublicDay(): void
}
/**
- * In Portugal, between 2013 andd 2015 (inclusive) this holiday did not happen due to government deliberation.
+ * In Portugal, between 2013 and 2015 (inclusive) this holiday did not happen due to government deliberation.
* It was restored in 2016.
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateAllSaintsDay(): void
+ private function calculateAllSaintsDay(): void
{
- if ($this->year <= 2013 || $this->year >= 2016) {
+ if ($this->year <= 2012 || $this->year >= 2016) {
$this->addHoliday($this->allSaintsDay($this->year, $this->timezone, $this->locale));
}
}
@@ -205,21 +209,23 @@ public function calculateAllSaintsDay(): void
* and elsewhere, as the Acclamation War. The war established the House of Braganza as Portugal's new ruling
* dynasty, replacing the House of Habsburg. This ended the so-called Iberian Union.
*
+ * The holiday was revoked in 2013 due to government deliberation. It was restored in 2016.
+ *
* @link https://pt.wikipedia.org/wiki/Restauração_da_Independência (portuguese link)
* @link https://pt.wikipedia.org/wiki/Guerra_da_Restauração (english link)
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateRestorationOfIndependenceDay(): void
+ private function calculateRestorationOfIndependenceDay(): void
{
// The Wikipedia article mentions that this has been a holiday since the second of half of the XIX century.
- if (($this->year >= 1850 && $this->year <= 2013) || $this->year >= 2016) {
+ if (($this->year >= 1850 && $this->year <= 2012) || $this->year >= 2016) {
$this->addHoliday(new Holiday(
'restorationOfIndependence',
- ['pt_PT' => 'Restauração da Independência'],
+ ['pt' => 'Restauração da Independência'],
new DateTime("$this->year-12-01", new DateTimeZone($this->timezone)),
$this->locale,
Holiday::TYPE_OFFICIAL
diff --git a/src/Yasumi/Provider/Romania.php b/src/Yasumi/Provider/Romania.php
index 460702433..41f069077 100755
--- a/src/Yasumi/Provider/Romania.php
+++ b/src/Yasumi/Provider/Romania.php
@@ -1,4 +1,4 @@
-addHoliday(new Holiday('dayAfterNewYearsDay', [
- 'en_US' => 'Day after New Year\'s Day',
- 'ro_RO' => 'A doua zi după Anul Nou'
- ], new DateTime("$this->year-01-02", new DateTimeZone($this->timezone)), $this->locale));
+ $this->addHoliday(new Holiday(
+ 'dayAfterNewYearsDay',
+ [],
+ new DateTime("$this->year-01-02", new DateTimeZone($this->timezone)),
+ $this->locale
+ ));
}
/**
@@ -102,18 +106,18 @@ public function calculateDayAfterNewYearsDay(): void
*
* @link https://en.wikipedia.org/wiki/United_Principalities
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateUnitedPrincipalitiesDay(): void
+ private function calculateUnitedPrincipalitiesDay(): void
{
// The law is official since 21.12.2014.
if ($this->year > 2014) {
$this->addHoliday(new Holiday('unitedPrincipalitiesDay', [
- 'en_US' => 'Union Day / Small Union',
- 'ro_RO' => 'Unirea Principatelor Române / Mica Unire'
+ 'en' => 'Union Day / Small Union',
+ 'ro' => 'Unirea Principatelor Române / Mica Unire',
], new DateTime("$this->year-01-24", new DateTimeZone($this->timezone)), $this->locale));
}
}
@@ -125,18 +129,20 @@ public function calculateUnitedPrincipalitiesDay(): void
*
* @link https://en.wikipedia.org/wiki/St._Andrew%27s_Day
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateStAndrewDay(): void
+ private function calculateStAndrewDay(): void
{
if ($this->year >= 2012) {
- $this->addHoliday(new Holiday('stAndrewDay', [
- 'en_US' => 'Saint Andrew\'s Day',
- 'ro_RO' => 'Sfântul Andrei'
- ], new DateTime($this->year . '-11-30', new DateTimeZone($this->timezone)), $this->locale));
+ $this->addHoliday(new Holiday(
+ 'stAndrewsDay',
+ [],
+ new DateTime($this->year . '-11-30', new DateTimeZone($this->timezone)),
+ $this->locale
+ ));
}
}
@@ -151,12 +157,12 @@ public function calculateStAndrewDay(): void
* @link https://en.wikipedia.org/wiki/Great_Union_Day
* @link https://ro.wikipedia.org/wiki/Ziua_na%C8%9Bional%C4%83_a_Rom%C3%A2niei
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateNationalDay(): void
+ private function calculateNationalDay(): void
{
$national_day = null;
@@ -173,10 +179,10 @@ public function calculateNationalDay(): void
$national_day = "$this->year-05-10";
}
- if (null !== $national_day) {
+ if (\is_string($national_day)) {
$this->addHoliday(new Holiday('nationalDay', [
- 'en_US' => 'National Day',
- 'ro_RO' => 'Ziua Națională'
+ 'en' => 'National Day',
+ 'ro' => 'Ziua Națională',
], new DateTime($national_day, new DateTimeZone($this->timezone)), $this->locale));
}
}
@@ -187,19 +193,19 @@ public function calculateNationalDay(): void
* Constantin Brâncuși (February 19, 1876 – March 16, 1957) was a Romanian sculptor, painter and photographer.
*
* @link https://en.wikipedia.org/wiki/Constantin_Br%C3%A2ncu%C8%99i
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateConstantinBrancusiDay(): void
+ private function calculateConstantinBrancusiDay(): void
{
if ($this->year >= 2016) {
$this->addHoliday(new Holiday(
'constantinBrancusiDay',
[
- 'en_US' => 'Constantin Brâncuși day',
- 'ro_RO' => 'Ziua Constantin Brâncuși'
+ 'en' => 'Constantin Brâncuși day',
+ 'ro' => 'Ziua Constantin Brâncuși',
],
new DateTime("$this->year-02-19", new DateTimeZone($this->timezone)),
$this->locale,
@@ -215,20 +221,20 @@ public function calculateConstantinBrancusiDay(): void
* according to the Law 220/2016 (18.11.2016)
*
* @link https://en.wikipedia.org/wiki/Children%27s_Day
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
* @throws \Exception
*/
- public function calculateChildrensDay(): void
+ private function calculateChildrensDay(): void
{
if ($this->year >= 1950 && $this->year <= 2016) {
$this->addHoliday(new Holiday(
'childrensDay',
[
- 'en_US' => 'International Children\'s Day',
- 'ro_RO' => 'Ziua Copilului'
+ 'en' => 'International Children\'s Day',
+ 'ro' => 'Ziua Copilului',
],
new DateTime("$this->year-06-01", new DateTimeZone($this->timezone)),
$this->locale,
@@ -238,17 +244,17 @@ public function calculateChildrensDay(): void
if ($this->year >= 2017) {
$this->addHoliday(new Holiday('childrensDay', [
- 'en_US' => 'International Children\'s Day',
- 'ro_RO' => 'Ziua Copilului'
+ 'en' => 'International Children\'s Day',
+ 'ro' => 'Ziua Copilului',
], new DateTime("$this->year-06-01", new DateTimeZone($this->timezone)), $this->locale));
}
}
/**
- * @param int $year
+ * @param int $year
* @param string $timezone
*
- * @return \DateTime
+ * @return DateTime
*
* @throws \Exception
*/
diff --git a/src/Yasumi/Provider/Russia.php b/src/Yasumi/Provider/Russia.php
index 184056835..61393d8df 100644
--- a/src/Yasumi/Provider/Russia.php
+++ b/src/Yasumi/Provider/Russia.php
@@ -1,4 +1,4 @@
-addHoliday(new Holiday('newYearHolidaysDay' . $day, [
- 'en_US' => 'New Year\'s holidays',
- 'ru_RU' => 'Новогодние каникулы'
+ 'en' => 'New Year\'s holidays',
+ 'ru' => 'Новогодние каникулы',
], new \DateTime("{$this->year}-01-{$day}", new \DateTimeZone($this->timezone)), $this->locale));
}
}
@@ -80,8 +80,8 @@ private function addNewYearsHolidays(): void
private function addOrthodoxChristmasDay(): void
{
$this->addHoliday(new Holiday('orthodoxChristmasDay', [
- 'en_US' => 'Orthodox Christmas Day',
- 'ru_RU' => 'Рождество'
+ 'en' => 'Orthodox Christmas Day',
+ 'ru' => 'Рождество',
], new \DateTime("{$this->year}-01-07", new \DateTimeZone($this->timezone)), $this->locale));
}
@@ -96,8 +96,8 @@ private function addDefenceOfTheFatherlandDay(): void
}
$this->addHoliday(new Holiday('defenceOfTheFatherlandDay', [
- 'en_US' => 'Defence of the Fatherland Day',
- 'ru_RU' => 'День защитника Отечества'
+ 'en' => 'Defence of the Fatherland Day',
+ 'ru' => 'День защитника Отечества',
], new \DateTime("{$this->year}-02-23", new \DateTimeZone($this->timezone)), $this->locale));
}
@@ -117,8 +117,8 @@ private function addInternationalWomensDay(): void
private function addSpringAndLabourDay(): void
{
$this->addHoliday(new Holiday('springAndLabourDay', [
- 'en_US' => 'Spring and Labour Day',
- 'ru_RU' => 'Праздник Весны и Труда'
+ 'en' => 'Spring and Labour Day',
+ 'ru' => 'Праздник Весны и Труда',
], new \DateTime("{$this->year}-05-01", new \DateTimeZone($this->timezone)), $this->locale));
}
@@ -129,8 +129,8 @@ private function addSpringAndLabourDay(): void
private function addVictoryDay(): void
{
$this->addHoliday(new Holiday('victoryDay', [
- 'en_US' => 'Victory Day',
- 'ru_RU' => 'День Победы'
+ 'en' => 'Victory Day',
+ 'ru' => 'День Победы',
], new \DateTime("{$this->year}-05-09", new \DateTimeZone($this->timezone)), $this->locale));
}
@@ -145,8 +145,8 @@ private function addRussiaDay(): void
}
$this->addHoliday(new Holiday('russiaDay', [
- 'en_US' => 'Russia Day',
- 'ru_RU' => 'День России'
+ 'en' => 'Russia Day',
+ 'ru' => 'День России',
], new \DateTime("{$this->year}-06-12", new \DateTimeZone($this->timezone)), $this->locale));
}
@@ -161,8 +161,8 @@ private function addUnityDay(): void
}
$this->addHoliday(new Holiday('unityDay', [
- 'en_US' => 'Unity Day',
- 'ru_RU' => 'День народного единства'
+ 'en' => 'Unity Day',
+ 'ru' => 'День народного единства',
], new \DateTime("{$this->year}-11-04", new \DateTimeZone($this->timezone)), $this->locale));
}
}
diff --git a/src/Yasumi/Provider/Slovakia.php b/src/Yasumi/Provider/Slovakia.php
index 1d85b7776..79d9773e1 100644
--- a/src/Yasumi/Provider/Slovakia.php
+++ b/src/Yasumi/Provider/Slovakia.php
@@ -1,4 +1,4 @@
-timezone = 'Europe/Bratislava';
// 1.1.
- $this->addHoliday($this->newYearsDay($this->year, $this->timezone, $this->locale));
+ $this->calculateSlovakIndependenceDay();
// 6.1.
$this->addHoliday($this->epiphany($this->year, $this->timezone, $this->locale, Holiday::TYPE_BANK));
// 1.5.
@@ -104,6 +106,30 @@ public function initialize(): void
$this->addHoliday($this->easterMonday($this->year, $this->timezone, $this->locale, Holiday::TYPE_BANK));
}
+
+ /**
+ * New Year's Day
+ *
+ * @see https://en.wikipedia.org/wiki/Public_holidays_in_Slovakia
+ *
+ * @throws InvalidDateException
+ * @throws \InvalidArgumentException
+ * @throws UnknownLocaleException
+ * @throws \Exception
+ */
+ private function calculateSlovakIndependenceDay(): void
+ {
+ $this->addHoliday(new Holiday(
+ 'slovakIndependenceDay',
+ [
+ 'sk' => 'Deň vzniku Slovenskej republiky',
+ 'en' => 'Day of the Establishment of the Slovak Republic',
+ ],
+ new DateTime($this->year . '-01-01', new DateTimeZone($this->timezone)),
+ $this->locale
+ ));
+ }
+
/**
* Saints Cyril and Methodius Day
*
@@ -111,19 +137,19 @@ public function initialize(): void
*
* Note: this holiday is common for Czech republic and Slovakia.
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateSaintsCyrilAndMethodiusDay(): void
+ private function calculateSaintsCyrilAndMethodiusDay(): void
{
$this->addHoliday(new Holiday(
'saintsCyrilAndMethodiusDay',
[
- 'sk_SK' => 'Sviatok svätého Cyrila a Metoda',
- 'cs_CZ' => 'Den slovanských věrozvěstů Cyrila a Metoděje',
- 'en_US' => 'Saints Cyril and Methodius Day',
+ 'sk' => 'Sviatok svätého Cyrila a Metoda',
+ 'cs' => 'Den slovanských věrozvěstů Cyrila a Metoděje',
+ 'en' => 'Saints Cyril and Methodius Day',
],
new DateTime($this->year . '-07-05', new DateTimeZone($this->timezone)),
$this->locale,
@@ -136,18 +162,18 @@ public function calculateSaintsCyrilAndMethodiusDay(): void
*
* @see https://en.wikipedia.org/wiki/Slovak_National_Uprising
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateSlovakNationalUprisingDay(): void
+ private function calculateSlovakNationalUprisingDay(): void
{
$this->addHoliday(new Holiday(
'slovakNationalUprisingDay',
[
- 'sk_SK' => 'Výročie Slovenského národného povstania',
- 'en_US' => 'Slovak National Uprising Day',
+ 'sk' => 'Výročie Slovenského národného povstania',
+ 'en' => 'Slovak National Uprising Day',
],
new DateTime($this->year . '-08-29', new DateTimeZone($this->timezone)),
$this->locale,
@@ -160,18 +186,18 @@ public function calculateSlovakNationalUprisingDay(): void
*
* @see https://en.wikipedia.org/wiki/Constitution_of_Slovakia
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateSlovakConstitutionDay(): void
+ private function calculateSlovakConstitutionDay(): void
{
$this->addHoliday(new Holiday(
'slovakConstitutionDay',
[
- 'sk_SK' => 'Deň Ústavy Slovenskej republiky',
- 'en_US' => 'Day of the Constitution of the Slovak Republic',
+ 'sk' => 'Deň Ústavy Slovenskej republiky',
+ 'en' => 'Day of the Constitution of the Slovak Republic',
],
new DateTime($this->year . '-09-01', new DateTimeZone($this->timezone)),
$this->locale,
@@ -188,16 +214,16 @@ public function calculateSlovakConstitutionDay(): void
* @see https://en.wikipedia.org/wiki/Our_Lady_of_Sorrows
* @see https://sk.wikipedia.org/wiki/Sedembolestn%C3%A1_Panna_M%C3%A1ria
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateOurLadyOfSorrowsDay(): void
+ private function calculateOurLadyOfSorrowsDay(): void
{
$this->addHoliday(new Holiday('ourLadyOfSorrowsDay', [
- 'sk_SK' => 'Sviatok Sedembolestnej Panny Márie',
- 'en_US' => 'Our Lady of Sorrows Day',
+ 'sk' => 'Sviatok Sedembolestnej Panny Márie',
+ 'en' => 'Our Lady of Sorrows Day',
], new DateTime($this->year . '-09-15', new DateTimeZone($this->timezone)), $this->locale, Holiday::TYPE_BANK));
}
@@ -206,19 +232,19 @@ public function calculateOurLadyOfSorrowsDay(): void
*
* Note: this national day is common for Czech republic and Slovakia.
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateStruggleForFreedomAndDemocracyDay(): void
+ private function calculateStruggleForFreedomAndDemocracyDay(): void
{
$this->addHoliday(new Holiday(
'struggleForFreedomAndDemocracyDay',
[
- 'sk_SK' => 'Deň boja za slobodu a demokraciu',
- 'cs_CZ' => 'Den boje za svobodu a demokracii',
- 'en_US' => 'Struggle for Freedom and Democracy Day',
+ 'sk' => 'Deň boja za slobodu a demokraciu',
+ 'cs' => 'Den boje za svobodu a demokracii',
+ 'en' => 'Struggle for Freedom and Democracy Day',
],
new DateTime($this->year . '-11-17', new DateTimeZone($this->timezone)),
$this->locale,
diff --git a/src/Yasumi/Provider/SouthAfrica.php b/src/Yasumi/Provider/SouthAfrica.php
index 0be7ab47d..15e9f7422 100644
--- a/src/Yasumi/Provider/SouthAfrica.php
+++ b/src/Yasumi/Provider/SouthAfrica.php
@@ -1,4 +1,4 @@
-addHoliday(new Holiday(
'humanRightsDay',
- ['en_ZA' => 'Human Rights Day'],
+ ['en' => 'Human Rights Day'],
new DateTime($this->year . '-3-21', new DateTimeZone($this->timezone)),
$this->locale
));
@@ -107,18 +110,18 @@ public function calculateHumanRightsDay(): void
*
* Family Day in South Africa takes place on the Monday following Easter Sunday.
*
- * @link http://www.gov.za/sites/www.gov.za/files/Act36of1994.pdf
+ * @link https://www.gov.za/documents/public-holidays-act
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateFamilyDay(): void
+ private function calculateFamilyDay(): void
{
$this->addHoliday(new Holiday(
'familyDay',
- ['en_ZA' => 'Family Day'],
+ ['en' => 'Family Day'],
$this->calculateEaster($this->year, $this->timezone)->add(new DateInterval('P1D')),
$this->locale
));
@@ -129,19 +132,19 @@ public function calculateFamilyDay(): void
*
* Freedom Day commemorates the first democratic elections held in South Africa on 27 April 1994.
*
- * @link http://www.gov.za/sites/www.gov.za/files/Act36of1994.pdf
- * @link http://www.gov.za/freedom-day-2014
+ * @link https://www.gov.za/documents/public-holidays-act
+ * @link https://www.gov.za/freedom-day-2014
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateFreedomDay(): void
+ private function calculateFreedomDay(): void
{
$this->addHoliday(new Holiday(
'freedomDay',
- ['en_ZA' => 'Freedom Day'],
+ ['en' => 'Freedom Day'],
new DateTime($this->year . '-4-27', new DateTimeZone($this->timezone)),
$this->locale
));
@@ -156,19 +159,19 @@ public function calculateFreedomDay(): void
* police, and the violence that ensued during the next few weeks, approximately 700 hundred people, many of them
* youths, were killed and property destroyed. Youth Day, previously known as Soweto Day, commemorates these events.
*
- * @link http://www.gov.za/sites/www.gov.za/files/Act36of1994.pdf
- * @link http://www.gov.za/youth-day-2014
+ * @link https://www.gov.za/documents/public-holidays-act
+ * @link https://www.gov.za/youth-day-2014
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateYouthDay(): void
+ private function calculateYouthDay(): void
{
$this->addHoliday(new Holiday(
'youthDay',
- ['en_ZA' => 'Youth Day'],
+ ['en' => 'Youth Day'],
new DateTime($this->year . '-6-16', new DateTimeZone($this->timezone)),
$this->locale
));
@@ -180,22 +183,22 @@ public function calculateYouthDay(): void
* President Jacob Zuma has declared 3 August 2016, the date of the 2016 Municipal Elections, a public holiday. The
* purpose is to enable all South Africans who are eligible to vote to exercise their right on 3 August 2016.
*
- * @link http://www.gov.za/speeches/president-jacob-zuma-declares-3-august-2016-public-holiday-24-jun-2016-0000
+ * @link https://www.gov.za/speeches/president-jacob-zuma-declares-3-august-2016-public-holiday-24-jun-2016-0000
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculate2016MunicipalElectionsDay(): void
+ private function calculate2016MunicipalElectionsDay(): void
{
- if ($this->year !== 2016) {
+ if (2016 !== $this->year) {
return;
}
$this->addHoliday(new Holiday(
'2016MunicipalElectionsDay',
- ['en_ZA' => '2016 Municipal Elections Day'],
+ ['en' => '2016 Municipal Elections Day'],
new DateTime('2016-8-3', new DateTimeZone($this->timezone)),
$this->locale
));
@@ -208,19 +211,19 @@ public function calculate2016MunicipalElectionsDay(): void
* (legislation that required African persons to carry a document on them to 'prove' that they were allowed to enter
* a 'white area').
*
- * @link http://www.gov.za/about-sa/public-holidays#women
- * @link http://www.gov.za/womens-day
+ * @link https://www.gov.za/about-sa/public-holidays#women
+ * @link https://www.gov.za/womens-day
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateNationalWomensDay(): void
+ private function calculateNationalWomensDay(): void
{
$this->addHoliday(new Holiday(
'nationalWomensDay',
- ['en_ZA' => 'National Women\'s Day'],
+ ['en' => 'National Women\'s Day'],
new DateTime($this->year . '-8-9', new DateTimeZone($this->timezone)),
$this->locale
));
@@ -233,19 +236,19 @@ public function calculateNationalWomensDay(): void
* Africans celebrate the day by remembering the cultural heritage of the many cultures that make up the population
* of South Africa.
*
- * @link http://www.gov.za/sites/www.gov.za/files/Act36of1994.pdf
- * @link http://www.gov.za/heritage-day-2014
+ * @link https://www.gov.za/documents/public-holidays-act
+ * @link https://www.gov.za/heritage-day-2014
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateHeritageDay(): void
+ private function calculateHeritageDay(): void
{
$this->addHoliday(new Holiday(
'heritageDay',
- ['en_ZA' => 'Heritage Day'],
+ ['en' => 'Heritage Day'],
new DateTime($this->year . '-9-24', new DateTimeZone($this->timezone)),
$this->locale
));
@@ -260,19 +263,19 @@ public function calculateHeritageDay(): void
* of democracy in South Africa 16 December retained its status as a public holiday, however, this time with the
* purpose of fostering reconciliation and national unity.
*
- * @link http://www.gov.za/sites/www.gov.za/files/Act36of1994.pdf
- * @link http://www.gov.za/day-reconciliation-2014
+ * @link https://www.gov.za/documents/public-holidays-act
+ * @link https://www.gov.za/day-reconciliation-2014
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateDayOfReconciliation(): void
+ private function calculateDayOfReconciliation(): void
{
$this->addHoliday(new Holiday(
'reconciliationDay',
- ['en_ZA' => 'Day of Reconciliation'],
+ ['en' => 'Day of Reconciliation'],
new DateTime($this->year . '-12-16', new DateTimeZone($this->timezone)),
$this->locale
));
@@ -287,22 +290,22 @@ public function calculateDayOfReconciliation(): void
* Note: Not entirely sure if this is a common rule as the Public Holidays Act doesn't mention such specific
* situation.
*
- * @link http://www.gov.za/sites/www.gov.za/files/Act36of1994.pdf
+ * @link https://www.gov.za/documents/public-holidays-act
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateSubstituteDayOfGoodwill(): void
+ private function calculateSubstituteDayOfGoodwill(): void
{
- if ($this->year !== 2016) {
+ if (2016 !== $this->year) {
return;
}
$this->addHoliday(new Holiday(
'substituteDayOfGoodwill',
- ['en_ZA' => 'Day of Goodwill observed'],
+ ['en' => 'Day of Goodwill observed'],
new DateTime('2016-12-27', new DateTimeZone($this->timezone)),
$this->locale
));
@@ -314,38 +317,27 @@ public function calculateSubstituteDayOfGoodwill(): void
* The Public Holidays Act (Act No 36 of 1994) determines whenever any public holiday falls on a Sunday, the Monday
* following on it shall be a public holiday.
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
private function calculateSubstituteHolidays(): void
{
- $datesIterator = $this->getIterator();
-
// Loop through all defined holidays
- while ($datesIterator->valid()) {
-
- // Exclude Good Friday, Family Day, 2016 Municipal Elections Day as these don't fall in the weekend
- if (\in_array(
- $datesIterator->current()->shortName,
- ['goodFriday', 'familyDay', '2016MunicipalElectionsDay'],
- true
- )) {
- $datesIterator->next();
- }
-
+ foreach ($this->getHolidays() as $holiday) {
// Substitute holiday is on a Monday in case the holiday falls on a Sunday
- if (0 === (int)$datesIterator->current()->format('w')) {
- $substituteHoliday = clone $datesIterator->current();
- $substituteHoliday->add(new DateInterval('P1D'));
+ if (0 === (int)$holiday->format('w')) {
+ $date = clone $holiday;
+ $date->add(new DateInterval('P1D'));
- $this->addHoliday(new Holiday('substituteHoliday:' . $substituteHoliday->shortName, [
- 'en_ZA' => $substituteHoliday->getName() . ' observed',
- ], $substituteHoliday, $this->locale));
+ $this->addHoliday(new SubstituteHoliday(
+ $holiday,
+ [],
+ $date,
+ $this->locale
+ ));
}
-
- $datesIterator->next();
}
}
}
diff --git a/src/Yasumi/Provider/SouthKorea.php b/src/Yasumi/Provider/SouthKorea.php
new file mode 100644
index 000000000..94886454a
--- /dev/null
+++ b/src/Yasumi/Provider/SouthKorea.php
@@ -0,0 +1,523 @@
+
+ */
+
+namespace Yasumi\Provider;
+
+use DateInterval;
+use DateTime;
+use DateTimeZone;
+use Yasumi\Exception\InvalidDateException;
+use Yasumi\Exception\UnknownLocaleException;
+use Yasumi\Holiday;
+use Yasumi\SubstituteHoliday;
+
+/**
+ * Provider for all holidays in the South Korea except for election day and temporary public holiday.
+ *
+ * @link https://en.wikipedia.org/wiki/Public_holidays_in_South_Korea
+ */
+class SouthKorea extends AbstractProvider
+{
+ use CommonHolidays, ChristianHolidays;
+
+ /**
+ * Code to identify this Holiday Provider. Typically this is the ISO3166 code corresponding to the respective
+ * country or sub-region.
+ */
+ public const ID = 'KR';
+
+ /**
+ * Dates in Gregorian calendar of Seollal, Buddha's Birthday, and Chuseok (~ 2050)
+ *
+ * The Korean calendar is derived from the Chinese calendar. Although not being an official calendar, the
+ * traditional Korean calendar is still maintained by the government. The current version is based on China's
+ * Shixian calendar, which was in turn developed by Jesuit scholars. However, because the Korean calendar is now
+ * based on the moon's shape seen from Korea, occasionally the calendar diverges from the traditional Chinese
+ * calendar by one day, even though the underlying rule is the same.
+ * @link https://en.wikipedia.org/wiki/Korean_calendar
+ *
+ * To convert from lunar calendar to Gregorian calendar, lunar observation is necessary.
+ * There is no perfect formula, and as it moves away from the current date, the error becomes bigger.
+ * Korea Astronomy and Space Science Institute (KASI) is supporting the converter until 2050.
+ * For more information, please refer to the paper below.
+ * 박한얼, 민병희, 안영숙,(2017).한국 음력의 운용과 계산법 연구.천문학논총,32(3),407-420.
+ * @link https://www.kasi.re.kr/kor/research/paper/20170259 - Korea Astronomy and Space Science Institute
+ */
+ public const LUNAR_HOLIDAY = [
+ 'seollal' => [
+ 1985 => '1985-2-20', 1986 => '1986-2-9', 1987 => '1987-1-29', 1988 => '1988-2-18', 1989 => '1989-2-6',
+ 1990 => '1990-1-27', 1991 => '1991-2-15', 1992 => '1992-2-4', 1993 => '1993-1-23', 1994 => '1994-2-10',
+ 1995 => '1995-1-31', 1996 => '1996-2-19', 1997 => '1997-2-8', 1998 => '1998-1-28', 1999 => '1999-2-16',
+ 2000 => '2000-2-5', 2001 => '2001-1-24', 2002 => '2002-2-12', 2003 => '2003-2-1', 2004 => '2004-1-22',
+ 2005 => '2005-2-9', 2006 => '2006-1-29', 2007 => '2007-2-18', 2008 => '2008-2-7', 2009 => '2009-1-26',
+ 2010 => '2010-2-14', 2011 => '2011-2-3', 2012 => '2012-1-23', 2013 => '2013-2-10', 2014 => '2014-1-31',
+ 2015 => '2015-2-19', 2016 => '2016-2-8', 2017 => '2017-1-28', 2018 => '2018-2-16', 2019 => '2019-2-5',
+ 2020 => '2020-1-25', 2021 => '2021-2-12', 2022 => '2022-2-1', 2023 => '2023-1-22', 2024 => '2024-2-10',
+ 2025 => '2025-1-29', 2026 => '2026-2-17', 2027 => '2027-2-7', 2028 => '2028-1-27', 2029 => '2029-2-13',
+ 2030 => '2030-2-3', 2031 => '2031-1-23', 2032 => '2032-2-11', 2033 => '2033-1-31', 2034 => '2034-2-19',
+ 2035 => '2035-2-8', 2036 => '2036-1-28', 2037 => '2037-2-15', 2038 => '2038-2-4', 2039 => '2037-1-24',
+ 2040 => '2040-2-12', 2041 => '2041-2-1', 2042 => '2042-1-22', 2043 => '2043-2-10', 2044 => '2044-1-30',
+ 2045 => '2045-2-17', 2046 => '2046-2-6', 2047 => '2047-1-26', 2048 => '2048-2-14', 2049 => '2049-2-2',
+ 2050 => '2050-1-23',
+ ],
+ 'buddhasBirthday' => [
+ 1975 => '1975-5-18', 1976 => '1976-5-6', 1977 => '1977-5-25', 1978 => '1978-5-14', 1979 => '1979-5-3',
+ 1980 => '1980-5-21', 1981 => '1981-5-11', 1982 => '1982-5-1', 1983 => '1983-5-20', 1984 => '1984-5-8',
+ 1985 => '1985-5-27', 1986 => '1986-5-16', 1987 => '1987-5-5', 1988 => '1988-5-23', 1989 => '1989-5-12',
+ 1990 => '1990-5-2', 1991 => '1991-5-21', 1992 => '1992-5-10', 1993 => '1993-5-28', 1994 => '1994-5-18',
+ 1995 => '1995-5-7', 1996 => '1996-5-24', 1997 => '1997-5-14', 1998 => '1998-5-3', 1999 => '1999-5-22',
+ 2000 => '2000-5-11', 2001 => '2001-4-30', 2002 => '2002-5-19', 2003 => '2003-5-8', 2004 => '2004-5-26',
+ 2005 => '2005-5-15', 2006 => '2006-5-5', 2007 => '2007-5-24', 2008 => '2008-5-12', 2009 => '2009-5-2',
+ 2010 => '2010-5-21', 2011 => '2011-5-10', 2012 => '2012-5-28', 2013 => '2013-5-17', 2014 => '2014-5-6',
+ 2015 => '2015-5-25', 2016 => '2016-5-14', 2017 => '2017-5-3', 2018 => '2018-5-22', 2019 => '2019-5-12',
+ 2020 => '2020-4-30', 2021 => '2021-5-19', 2022 => '2022-5-8', 2023 => '2023-5-27', 2024 => '2024-5-15',
+ 2025 => '2025-5-5', 2026 => '2026-5-24', 2027 => '2027-5-13', 2028 => '2028-5-2', 2029 => '2029-5-20',
+ 2030 => '2030-5-9', 2031 => '2031-5-28', 2032 => '2032-5-16', 2033 => '2033-5-6', 2034 => '2034-5-25',
+ 2035 => '2035-5-15', 2036 => '2036-5-3', 2037 => '2037-5-22', 2038 => '2038-5-11', 2039 => '2039-4-30',
+ 2040 => '2040-5-18', 2041 => '2041-5-7', 2042 => '2042-5-26', 2043 => '2043-5-16', 2044 => '2044-5-5',
+ 2045 => '2045-5-24', 2046 => '2046-5-13', 2047 => '2047-5-2', 2048 => '2048-5-20', 2049 => '2049-5-9',
+ 2050 => '2050-5-28',
+ ],
+ 'chuseok' => [
+ 1949 => '1949-10-6', 1950 => '1950-9-26', 1951 => '1951-9-15', 1952 => '1952-10-3', 1953 => '1953-9-22',
+ 1954 => '1954-9-11', 1955 => '1955-9-30', 1956 => '1956-9-19', 1957 => '1957-9-8', 1958 => '1958-9-27',
+ 1959 => '1959-9-17', 1960 => '1960-10-5', 1961 => '1961-9-24', 1962 => '1962-9-13', 1963 => '1963-10-2',
+ 1964 => '1964-9-20', 1965 => '1965-9-10', 1966 => '1966-9-29', 1967 => '1967-9-18', 1968 => '1968-10-6',
+ 1969 => '1969-9-26', 1970 => '1970-9-15', 1971 => '1971-10-3', 1972 => '1972-9-22', 1973 => '1973-9-11',
+ 1974 => '1974-9-30', 1975 => '1975-9-20', 1976 => '1976-9-8', 1977 => '1977-9-27', 1978 => '1978-9-17',
+ 1979 => '1979-10-5', 1980 => '1980-9-23', 1981 => '1981-9-12', 1982 => '1982-10-1', 1983 => '1983-9-21',
+ 1984 => '1984-9-10', 1985 => '1985-9-29', 1986 => '1986-9-18', 1987 => '1987-10-7', 1988 => '1988-9-25',
+ 1989 => '1989-9-14', 1990 => '1990-10-3', 1991 => '1991-9-22', 1992 => '1992-9-11', 1993 => '1993-9-30',
+ 1994 => '1994-9-20', 1995 => '1950-9-9', 1996 => '1996-9-27', 1997 => '1997-9-16', 1998 => '1998-10-5',
+ 1999 => '1999-9-24', 2000 => '2000-9-12', 2001 => '2001-10-1', 2002 => '2002-9-21', 2003 => '2003-9-11',
+ 2004 => '2004-9-28', 2005 => '2005-9-18', 2006 => '2006-10-6', 2007 => '2007-9-25', 2008 => '2008-9-14',
+ 2009 => '2009-10-3', 2010 => '2010-9-22', 2011 => '2011-9-12', 2012 => '2012-9-30', 2013 => '2013-9-19',
+ 2014 => '2014-9-8', 2015 => '2015-9-27', 2016 => '2016-9-15', 2017 => '2017-10-4', 2018 => '2018-9-24',
+ 2019 => '2019-9-13', 2020 => '2020-10-1', 2021 => '2021-9-21', 2022 => '2022-9-10', 2023 => '2023-9-29',
+ 2024 => '2024-9-17', 2025 => '2025-10-6', 2026 => '2026-9-25', 2027 => '2027-9-15', 2028 => '2028-10-3',
+ 2029 => '2029-9-22', 2030 => '2030-9-12', 2031 => '2031-10-1', 2032 => '2032-9-19', 2033 => '2033-9-8',
+ 2034 => '2034-9-27', 2035 => '2035-9-16', 2036 => '2036-10-4', 2037 => '2037-9-24', 2038 => '2038-9-13',
+ 2039 => '2039-10-2', 2040 => '2040-9-21', 2041 => '2041-9-10', 2042 => '2042-9-28', 2043 => '2043-9-17',
+ 2044 => '2044-10-5', 2045 => '2045-9-25', 2046 => '2046-9-15', 2047 => '2047-10-4', 2048 => '2048-9-22',
+ 2049 => '2049-9-11', 2050 => '2050-9-30',
+ ],
+ ];
+
+ /**
+ * Initialize holidays for South Korea.
+ *
+ * @throws InvalidDateException
+ * @throws \InvalidArgumentException
+ * @throws UnknownLocaleException
+ * @throws \Exception
+ */
+ public function initialize(): void
+ {
+ $this->timezone = 'Asia/Seoul';
+
+ // Add common holidays
+ $this->calculateNewYearsDay();
+ if ($this->year >= 1949) {
+ $this->addHoliday($this->christmasDay($this->year, $this->timezone, $this->locale));
+ }
+
+ // Calculate lunar holidays
+ $this->calculateSeollal();
+ $this->calculateBuddhasBirthday();
+ $this->calculateChuseok();
+
+ // Calculate other holidays
+ $this->calculateIndependenceMovementDay();
+ $this->calculateArborDay();
+ $this->calculateChildrensDay();
+ $this->calculateMemorialDay();
+ $this->calculateConstitutionDay();
+ $this->calculateLiberationDay();
+ $this->calculateArmedForcesDay();
+ $this->calculateNationalFoundationDay();
+ $this->calculateHangulDay();
+ $this->calculateSubstituteHolidays();
+ }
+
+ /**
+ * New Year's Day. New Year's Day is held on January 1st and established since 1950.
+ * From the enactment of the First Law to 1998, there was a two or three-day break in the New Year.
+ *
+ * @link https://en.wikipedia.org/wiki/New_Year%27s_Day#East_Asian
+ *
+ * @throws \Exception
+ */
+ public function calculateNewYearsDay(): void
+ {
+ if ($this->year >= 1950) {
+ $this->addHoliday($this->newYearsDay($this->year, $this->timezone, $this->locale));
+ if ($this->year <= 1998) {
+ $this->addHoliday(new Holiday(
+ 'dayAfterNewYearsDay',
+ [],
+ new DateTime("$this->year-1-2", new DateTimeZone($this->timezone)),
+ $this->locale
+ ));
+ }
+ if ($this->year <= 1990) {
+ $this->addHoliday(new Holiday(
+ 'twoDaysLaterNewYearsDay',
+ ['en' => 'Two Days Later New Year\'s Day', 'ko' => '새해 연휴'],
+ new DateTime("$this->year-1-3", new DateTimeZone($this->timezone)),
+ $this->locale
+ ));
+ }
+ }
+ }
+
+ /**
+ * Seollal (Korean New Year's Day).
+ * Seollal is held on the 1st day of the 1st lunar month and was established from 1985.
+ *
+ * @link https://en.wikipedia.org/wiki/Korean_New_Year
+ *
+ * @throws \Exception
+ */
+ public function calculateSeollal(): void
+ {
+ if ($this->year >= 1985 && isset(self::LUNAR_HOLIDAY['seollal'][$this->year])) {
+ $seollal = new DateTime(self::LUNAR_HOLIDAY['seollal'][$this->year], new DateTimeZone($this->timezone));
+ $this->addHoliday(new Holiday(
+ 'seollal',
+ ['en' => 'Seollal', 'ko' => '설날'],
+ $seollal,
+ $this->locale
+ ));
+ if ($this->year > 1989) {
+ $dayBeforeSeollal = clone $seollal;
+ $dayBeforeSeollal->sub(new DateInterval('P1D'));
+ $this->addHoliday(new Holiday(
+ 'dayBeforeSeollal',
+ ['en' => 'Day before Seollal', 'ko' => '설날 연휴'],
+ $dayBeforeSeollal,
+ $this->locale
+ ));
+ $dayAfterSeollal = clone $seollal;
+ $dayAfterSeollal->add(new DateInterval('P1D'));
+ $this->addHoliday(new Holiday(
+ 'dayAfterSeollal',
+ ['en' => 'Day after Seollal', 'ko' => '설날 연휴'],
+ $dayAfterSeollal,
+ $this->locale
+ ));
+ }
+ }
+ }
+
+ /**
+ * Buddha's Birthday is held on the 8th day of the 4th lunar month and was established since 1975.
+ *
+ * @link https://en.wikipedia.org/wiki/Buddha%27s_Birthday
+ *
+ * @throws \Exception
+ */
+ public function calculateBuddhasBirthday(): void
+ {
+ if ($this->year >= 1975 && isset(self::LUNAR_HOLIDAY['buddhasBirthday'][$this->year])) {
+ $this->addHoliday(new Holiday(
+ 'buddhasBirthday',
+ ['en' => 'Buddha\'s Birthday', 'ko' => '부처님오신날'],
+ new DateTime(self::LUNAR_HOLIDAY['buddhasBirthday'][$this->year], new DateTimeZone($this->timezone)),
+ $this->locale
+ ));
+ }
+ }
+
+ /**
+ * Chuseok (Korean Thanksgiving Day).
+ *
+ * Chuseok, one of the biggest holidays in Korea, is a major harvest festival and a three-day holiday celebrated on
+ * the 15th day of the 8th month of the lunar calendar on the full moon.
+ *
+ * @link https://en.wikipedia.org/wiki/Chuseok
+ *
+ * @throws \Exception
+ */
+ public function calculateChuseok(): void
+ {
+ if ($this->year >= 1949 && isset(self::LUNAR_HOLIDAY['chuseok'][$this->year])) {
+ // Chuseok
+ $chuseok = new Holiday(
+ 'chuseok',
+ ['en' => 'Chuseok', 'ko' => '추석'],
+ new DateTime(self::LUNAR_HOLIDAY['chuseok'][$this->year], new DateTimeZone($this->timezone)),
+ $this->locale
+ );
+ $this->addHoliday($chuseok);
+
+ // Day after Chuseok
+ if ($this->year >= 1986) {
+ $this->addHoliday(new Holiday(
+ 'dayAfterChuseok',
+ ['en' => 'Day after Chuseok', 'ko' => '추석 연휴'],
+ (clone $chuseok)->add(new DateInterval('P1D')),
+ $this->locale
+ ));
+ }
+
+ // Day before Chuseok
+ if ($this->year >= 1989) {
+ $this->addHoliday(new Holiday(
+ 'dayBeforeChuseok',
+ ['en' => 'Day before Chuseok', 'ko' => '추석 연휴'],
+ (clone $chuseok)->sub(new DateInterval('P1D')),
+ $this->locale
+ ));
+ }
+ }
+ }
+
+ /**
+ * Independence Movement Day. Independence Movement Day is held on March 1st and was established from 1949.
+ *
+ * @link https://en.wikipedia.org/wiki/Independence_Movement_Day
+ *
+ * @throws \Exception
+ */
+ public function calculateIndependenceMovementDay(): void
+ {
+ if ($this->year >= 1949) {
+ $this->addHoliday(new Holiday(
+ 'independenceMovementDay',
+ ['en' => 'Independence Movement Day', 'ko' => '삼일절'],
+ new DateTime("$this->year-3-1", new DateTimeZone($this->timezone)),
+ $this->locale
+ ));
+ }
+ }
+
+ /**
+ * Sikmogil (Arbor Day). Sikmogil is held on May 5th and established since 1949.
+ *
+ * @link https://en.wikipedia.org/wiki/Sikmogil
+ *
+ * @throws \Exception
+ */
+ public function calculateArborDay(): void
+ {
+ if (($this->year >= 1949 && $this->year < 1960) || ($this->year > 1960 && $this->year < 2006)) {
+ $this->addHoliday(new Holiday(
+ 'arborDay',
+ ['en' => 'Arbor Day', 'ko' => '식목일'],
+ new DateTime("$this->year-4-5", new DateTimeZone($this->timezone)),
+ $this->locale
+ ));
+ }
+ }
+
+ /**
+ * Children's Day. Children's Day is held on May 5th and established since 1970.
+ *
+ * @link https://en.wikipedia.org/wiki/Children%27s_Day#South_Korea
+ *
+ * @throws \Exception
+ */
+ public function calculateChildrensDay(): void
+ {
+ if ($this->year >= 1970) {
+ $this->addHoliday(new Holiday(
+ 'childrensDay',
+ ['en' => 'Children\'s Day', 'ko' => '어린이날'],
+ new DateTime("$this->year-5-5", new DateTimeZone($this->timezone)),
+ $this->locale
+ ));
+ }
+ }
+
+ /**
+ * Memorial Day. Memorial Day is held on June 6th and established since 1956.
+ *
+ * @link https://en.wikipedia.org/wiki/Memorial_Day_(South_Korea)
+ *
+ * @throws \Exception
+ */
+ public function calculateMemorialDay(): void
+ {
+ if ($this->year >= 1966) {
+ $this->addHoliday(new Holiday(
+ 'memorialDay',
+ ['en' => 'Memorial Day', 'ko' => '현충일'],
+ new DateTime("$this->year-6-6", new DateTimeZone($this->timezone)),
+ $this->locale
+ ));
+ }
+ }
+
+ /**
+ * Constitution Day.
+ *
+ * Constitution Day is held on July 17th and established since 1949.
+ * Officially, it is a strict national holiday, but government offices and banks work normally after 2008.
+ *
+ * @link https://en.wikipedia.org/wiki/Constitution_Day_(South_Korea)
+ *
+ * @throws \Exception
+ */
+ public function calculateConstitutionDay(): void
+ {
+ if ($this->year >= 1949 && $this->year < 2008) {
+ $this->addHoliday(new Holiday(
+ 'constitutionDay',
+ ['en' => 'Constitution Day', 'ko' => '제헌절'],
+ new DateTime("$this->year-7-17", new DateTimeZone($this->timezone)),
+ $this->locale
+ ));
+ }
+ }
+
+ /**
+ * Liberation Day. Liberation Day is held on August 15th and established since 1949.
+ *
+ * @link https://en.wikipedia.org/wiki/National_Liberation_Day_of_Korea
+ *
+ * @throws \Exception
+ */
+ public function calculateLiberationDay(): void
+ {
+ if ($this->year >= 1949) {
+ $this->addHoliday(new Holiday(
+ 'liberationDay',
+ ['en' => 'Liberation Day', 'ko' => '광복절'],
+ new DateTime("$this->year-8-15", new DateTimeZone($this->timezone)),
+ $this->locale
+ ));
+ }
+ }
+
+ /**
+ * Armed Forces Day. Armed Forces Day is held on October 1st and established since 1956.
+ *
+ * @link https://en.wikipedia.org/wiki/Armed_Forces_Day_(South_Korea)
+ *
+ * @throws \Exception
+ */
+ public function calculateArmedForcesDay(): void
+ {
+ if ($this->year >= 1956 && $this->year <= 1990) {
+ $this->addHoliday(new Holiday(
+ 'armedForcesDay',
+ ['en' => 'Armed Forces Day', 'ko' => '국군의 날'],
+ new DateTime("$this->year-10-1", new DateTimeZone($this->timezone)),
+ $this->locale
+ ));
+ }
+ }
+
+ /**
+ * Gaecheonjeol (National Foundation Day). Gaecheonjeol is held on October 3rd and established since 1949.
+ *
+ * @link https://en.wikipedia.org/wiki/Gaecheonjeol
+ *
+ * @throws \Exception
+ */
+ public function calculateNationalFoundationDay(): void
+ {
+ if ($this->year >= 1949) {
+ $this->addHoliday(new Holiday(
+ 'nationalFoundationDay',
+ ['en' => 'National Foundation Day', 'ko' => '개천절'],
+ new DateTime("$this->year-10-3", new DateTimeZone($this->timezone)),
+ $this->locale
+ ));
+ }
+ }
+
+ /**
+ * Hangul Day. Hangul Day is held on October 9th and established since 1949.
+ *
+ * @link https://en.wikipedia.org/wiki/Hangul_Day
+ *
+ * @throws \Exception
+ */
+ public function calculateHangulDay(): void
+ {
+ if (($this->year >= 1949 && $this->year <= 1990) || $this->year > 2012) {
+ $this->addHoliday(new Holiday(
+ 'hangulDay',
+ ['en' => 'Hangul Day', 'ko' => '한글날'],
+ new DateTime("$this->year-10-9", new DateTimeZone($this->timezone)),
+ $this->locale
+ ));
+ }
+ }
+
+ /**
+ * Substitute Holidays.
+ * related statutes: Article 3 Alternative Statutory Holidays of the Regulations on Holidays of Government Offices
+ *
+ * Since 2014, it has been applied only on Seollal, Chuseok and Children's Day.
+ * Due to the lunar calendar, public holidays can overlap even if it's not a Sunday.
+ * When public holidays fall each other, the first non-public holiday after the holiday become as a public holiday.
+ * As an exception, Children's Day also applies on Saturday.
+ *
+ * @throws \Exception
+ */
+ public function calculateSubstituteHolidays(): void
+ {
+ if ($this->year > 2013) {
+ // Initialize holidays variable
+ $holidays = $this->getHolidays();
+ $acceptedHolidays = [
+ 'dayBeforeSeollal', 'seollal', 'dayAfterSeollal',
+ 'dayBeforeChuseok', 'chuseok', 'dayAfterChuseok',
+ 'childrensDay',
+ ];
+
+ // Loop through all holidays
+ foreach ($holidays as $shortName => $holiday) {
+ // Get list of holiday dates except this
+ $holidayDates = \array_map(static function ($holiday) use ($shortName) {
+ return $holiday->shortName === $shortName ? false : (string)$holiday;
+ }, $holidays);
+
+ // Only process accepted holidays and conditions
+ if (\in_array($shortName, $acceptedHolidays, true)
+ && (
+ 0 === (int)$holiday->format('w')
+ || \in_array($holiday, $holidayDates, false)
+ || (6 === (int)$holiday->format('w') && 'childrensDay' === $shortName)
+ )
+ ) {
+ $date = clone $holiday;
+
+ // Find next week day (not being another holiday)
+ while (0 === (int)$date->format('w')
+ || (6 === (int)$date->format('w') && 'childrensDay' === $shortName)
+ || \in_array($date, $holidayDates, false)) {
+ $date->add(new DateInterval('P1D'));
+ continue;
+ }
+
+ // Add a new holiday that is substituting the original holiday
+ $substitute = new SubstituteHoliday(
+ $holiday,
+ [],
+ $date,
+ $this->locale
+ );
+
+ // Add a new holiday that is substituting the original holiday
+ $this->addHoliday($substitute);
+
+ // Add substitute holiday to the list
+ $holidays[] = $substitute;
+ }
+ }
+ }
+ }
+}
diff --git a/src/Yasumi/Provider/Spain.php b/src/Yasumi/Provider/Spain.php
index 27154b754..5f235d330 100755
--- a/src/Yasumi/Provider/Spain.php
+++ b/src/Yasumi/Provider/Spain.php
@@ -1,4 +1,4 @@
-year >= 1981) {
$this->addHoliday(new Holiday(
'nationalDay',
- ['es_ES' => 'Fiesta Nacional de España'],
+ ['es' => 'Fiesta Nacional de España'],
new DateTime("$this->year-10-12", new DateTimeZone($this->timezone)),
$this->locale
));
@@ -95,19 +97,19 @@ public function calculateNationalDay(): void
* 1978. In this referendum, a new constitution was approved. This was an important step in Spain's transition to
* becoming a constitutional monarchy and democracy.
*
- * @link http://www.timeanddate.com/holidays/spain/constitution-day
+ * @link https://www.timeanddate.com/holidays/spain/constitution-day
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateConstitutionDay(): void
+ private function calculateConstitutionDay(): void
{
if ($this->year >= 1978) {
$this->addHoliday(new Holiday(
'constitutionDay',
- ['es_ES' => 'Día de la Constitución'],
+ ['es' => 'Día de la Constitución'],
new DateTime("$this->year-12-6", new DateTimeZone($this->timezone)),
$this->locale
));
diff --git a/src/Yasumi/Provider/Spain/Andalusia.php b/src/Yasumi/Provider/Spain/Andalusia.php
index 393d06d95..a83456f93 100755
--- a/src/Yasumi/Provider/Spain/Andalusia.php
+++ b/src/Yasumi/Provider/Spain/Andalusia.php
@@ -1,4 +1,4 @@
-year >= 1980) {
$this->addHoliday(new Holiday(
'andalusiaDay',
- ['es_ES' => 'Día de Andalucía'],
+ ['es' => 'Día de Andalucía'],
new DateTime("$this->year-2-28", new DateTimeZone($this->timezone)),
$this->locale
));
diff --git a/src/Yasumi/Provider/Spain/Aragon.php b/src/Yasumi/Provider/Spain/Aragon.php
index 0ba419e3b..4456608a1 100755
--- a/src/Yasumi/Provider/Spain/Aragon.php
+++ b/src/Yasumi/Provider/Spain/Aragon.php
@@ -1,4 +1,4 @@
-year >= 1984) {
$this->addHoliday(new Holiday(
'asturiasDay',
- ['es_ES' => 'Día de Asturias'],
+ ['es' => 'Día de Asturias'],
new DateTime("$this->year-9-8", new DateTimeZone($this->timezone)),
$this->locale
));
diff --git a/src/Yasumi/Provider/Spain/BalearicIslands.php b/src/Yasumi/Provider/Spain/BalearicIslands.php
index 24c2d491b..dc6466a91 100755
--- a/src/Yasumi/Provider/Spain/BalearicIslands.php
+++ b/src/Yasumi/Provider/Spain/BalearicIslands.php
@@ -1,4 +1,4 @@
-year >= 1983) {
$this->addHoliday(new Holiday(
'balearicIslandsDay',
- ['es_ES' => 'Día de les Illes Balears'],
+ ['es' => 'Día de les Illes Balears'],
new DateTime("$this->year-3-1", new DateTimeZone($this->timezone)),
$this->locale
));
diff --git a/src/Yasumi/Provider/Spain/BasqueCountry.php b/src/Yasumi/Provider/Spain/BasqueCountry.php
index 0ab4d9e36..1db204f40 100755
--- a/src/Yasumi/Provider/Spain/BasqueCountry.php
+++ b/src/Yasumi/Provider/Spain/BasqueCountry.php
@@ -1,4 +1,4 @@
-year >= 2011 && $this->year <= 2013) {
$this->addHoliday(new Holiday(
'basqueCountryDay',
- ['es_ES' => 'Euskadi Eguna'],
+ ['es' => 'Euskadi Eguna'],
new DateTime("$this->year-10-25", new DateTimeZone($this->timezone)),
$this->locale
));
diff --git a/src/Yasumi/Provider/Spain/CanaryIslands.php b/src/Yasumi/Provider/Spain/CanaryIslands.php
index 78b237648..84a33d556 100755
--- a/src/Yasumi/Provider/Spain/CanaryIslands.php
+++ b/src/Yasumi/Provider/Spain/CanaryIslands.php
@@ -1,4 +1,4 @@
-year >= 1984) {
$this->addHoliday(new Holiday(
'canaryIslandsDay',
- ['es_ES' => 'Día de las Canarias'],
+ ['es' => 'Día de las Canarias'],
new DateTime("$this->year-5-30", new DateTimeZone($this->timezone)),
$this->locale
));
diff --git a/src/Yasumi/Provider/Spain/Cantabria.php b/src/Yasumi/Provider/Spain/Cantabria.php
index c58b5ff82..c7fd37b68 100755
--- a/src/Yasumi/Provider/Spain/Cantabria.php
+++ b/src/Yasumi/Provider/Spain/Cantabria.php
@@ -1,4 +1,4 @@
-year >= 1967) {
$this->addHoliday(new Holiday(
'cantabriaDay',
- ['es_ES' => 'Día de Cantabria'],
+ ['es' => 'Día de Cantabria'],
new DateTime("second sunday of august $this->year", new DateTimeZone($this->timezone)),
$this->locale
));
diff --git a/src/Yasumi/Provider/Spain/CastileAndLeon.php b/src/Yasumi/Provider/Spain/CastileAndLeon.php
index 4f1126acb..2c9609b5c 100755
--- a/src/Yasumi/Provider/Spain/CastileAndLeon.php
+++ b/src/Yasumi/Provider/Spain/CastileAndLeon.php
@@ -1,4 +1,4 @@
-year >= 1976) {
$this->addHoliday(new Holiday(
'castileAndLeonDay',
- ['es_ES' => 'Día de Castilla y León'],
+ ['es' => 'Día de Castilla y León'],
new DateTime("$this->year-4-23", new DateTimeZone($this->timezone)),
$this->locale
));
diff --git a/src/Yasumi/Provider/Spain/CastillaLaMancha.php b/src/Yasumi/Provider/Spain/CastillaLaMancha.php
index bca90b1de..d3bd12912 100755
--- a/src/Yasumi/Provider/Spain/CastillaLaMancha.php
+++ b/src/Yasumi/Provider/Spain/CastillaLaMancha.php
@@ -1,4 +1,4 @@
-year >= 1984) {
$this->addHoliday(new Holiday(
'castillaLaManchaDay',
- ['es_ES' => 'Día de la Región Castilla-La Mancha'],
+ ['es' => 'Día de la Región Castilla-La Mancha'],
new DateTime("$this->year-5-31", new DateTimeZone($this->timezone)),
$this->locale
));
diff --git a/src/Yasumi/Provider/Spain/Catalonia.php b/src/Yasumi/Provider/Spain/Catalonia.php
index d0c4d1bb3..b7cba08c7 100755
--- a/src/Yasumi/Provider/Spain/Catalonia.php
+++ b/src/Yasumi/Provider/Spain/Catalonia.php
@@ -1,4 +1,4 @@
-year >= 1886) {
$this->addHoliday(new Holiday(
'nationalCataloniaDay',
- ['es_ES' => 'Diada Nacional de Catalunya'],
+ ['es' => 'Diada Nacional de Catalunya'],
new DateTime("$this->year-9-11", new DateTimeZone($this->timezone)),
$this->locale
));
diff --git a/src/Yasumi/Provider/Spain/Ceuta.php b/src/Yasumi/Provider/Spain/Ceuta.php
index a2d99f594..5c6c70bac 100755
--- a/src/Yasumi/Provider/Spain/Ceuta.php
+++ b/src/Yasumi/Provider/Spain/Ceuta.php
@@ -1,4 +1,4 @@
-year >= 1416) {
$this->addHoliday(new Holiday(
'ceutaDay',
- ['es_ES' => 'Día de Ceuta'],
+ ['es' => 'Día de Ceuta'],
new DateTime("$this->year-9-2", new DateTimeZone($this->timezone)),
$this->locale
));
diff --git a/src/Yasumi/Provider/Spain/CommunityOfMadrid.php b/src/Yasumi/Provider/Spain/CommunityOfMadrid.php
index ffae26b49..699b35de3 100755
--- a/src/Yasumi/Provider/Spain/CommunityOfMadrid.php
+++ b/src/Yasumi/Provider/Spain/CommunityOfMadrid.php
@@ -1,4 +1,4 @@
-addHoliday(new Holiday(
'dosdeMayoUprisingDay',
- ['es_ES' => 'Fiesta de la Comunidad de Madrid'],
+ ['es' => 'Fiesta de la Comunidad de Madrid'],
new DateTime("$this->year-5-2", new DateTimeZone($this->timezone)),
$this->locale
));
diff --git a/src/Yasumi/Provider/Spain/Extremadura.php b/src/Yasumi/Provider/Spain/Extremadura.php
index 2a47a2405..912778ccf 100755
--- a/src/Yasumi/Provider/Spain/Extremadura.php
+++ b/src/Yasumi/Provider/Spain/Extremadura.php
@@ -1,4 +1,4 @@
-year >= 1985) {
$this->addHoliday(new Holiday(
'extremaduraDay',
- ['es_ES' => 'Día de Extremadura'],
+ ['es' => 'Día de Extremadura'],
new DateTime("$this->year-9-8", new DateTimeZone($this->timezone)),
$this->locale
));
diff --git a/src/Yasumi/Provider/Spain/Galicia.php b/src/Yasumi/Provider/Spain/Galicia.php
index 383a47695..a03815983 100755
--- a/src/Yasumi/Provider/Spain/Galicia.php
+++ b/src/Yasumi/Provider/Spain/Galicia.php
@@ -1,4 +1,4 @@
-year >= 1991) {
$this->addHoliday(new Holiday('galicianLiteratureDay', [
- 'es_ES' => 'Día de las Letras Gallegas',
- 'gl_ES' => 'Día das Letras Galegas',
+ 'es' => 'Día de las Letras Gallegas',
+ 'gl' => 'Día das Letras Galegas',
], new DateTime("$this->year-5-17", new DateTimeZone($this->timezone)), $this->locale));
}
}
@@ -95,18 +97,18 @@ public function calculateGalicianLiteratureDay(): void
* Sunday. If July 25 falls on a Tuesday or Thursday, many businesses and organizations are also closed on Monday,
* July 24, or Friday, July 26. In the rest of Spain, July 25 is not a public holiday.
*
- * @link http://www.timeanddate.com/holidays/spain/santiago-apostle
+ * @link https://www.timeanddate.com/holidays/spain/santiago-apostle
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateStJamesDay(): void
+ private function calculateStJamesDay(): void
{
if ($this->year >= 2000) {
$this->addHoliday(new Holiday('stJamesDay', [
- 'es_ES' => 'Santiago Apostol',
+ 'es' => 'Santiago Apostol',
], new DateTime("$this->year-7-25", new DateTimeZone($this->timezone)), $this->locale));
}
}
diff --git a/src/Yasumi/Provider/Spain/LaRioja.php b/src/Yasumi/Provider/Spain/LaRioja.php
index 36bd6e973..488dcf66a 100755
--- a/src/Yasumi/Provider/Spain/LaRioja.php
+++ b/src/Yasumi/Provider/Spain/LaRioja.php
@@ -1,4 +1,4 @@
-year >= 1983) {
$this->addHoliday(new Holiday('laRiojaDay', [
- 'es_ES' => 'Día de La Rioja',
+ 'es' => 'Día de La Rioja',
], new DateTime("$this->year-6-9", new DateTimeZone($this->timezone)), $this->locale));
}
}
diff --git a/src/Yasumi/Provider/Spain/Melilla.php b/src/Yasumi/Provider/Spain/Melilla.php
index 44fe9fc74..4584a0cb2 100755
--- a/src/Yasumi/Provider/Spain/Melilla.php
+++ b/src/Yasumi/Provider/Spain/Melilla.php
@@ -1,4 +1,4 @@
-year >= 1983) {
$this->addHoliday(new Holiday('murciaDay', [
- 'es_ES' => 'Día de la Región de Murcia',
+ 'es' => 'Día de la Región de Murcia',
], new DateTime("$this->year-6-9", new DateTimeZone($this->timezone)), $this->locale));
}
}
diff --git a/src/Yasumi/Provider/Spain/ValencianCommunity.php b/src/Yasumi/Provider/Spain/ValencianCommunity.php
index c5a0b1582..24bc2566d 100755
--- a/src/Yasumi/Provider/Spain/ValencianCommunity.php
+++ b/src/Yasumi/Provider/Spain/ValencianCommunity.php
@@ -1,4 +1,4 @@
-year >= 1239) {
$this->addHoliday(new Holiday('valencianCommunityDay', [
- 'es_ES' => 'Día de la Comunidad Valenciana',
+ 'es' => 'Día de la Comunidad Valenciana',
], new DateTime("$this->year-10-9", new DateTimeZone($this->timezone)), $this->locale));
}
}
diff --git a/src/Yasumi/Provider/Sweden.php b/src/Yasumi/Provider/Sweden.php
index f8a6a1401..6df730215 100644
--- a/src/Yasumi/Provider/Sweden.php
+++ b/src/Yasumi/Provider/Sweden.php
@@ -1,4 +1,4 @@
-addHoliday($this->epiphany($this->year, $this->timezone, $this->locale));
+ $this->calculateEpiphanyEve();
+ $this->calculateWalpurgisEve();
$this->addHoliday($this->goodFriday($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->easter($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->easterMonday($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->ascensionDay($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->pentecost($this->year, $this->timezone, $this->locale));
- $this->calculateStJohnsDay(); // aka Midsummer's Day
- $this->calculateAllSaintsDay();
- $this->addHoliday($this->christmasEve($this->year, $this->timezone, $this->locale, Holiday::TYPE_OFFICIAL));
+ $this->calculateStJohnsHolidays(); // aka Midsummer
+ $this->calculateAllSaintsHolidays();
+ $this->addHoliday($this->christmasEve($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->christmasDay($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->secondChristmasDay($this->year, $this->timezone, $this->locale));
+ $this->addHoliday($this->newYearsEve($this->year, $this->timezone, $this->locale, Holiday::TYPE_OBSERVANCE));
+
// Calculate other holidays
$this->calculateNationalDay();
}
+ /**
+ * Epiphany Eve.
+ *
+ * Epiphany is a Christian feast day that celebrates the revelation of God the Son as a human being in Jesus Christ.
+ * The traditional date for the feast is January 6. In Sweden the holiday is celebrated on the evening before, also
+ * known as Twelfth Night.
+ *
+ * Epiphany Eve is often treated with the afternoon off, but this varies depending on employer.
+ *
+ * @link https://en.wikipedia.org/wiki/Twelfth_Night_(holiday)
+ *
+ * @throws InvalidDateException
+ * @throws UnknownLocaleException
+ * @throws \InvalidArgumentException
+ * @throws \Exception
+ */
+ public function calculateEpiphanyEve(): void
+ {
+ $this->addHoliday(new Holiday(
+ 'epiphanyEve',
+ [],
+ new DateTime("$this->year-1-5", new DateTimeZone($this->timezone)),
+ $this->locale,
+ Holiday::TYPE_OBSERVANCE
+ ));
+ }
+
+
+ /**
+ * Walpurgis Night.
+ *
+ * Walpurgis Night is the eve of the Christian feast day of Saint Walpurga, an 8th-century abbess in Francia.
+ * This feast commemorates the canonization of Saint Walpurga and the movement of her relics to Eichstätt,
+ * both of which occurred on 1 May 870
+ *
+ * Walpurgis Night is often treated with the afternoon off, but this varies depending on employer.
+ *
+ * @link https://en.wikipedia.org/wiki/Walpurgis_Night
+ *
+ * @throws InvalidDateException
+ * @throws UnknownLocaleException
+ * @throws \InvalidArgumentException
+ * @throws \Exception
+ */
+ public function calculateWalpurgisEve(): void
+ {
+ $this->addHoliday(new Holiday(
+ 'walpurgisEve',
+ [],
+ new DateTime("$this->year-4-30", new DateTimeZone($this->timezone)),
+ $this->locale,
+ Holiday::TYPE_OBSERVANCE
+ ));
+ }
+
/**
* St. John's Day / Midsummer.
*
@@ -77,24 +138,29 @@ public function initialize(): void
*
* @link https://en.wikipedia.org/wiki/Midsummer#Sweden
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateStJohnsDay(): void
+ private function calculateStJohnsHolidays(): void
{
- $date = new DateTime("$this->year-6-20", new DateTimeZone($this->timezone)); // Default date
-
- // Check between the 20th and 26th day which one is a Saturday
- for ($d = 0; $d <= 7; ++$d) {
- if ($date->format('l') === 'Saturday') {
- break;
- }
- $date->add(new DateInterval('P1D'));
- }
+ $date = new DateTime("$this->year-6-20 this saturday", new DateTimeZone($this->timezone));
+ $this->addHoliday(new Holiday(
+ 'stJohnsDay',
+ [],
+ $date,
+ $this->locale
+ ));
- $this->addHoliday(new Holiday('stJohnsDay', ['sv_SE' => 'midsommardagen'], $date, $this->locale));
+ $date->sub(new DateInterval('P1D'));
+ $this->addHoliday(new Holiday(
+ 'stJohnsEve',
+ [],
+ $date,
+ $this->locale,
+ Holiday::TYPE_OBSERVANCE
+ ));
}
/**
@@ -111,26 +177,31 @@ public function calculateStJohnsDay(): void
* In many Lutheran Churches, it is moved to the first Sunday of November.
*
* @link https://en.wikipedia.org/wiki/All_Saints%27_Day
- * @link http://www.timeanddate.com/holidays/sweden/all-saints-day
+ * @link https://www.timeanddate.com/holidays/sweden/all-saints-day
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateAllSaintsDay(): void
+ private function calculateAllSaintsHolidays(): void
{
- $date = new DateTime("$this->year-10-31", new DateTimeZone($this->timezone));
-
- // Check between 31 October and 6th of November the day that is a Saturday
- for ($d = 0; $d <= 7; ++$d) {
- if ($date->format('l') === 'Saturday') {
- break;
- }
- $date->add(new DateInterval('P1D'));
- }
+ $date = new DateTime("$this->year-10-31 this saturday", new DateTimeZone($this->timezone));
+ $this->addHoliday(new Holiday(
+ 'allSaintsDay',
+ [],
+ $date,
+ $this->locale
+ ));
- $this->addHoliday(new Holiday('allSaintsDay', [], $date, $this->locale));
+ $date->sub(new DateInterval('P1D'));
+ $this->addHoliday(new Holiday(
+ 'allSaintsEve',
+ [],
+ $date,
+ $this->locale,
+ Holiday::TYPE_OBSERVANCE
+ ));
}
/**
@@ -142,12 +213,12 @@ public function calculateAllSaintsDay(): void
* Olympic Stadium, in honour of the election of King Gustav Vasa in 1523, as this was considered the foundation of
* modern Sweden.
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateNationalDay(): void
+ private function calculateNationalDay(): void
{
if ($this->year < 1916) {
return;
@@ -162,7 +233,7 @@ public function calculateNationalDay(): void
$this->addHoliday(new Holiday(
'nationalDay',
- ['sv_SE' => $holiday_name],
+ ['sv' => $holiday_name],
new DateTime("$this->year-6-6", new DateTimeZone($this->timezone)),
$this->locale
));
diff --git a/src/Yasumi/Provider/Switzerland.php b/src/Yasumi/Provider/Switzerland.php
index ba43389c1..f0c0d268c 100644
--- a/src/Yasumi/Provider/Switzerland.php
+++ b/src/Yasumi/Provider/Switzerland.php
@@ -1,4 +1,4 @@
- 'National Day',
- 'fr_FR' => 'Jour de la fête nationale',
- 'fr_CH' => 'Jour de la fête nationale',
- 'de_DE' => 'Bundesfeiertag',
- 'de_CH' => 'Bundesfeiertag',
- 'it_IT' => 'Giorno festivo federale',
- 'it_CH' => 'Giorno festivo federale',
- 'rm_CH' => 'Fiasta naziunala',
+ 'en' => 'National Day',
+ 'fr' => 'Jour de la fête nationale',
+ 'de' => 'Bundesfeiertag',
+ 'it' => 'Giorno festivo federale',
+ 'rm' => 'Fiasta naziunala',
];
if ($this->year >= 1994) {
$this->addHoliday(new Holiday(
@@ -80,7 +79,7 @@ public function calculateNationalDay(): void
$this->locale,
Holiday::TYPE_OFFICIAL
));
- } elseif ($this->year >= 1899 || $this->year === 1891) {
+ } elseif ($this->year >= 1899 || 1891 === $this->year) {
$this->addHoliday(new Holiday(
'swissNationalDay',
$translations,
@@ -100,9 +99,9 @@ public function calculateNationalDay(): void
*
* @link https://en.wikipedia.org/wiki/Berchtoldstag
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
public function calculateBerchtoldsTag(): void
@@ -110,11 +109,9 @@ public function calculateBerchtoldsTag(): void
$this->addHoliday(new Holiday(
'berchtoldsTag',
[
- 'de_DE' => 'Berchtoldstag',
- 'de_CH' => 'Berchtoldstag',
- 'fr_FR' => 'Jour de la Saint-Berthold',
- 'fr_CH' => 'Jour de la Saint-Berthold',
- 'en_US' => 'Berchtoldstag',
+ 'de' => 'Berchtoldstag',
+ 'fr' => 'Jour de la Saint-Berthold',
+ 'en' => 'Berchtoldstag',
],
new DateTime($this->year . '-01-02', new DateTimeZone($this->timezone)),
$this->locale,
@@ -132,9 +129,9 @@ public function calculateBerchtoldsTag(): void
*
* @link https://en.wikipedia.org/wiki/Federal_Day_of_Thanksgiving,_Repentance_and_Prayer
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
public function calculateBettagsMontag(): void
@@ -146,12 +143,9 @@ public function calculateBettagsMontag(): void
$date->add(new DateInterval('P1D'));
$this->addHoliday(new Holiday('bettagsMontag', [
- 'fr_FR' => 'Jeûne fédéral',
- 'fr_CH' => 'Jeûne fédéral',
- 'de_DE' => 'Eidgenössischer Dank-, Buss- und Bettag',
- 'de_CH' => 'Eidgenössischer Dank-, Buss- und Bettag',
- 'it_IT' => 'Festa federale di ringraziamento, pentimento e preghiera',
- 'it_CH' => 'Festa federale di ringraziamento, pentimento e preghiera',
+ 'fr' => 'Jeûne fédéral',
+ 'de' => 'Eidgenössischer Dank-, Buss- und Bettag',
+ 'it' => 'Festa federale di ringraziamento, pentimento e preghiera',
], $date, $this->locale, Holiday::TYPE_OTHER));
}
}
diff --git a/src/Yasumi/Provider/Switzerland/Aargau.php b/src/Yasumi/Provider/Switzerland/Aargau.php
index 7d47ff712..ae03c1812 100644
--- a/src/Yasumi/Provider/Switzerland/Aargau.php
+++ b/src/Yasumi/Provider/Switzerland/Aargau.php
@@ -1,4 +1,4 @@
-year . '-09', new DateTimeZone($this->timezone));
@@ -79,13 +81,11 @@ public function calculateJeuneGenevois(): void
if (($this->year >= 1840 && $this->year <= 1869) || $this->year >= 1966) {
$this->addHoliday(new Holiday('jeuneGenevois', [
- 'fr_FR' => 'Jeûne genevois',
- 'fr_CH' => 'Jeûne genevois',
+ 'fr' => 'Jeûne genevois',
], $date, $this->locale, Holiday::TYPE_OTHER));
} elseif ($this->year > 1869 && $this->year < 1966) {
$this->addHoliday(new Holiday('jeuneGenevois', [
- 'fr_FR' => 'Jeûne genevois',
- 'fr_CH' => 'Jeûne genevois',
+ 'fr' => 'Jeûne genevois',
], $date, $this->locale, Holiday::TYPE_OBSERVANCE));
}
}
@@ -100,19 +100,18 @@ public function calculateJeuneGenevois(): void
*
* @link https://fr.wikipedia.org/wiki/Restauration_genevoise
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateRestaurationGenevoise(): void
+ private function calculateRestaurationGenevoise(): void
{
if ($this->year > 1813) {
$this->addHoliday(new Holiday(
'restaurationGenevoise',
[
- 'fr_FR' => 'Restauration de la République',
- 'fr_CH' => 'Restauration de la République',
+ 'fr' => 'Restauration de la République',
],
new DateTime($this->year . '-12-31', new DateTimeZone($this->timezone)),
$this->locale,
diff --git a/src/Yasumi/Provider/Switzerland/Glarus.php b/src/Yasumi/Provider/Switzerland/Glarus.php
index 57ca3f79b..15163b4b1 100644
--- a/src/Yasumi/Provider/Switzerland/Glarus.php
+++ b/src/Yasumi/Provider/Switzerland/Glarus.php
@@ -1,4 +1,4 @@
-year >= 1389) {
$date = new DateTime('First Thursday of ' . $this->year . '-04', new DateTimeZone($this->timezone));
$this->addHoliday(new Holiday('nafelserFahrt', [
- 'de_DE' => 'Näfelser Fahrt',
- 'de_CH' => 'Näfelser Fahrt',
+ 'de' => 'Näfelser Fahrt',
], $date, $this->locale, Holiday::TYPE_OTHER));
}
}
diff --git a/src/Yasumi/Provider/Switzerland/Grisons.php b/src/Yasumi/Provider/Switzerland/Grisons.php
index 80fcdc279..f14f2f4fe 100644
--- a/src/Yasumi/Provider/Switzerland/Grisons.php
+++ b/src/Yasumi/Provider/Switzerland/Grisons.php
@@ -1,4 +1,4 @@
-year > 1974) {
$this->addHoliday(new Holiday(
'plebisciteJurassien',
[
- 'fr_FR' => 'Commémoration du plébiscite jurassien',
- 'fr_CH' => 'Commémoration du plébiscite jurassien',
+ 'fr' => 'Commémoration du plébiscite jurassien',
],
new DateTime($this->year . '-06-23', new DateTimeZone($this->timezone)),
$this->locale,
diff --git a/src/Yasumi/Provider/Switzerland/Lucerne.php b/src/Yasumi/Provider/Switzerland/Lucerne.php
index 89115995d..36d283e2e 100644
--- a/src/Yasumi/Provider/Switzerland/Lucerne.php
+++ b/src/Yasumi/Provider/Switzerland/Lucerne.php
@@ -1,4 +1,4 @@
-year > 1848) {
$this->addHoliday(new Holiday(
'instaurationRepublique',
[
- 'fr_FR' => 'Instauration de la République',
- 'fr_CH' => 'Instauration de la République',
+ 'fr' => 'Instauration de la République',
],
new DateTime($this->year . '-03-01', new DateTimeZone($this->timezone)),
$this->locale,
diff --git a/src/Yasumi/Provider/Switzerland/Nidwalden.php b/src/Yasumi/Provider/Switzerland/Nidwalden.php
index 98276f72e..cef28e01d 100644
--- a/src/Yasumi/Provider/Switzerland/Nidwalden.php
+++ b/src/Yasumi/Provider/Switzerland/Nidwalden.php
@@ -1,4 +1,4 @@
-year >= 1947) {
$this->addHoliday(new Holiday(
'bruderKlausenFest',
[
- 'de_DE' => 'Bruder-Klausen-Fest',
- 'de_CH' => 'Bruder-Klausen-Fest',
+ 'de' => 'Bruder-Klausen-Fest',
],
new DateTime($this->year . '-09-25', new DateTimeZone($this->timezone)),
$this->locale,
@@ -94,8 +95,7 @@ public function calculateBruderKlausenFest(): void
$this->addHoliday(new Holiday(
'bruderKlausenFest',
[
- 'de_DE' => 'Bruder-Klausen-Fest',
- 'de_CH' => 'Bruder-Klausen-Fest',
+ 'de' => 'Bruder-Klausen-Fest',
],
new DateTime($this->year . '-09-21', new DateTimeZone($this->timezone)),
$this->locale,
diff --git a/src/Yasumi/Provider/Switzerland/Schaffhausen.php b/src/Yasumi/Provider/Switzerland/Schaffhausen.php
index b36b48f82..211e25a0e 100644
--- a/src/Yasumi/Provider/Switzerland/Schaffhausen.php
+++ b/src/Yasumi/Provider/Switzerland/Schaffhausen.php
@@ -1,4 +1,4 @@
-addHoliday(new Holiday(
'stPeterPaul',
[
- 'it_IT' => 'Santi Pietro e Paolo',
- 'it_CH' => 'Santi Pietro e Paolo',
- 'en_US' => 'Feast of Saints Peter and Paul',
- 'fr_FR' => 'Solennité des saints Pierre et Paul',
- 'fr_CH' => 'Solennité des saints Pierre et Paul',
- 'de_DE' => 'St. Peter und Paul',
- 'de_CH' => 'St. Peter und Paul',
+ 'it' => 'Santi Pietro e Paolo',
+ 'en' => 'Feast of Saints Peter and Paul',
+ 'fr' => 'Solennité des saints Pierre et Paul',
+ 'de' => 'St. Peter und Paul',
],
new DateTime($this->year . '-06-29', new DateTimeZone($this->timezone)),
$this->locale,
diff --git a/src/Yasumi/Provider/Switzerland/Uri.php b/src/Yasumi/Provider/Switzerland/Uri.php
index 191ac8cd5..3758f1f5a 100644
--- a/src/Yasumi/Provider/Switzerland/Uri.php
+++ b/src/Yasumi/Provider/Switzerland/Uri.php
@@ -1,4 +1,4 @@
-year >= 1986) {
$this->addHoliday(new Holiday('martinLutherKingDay', [
- 'en_US' => 'Dr. Martin Luther King Jr\'s Birthday',
+ 'en' => 'Dr. Martin Luther King Jr\'s Birthday',
], new DateTime("third monday of january $this->year", new DateTimeZone($this->timezone)), $this->locale));
}
}
+ /**
+ * Washington's Birthday.
+ *
+ * Washington's Birthday is a United States federal holiday celebrated on the third Monday of February in honor
+ * of George Washington, the first President of the United States. Colloquially, it is widely known as
+ * Presidents Day and is often an occasion to remember all the presidents.
+ *
+ * Washington's Birthday was first declared a federal holiday by an 1879 act of Congress. The Uniform Holidays
+ * Act, 1968 shifted the date of the commemoration of Washington's Birthday from February 22 to the third Monday
+ * in February.
+ *
+ * @link https://en.wikipedia.org/wiki/Washington%27s_Birthday
+ *
+ * @throws \Exception
+ */
+ private function calculateWashingtonsBirthday(): void
+ {
+ if ($this->year >= 1879) {
+ $date = new DateTime("$this->year-2-22", new DateTimeZone($this->timezone));
+ if ($this->year >= 1968) {
+ $date = new DateTime("third monday of february $this->year", new DateTimeZone($this->timezone));
+ }
+ $this->addHoliday(new Holiday('washingtonsBirthday', [
+ 'en' => 'Washington\'s Birthday',
+ ], $date, $this->locale));
+ }
+ }
+
/**
* Memorial Day.
*
@@ -88,7 +119,7 @@ private function calculateMartinLutherKingday(): void
* Memorial Day was first declared a federal holiday on May 1, 1865. The Uniform Holidays Act, 1968 shifted the
* date of the commemoration of Memorial Day from May 30 to the last Monday in May.
*
- * @link http://en.wikipedia.org/wiki/Memorial_Day
+ * @link https://en.wikipedia.org/wiki/Memorial_Day
*
* @throws \Exception
*/
@@ -100,7 +131,7 @@ private function calculateMemorialDay(): void
$date = new DateTime("last monday of may $this->year", new DateTimeZone($this->timezone));
}
$this->addHoliday(new Holiday('memorialDay', [
- 'en_US' => 'Memorial Day',
+ 'en' => 'Memorial Day',
], $date, $this->locale));
}
}
@@ -113,7 +144,7 @@ private function calculateMemorialDay(): void
* from Great Britain. In case Independence Day falls on a Sunday, a substituted holiday is observed the
* following Monday. If it falls on a Saturday, a substituted holiday is observed the previous Friday.
*
- * @link http://en.wikipedia.org/wiki/Independence_Day_(United_States)
+ * @link https://en.wikipedia.org/wiki/Independence_Day_(United_States)
*
* @throws \Exception
*/
@@ -121,7 +152,7 @@ private function calculateIndependenceDay(): void
{
if ($this->year >= 1776) {
$this->addHoliday(new Holiday('independenceDay', [
- 'en_US' => 'Independence Day',
+ 'en' => 'Independence Day',
], new DateTime("$this->year-7-4", new DateTimeZone($this->timezone)), $this->locale));
}
}
@@ -132,7 +163,7 @@ private function calculateIndependenceDay(): void
* Labor Day in the United States is a holiday celebrated on the first Monday in September. It is a celebration
* of the American labor movement and is dedicated to the social and economic achievements of workers.
*
- * @link http://en.wikipedia.org/wiki/Labor_Day
+ * @link https://en.wikipedia.org/wiki/Labor_Day
*
* @throws \Exception
*/
@@ -142,7 +173,7 @@ private function calculateLabourDay(): void
$this->addHoliday(new Holiday(
'labourDay',
[
- 'en_US' => 'Labour Day',
+ 'en' => 'Labour Day',
],
new DateTime("first monday of september $this->year", new DateTimeZone($this->timezone)),
$this->locale
@@ -159,7 +190,7 @@ private function calculateLabourDay(): void
* though people have celebrated Columbus's voyage since the colonial period. Since 1970 (Oct. 12), the holiday
* has been fixed to the second Monday in October.
*
- * @link http://en.wikipedia.org/wiki/Columbus_Day
+ * @link https://en.wikipedia.org/wiki/Columbus_Day
*
* @throws \Exception
*/
@@ -171,7 +202,7 @@ private function calculateColumbusDay(): void
$date = new DateTime("second monday of october $this->year", new DateTimeZone($this->timezone));
}
$this->addHoliday(new Holiday('columbusDay', [
- 'en_US' => 'Columbus Day',
+ 'en' => 'Columbus Day',
], $date, $this->locale));
}
}
@@ -183,17 +214,17 @@ private function calculateColumbusDay(): void
* also known as veterans. It is a federal holiday that is observed on November 11 since 1919. Congress amended
* a bill on June 1, 1954, replacing "Armistice" with "Veterans," and it has been known as Veterans Day since.
*
- * @link http://en.wikipedia.org/wiki/Veterans_Day
+ * @link https://en.wikipedia.org/wiki/Veterans_Day
*
* @throws \Exception
*/
private function calculateVeteransDay(): void
{
if ($this->year >= 1919) {
- $name = ($this->year < 1954) ? 'Armistice Day' : 'Veterans Day';
+ $name = $this->year < 1954 ? 'Armistice Day' : 'Veterans Day';
$this->addHoliday(new Holiday('veteransDay', [
- 'en_US' => $name,
+ 'en' => $name,
], new DateTime("$this->year-11-11", new DateTimeZone($this->timezone)), $this->locale));
}
}
@@ -206,7 +237,7 @@ private function calculateVeteransDay(): void
* President Abraham Lincoln proclaimed a national day of "Thanksgiving and Praise to our beneficent Father who
* dwelleth in the Heavens", to be celebrated on the last Thursday in November.
*
- * @link http://en.wikipedia.org/wiki/Thanksgiving_(United_States)
+ * @link https://en.wikipedia.org/wiki/Thanksgiving_(United_States)
*
* @throws \Exception
*/
@@ -216,7 +247,7 @@ private function calculateThanksgivingDay(): void
$this->addHoliday(new Holiday(
'thanksgivingDay',
[
- 'en_US' => 'Thanksgiving Day',
+ 'en' => 'Thanksgiving Day',
],
new DateTime("fourth thursday of november $this->year", new DateTimeZone($this->timezone)),
$this->locale
@@ -224,80 +255,44 @@ private function calculateThanksgivingDay(): void
}
}
- /**
- * Washington's Birthday.
- *
- * Washington's Birthday is a United States federal holiday celebrated on the third Monday of February in honor
- * of George Washington, the first President of the United States. Colloquially, it is widely known as
- * Presidents Day and is often an occasion to remember all the presidents.
- *
- * Washington's Birthday was first declared a federal holiday by an 1879 act of Congress. The Uniform Holidays
- * Act, 1968 shifted the date of the commemoration of Washington's Birthday from February 22 to the third Monday
- * in February.
- *
- * @link http://en.wikipedia.org/wiki/Washington%27s_Birthday
- *
- * @throws \Exception
- */
- private function calculateWashingtonsBirthday(): void
- {
- if ($this->year >= 1879) {
- $date = new DateTime("$this->year-2-22", new DateTimeZone($this->timezone));
- if ($this->year >= 1968) {
- $date = new DateTime("third monday of february $this->year", new DateTimeZone($this->timezone));
- }
- $this->addHoliday(new Holiday('washingtonsBirthday', [
- 'en_US' => 'Washington\'s Birthday',
- ], $date, $this->locale));
- }
- }
-
/**
* Calculate substitute holidays.
*
* When New Year's Day, Independence Day, or Christmas Day falls on a Saturday, the previous day is also a holiday.
* When one of these holidays fall on a Sunday, the next day is also a holiday.
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
private function calculateSubstituteHolidays(): void
{
- $datesIterator = $this->getIterator();
- $substituteHoliday = null;
-
// Loop through all defined holidays
- while ($datesIterator->valid()) {
+ foreach ($this->getHolidays() as $holiday) {
+ $date = null;
- // Only process New Year's Day, Independence Day, or Christmas Day
- if (\in_array(
- $datesIterator->current()->shortName,
- ['newYearsDay', 'independenceDay', 'christmasDay'],
- true
- )) {
-
- // Substitute holiday is on a Monday in case the holiday falls on a Sunday
- if (0 === (int)$datesIterator->current()->format('w')) {
- $substituteHoliday = clone $datesIterator->current();
- $substituteHoliday->add(new DateInterval('P1D'));
- }
+ // Substitute holiday is on a Monday in case the holiday falls on a Sunday
+ if (0 === (int)$holiday->format('w')) {
+ $date = clone $holiday;
+ $date->add(new DateInterval('P1D'));
+ }
- // Substitute holiday is on a Friday in case the holiday falls on a Saturday
- if (6 === (int)$datesIterator->current()->format('w')) {
- $substituteHoliday = clone $datesIterator->current();
- $substituteHoliday->sub(new DateInterval('P1D'));
- }
+ // Substitute holiday is on a Friday in case the holiday falls on a Saturday
+ if (6 === (int)$holiday->format('w')) {
+ $date = clone $holiday;
+ $date->sub(new DateInterval('P1D'));
+ }
- // Add substitute holiday
- if (null !== $substituteHoliday) {
- $this->addHoliday(new Holiday('substituteHoliday:' . $substituteHoliday->shortName, [
- 'en_US' => $substituteHoliday->getName() . ' observed',
- ], $substituteHoliday, $this->locale));
- }
+ // Add substitute holiday
+ if ($date instanceof Holiday) {
+ $this->addHoliday(new SubstituteHoliday(
+ $holiday,
+ [],
+ $date,
+ $this->locale
+ ));
}
- $datesIterator->next();
}
}
}
diff --git a/src/Yasumi/Provider/Ukraine.php b/src/Yasumi/Provider/Ukraine.php
index e5e2e3dea..4a18bfe6d 100644
--- a/src/Yasumi/Provider/Ukraine.php
+++ b/src/Yasumi/Provider/Ukraine.php
@@ -1,4 +1,4 @@
-addHoliday(new Holiday(
'christmasDay',
@@ -85,16 +87,16 @@ public function calculateChristmasDay(): void
*
* @link https://en.wikipedia.org/wiki/International_Workers%27_Day#Ukraine
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateSecondInternationalWorkersDay(): void
+ private function calculateSecondInternationalWorkersDay(): void
{
$this->addHoliday(new Holiday('secondInternationalWorkersDay', [
- 'uk_UA' => 'День міжнародної солідарності трудящих',
- 'ru_UA' => 'День международной солидарности трудящихся'
+ 'uk' => 'День міжнародної солідарності трудящих',
+ 'ru' => 'День международной солидарности трудящихся',
], new \DateTime("$this->year-05-02", new \DateTimeZone($this->timezone)), $this->locale));
}
@@ -109,16 +111,16 @@ public function calculateSecondInternationalWorkersDay(): void
*
* @link https://en.wikipedia.org/wiki/Victory_Day_over_Nazism_in_World_War_II
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateVictoryDay(): void
+ private function calculateVictoryDay(): void
{
$this->addHoliday(new Holiday(
'victoryDay',
- ['uk_UA' => 'День перемоги', 'ru_UA' => 'День победы'],
+ ['uk' => 'День перемоги', 'ru' => 'День победы'],
new \DateTime("$this->year-05-09", new \DateTimeZone($this->timezone)),
$this->locale
));
@@ -131,12 +133,12 @@ public function calculateVictoryDay(): void
*
* @link https://en.wikipedia.org/wiki/Constitution_Day_(Ukraine)
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateConstitutionDay(): void
+ private function calculateConstitutionDay(): void
{
if ($this->year < 1996) {
return;
@@ -144,7 +146,7 @@ public function calculateConstitutionDay(): void
$this->addHoliday(new Holiday(
'constitutionDay',
- ['uk_UA' => 'День Конституції', 'ru_UA' => 'День Конституции'],
+ ['uk' => 'День Конституції', 'ru' => 'День Конституции'],
new \DateTime("$this->year-06-28", new \DateTimeZone($this->timezone)),
$this->locale
));
@@ -159,12 +161,12 @@ public function calculateConstitutionDay(): void
*
* @link https://en.wikipedia.org/wiki/Declaration_of_Independence_of_Ukraine
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateIndependenceDay(): void
+ private function calculateIndependenceDay(): void
{
if ($this->year < 1991) {
return;
@@ -172,7 +174,7 @@ public function calculateIndependenceDay(): void
$this->addHoliday(new Holiday(
'independenceDay',
- ['uk_UA' => 'День Незалежності', 'ru_UA' => 'День Независимости'],
+ ['uk' => 'День Незалежності', 'ru' => 'День Независимости'],
new \DateTime("$this->year-08-24", new \DateTimeZone($this->timezone)),
$this->locale
));
@@ -188,12 +190,12 @@ public function calculateIndependenceDay(): void
*
* @link https://en.wikipedia.org/wiki/Defender_of_Ukraine_Day
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateDefenderOfUkraineDay(): void
+ private function calculateDefenderOfUkraineDay(): void
{
if ($this->year < 2015) {
return;
@@ -201,14 +203,14 @@ public function calculateDefenderOfUkraineDay(): void
$this->addHoliday(new Holiday(
'defenderOfUkraineDay',
- ['uk_UA' => 'День захисника України', 'ru_UA' => 'День Защитника Украины'],
+ ['uk' => 'День захисника України', 'ru' => 'День Защитника Украины'],
new \DateTime("$this->year-10-14", new \DateTimeZone($this->timezone)),
$this->locale
));
}
/**
- * @param int $year
+ * @param int $year
* @param string $timezone
*
* @return \DateTime
diff --git a/src/Yasumi/Provider/UnitedKingdom.php b/src/Yasumi/Provider/UnitedKingdom.php
index 68aea9c30..e1f4c0417 100644
--- a/src/Yasumi/Provider/UnitedKingdom.php
+++ b/src/Yasumi/Provider/UnitedKingdom.php
@@ -1,4 +1,4 @@
-timezone = 'Europe/London';
-
// Add common holidays
$this->calculateNewYearsDay();
$this->calculateMayDayBankHoliday();
@@ -65,14 +68,14 @@ public function initialize(): void
* Since 1974 (by Royal Proclamation) it was established as a bank holiday.
*
* @link https://en.wikipedia.org/wiki/Public_holidays_in_the_United_Kingdom
- * @link http://www.timeanddate.com/holidays/uk/new-year-day
+ * @link https://www.timeanddate.com/holidays/uk/new-year-day
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- public function calculateNewYearsDay(): void
+ protected function calculateNewYearsDay(): void
{
// Before 1871 it was not an observed or statutory holiday
if ($this->year < 1871) {
@@ -104,23 +107,36 @@ public function calculateNewYearsDay(): void
* and schools are closed, while stores may be open or closed, according to local custom. Public transport systems
* often run to a holiday timetable.
*
- * @link http://www.timeanddate.com/holidays/uk/early-may-bank-holiday
+ * @link https://www.timeanddate.com/holidays/uk/early-may-bank-holiday
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- private function calculateMayDayBankHoliday(): void
+ protected function calculateMayDayBankHoliday(): void
{
// From 1978, by Royal Proclamation annually
if ($this->year < 1978) {
return;
}
+ // Moved to 8 May to commemorate the 50th (1995) and 75th (2020) anniversary of VE Day.
+ if (1995 === $this->year || 2020 === $this->year) {
+ $this->addHoliday(new Holiday(
+ 'mayDayBankHoliday',
+ ['en' => 'May Day Bank Holiday'],
+ new DateTime("$this->year-5-8", new DateTimeZone($this->timezone)),
+ $this->locale,
+ Holiday::TYPE_BANK
+ ));
+
+ return;
+ }
+
$this->addHoliday(new Holiday(
'mayDayBankHoliday',
- ['en_GB' => 'May Day Bank Holiday'],
+ ['en' => 'May Day Bank Holiday'],
new DateTime("first monday of may $this->year", new DateTimeZone($this->timezone)),
$this->locale,
Holiday::TYPE_BANK
@@ -135,24 +151,38 @@ private function calculateMayDayBankHoliday(): void
* The last Monday in May is a bank holiday. Many organizations, businesses and schools are closed. Stores may be
* open or closed, according to local custom. Public transport systems often run to a holiday timetable.
*
- * @link http://www.timeanddate.com/holidays/uk/spring-bank-holiday
+ * @link https://www.timeanddate.com/holidays/uk/spring-bank-holiday
* @link https://en.wikipedia.org/wiki/Public_holidays_in_the_United_Kingdom
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- private function calculateSpringBankHoliday(): void
+ protected function calculateSpringBankHoliday(): void
{
// Statutory bank holiday from 1971, following a trial period from 1965 to 1970.
if ($this->year < 1965) {
return;
}
+ // Moved to 4 June for the celebration of the Golden (2002) and Diamond (2012) Jubilee
+ // of Elizabeth II.
+ if (2002 === $this->year || 2012 === $this->year) {
+ $this->addHoliday(new Holiday(
+ 'springBankHoliday',
+ ['en' => 'Spring Bank Holiday'],
+ new DateTime("$this->year-6-4", new DateTimeZone($this->timezone)),
+ $this->locale,
+ Holiday::TYPE_BANK
+ ));
+
+ return;
+ }
+
$this->addHoliday(new Holiday(
'springBankHoliday',
- ['en_GB' => 'Spring Bank Holiday'],
+ ['en' => 'Spring Bank Holiday'],
new DateTime("last monday of may $this->year", new DateTimeZone($this->timezone)),
$this->locale,
Holiday::TYPE_BANK
@@ -162,7 +192,7 @@ private function calculateSpringBankHoliday(): void
/**
* The Summer Bank holiday, also known as the Late Summer bank holiday, is a time for people in the United Kingdom
* to have a day off work or school. It falls on the last Monday of August replacing the first Monday in August
- * (formerly commonly known as "August Bank Holiday".
+ * (formerly commonly known as "August Bank Holiday").
*
* Many organizations, businesses and schools are closed. Stores may be open or closed, according to local custom.
* Public transport systems often run to a holiday timetable.
@@ -170,21 +200,47 @@ private function calculateSpringBankHoliday(): void
* @link https://www.timeanddate.com/holidays/uk/summer-bank-holiday
* @link https://en.wikipedia.org/wiki/Public_holidays_in_the_United_Kingdom
*
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
* @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
* @throws \Exception
*/
- private function calculateSummerBankHoliday(): void
+ protected function calculateSummerBankHoliday(): void
{
- // Statutory bank holiday from 1971, following a trial period from 1965 to 1970.
+ if ($this->year < 1871) {
+ return;
+ }
+
if ($this->year < 1965) {
+ $this->addHoliday(new Holiday(
+ 'summerBankHoliday',
+ ['en' => 'August Bank Holiday'],
+ new DateTime("first monday of august $this->year", new DateTimeZone($this->timezone)),
+ $this->locale,
+ Holiday::TYPE_BANK
+ ));
+
+ return;
+ }
+
+ // Statutory bank holiday from 1971, following a trial period from 1965 to 1970.
+ // During the trial period, the definition was different than today, causing exceptions
+ // in 1968 and 1969.
+ if (1968 === $this->year || 1969 === $this->year) {
+ $this->addHoliday(new Holiday(
+ 'summerBankHoliday',
+ ['en' => 'Summer Bank Holiday'],
+ new DateTime("first monday of september $this->year", new DateTimeZone($this->timezone)),
+ $this->locale,
+ Holiday::TYPE_BANK
+ ));
+
return;
}
$this->addHoliday(new Holiday(
'summerBankHoliday',
- ['en_GB' => 'Summer Bank Holiday'],
+ ['en' => 'Summer Bank Holiday'],
new DateTime("last monday of august $this->year", new DateTimeZone($this->timezone)),
$this->locale,
Holiday::TYPE_BANK
@@ -205,42 +261,40 @@ private function calculateSummerBankHoliday(): void
* If Christmas Day falls on a Saturday, the following Monday and Tuesday are bank holidays. All schools and many
* organizations are closed in this period. Some may close for the whole week between Christmas and New Year.
*
- * @link http://www.timeanddate.com/holidays/uk/christmas-day
- * @link http://www.timeanddate.com/holidays/uk/boxing-day
+ * @link https://www.timeanddate.com/holidays/uk/christmas-day
+ * @link https://www.timeanddate.com/holidays/uk/boxing-day
+ *
+ * @param string|null $type the Holiday Type (e.g. Official, Seasonal, etc.)
*
- * @throws \Yasumi\Exception\InvalidDateException
- * @throws \InvalidArgumentException
- * @throws \Yasumi\Exception\UnknownLocaleException
* @throws \Exception
*/
- public function calculateChristmasHolidays(): void
+ protected function calculateChristmasHolidays(string $type = null): void
{
- $christmasDay = new DateTime("$this->year-12-25", new DateTimeZone($this->timezone));
- $boxingDay = new DateTime("$this->year-12-26", new DateTimeZone($this->timezone));
-
- $this->addHoliday(new Holiday('christmasDay', [], $christmasDay, $this->locale));
- $this->addHoliday(new Holiday('secondChristmasDay', [], $boxingDay, $this->locale, Holiday::TYPE_BANK));
+ $christmasDay = $this->christmasDay($this->year, $this->timezone, $this->locale, $type ?? Holiday::TYPE_OFFICIAL);
+ $secondChristmasDay = $this->secondChristmasDay($this->year, $this->timezone, $this->locale, Holiday::TYPE_BANK);
- $substituteChristmasDay = clone $christmasDay;
- $substituteBoxingDay = clone $boxingDay;
+ $this->addHoliday($christmasDay);
+ $this->addHoliday($secondChristmasDay);
if (\in_array((int)$christmasDay->format('w'), [0, 6], true)) {
- $substituteChristmasDay->add(new DateInterval('P2D'));
- $this->addHoliday(new Holiday(
- 'substituteHoliday:christmasDay',
+ $date = clone $christmasDay;
+ $date->add(new DateInterval('P2D'));
+ $this->addHoliday(new SubstituteHoliday(
+ $christmasDay,
[],
- $substituteChristmasDay,
+ $date,
$this->locale,
Holiday::TYPE_BANK
));
}
- if (\in_array((int)$boxingDay->format('w'), [0, 6], true)) {
- $substituteBoxingDay->add(new DateInterval('P2D'));
- $this->addHoliday(new Holiday(
- 'substituteHoliday:secondChristmasDay',
+ if (\in_array((int)$secondChristmasDay->format('w'), [0, 6], true)) {
+ $date = clone $secondChristmasDay;
+ $date->add(new DateInterval('P2D'));
+ $this->addHoliday(new SubstituteHoliday(
+ $secondChristmasDay,
[],
- $substituteBoxingDay,
+ $date,
$this->locale,
Holiday::TYPE_BANK
));
diff --git a/src/Yasumi/Provider/UnitedKingdom/England.php b/src/Yasumi/Provider/UnitedKingdom/England.php
new file mode 100644
index 000000000..70c91b8e3
--- /dev/null
+++ b/src/Yasumi/Provider/UnitedKingdom/England.php
@@ -0,0 +1,33 @@
+
+ */
+
+namespace Yasumi\Provider\UnitedKingdom;
+
+use Yasumi\Provider\UnitedKingdom;
+
+/**
+ * Provider for all holidays in England (United Kingdom).
+ *
+ * England is a country that is part of the United Kingdom. It covers an area of 130,279 square kilometres
+ * (50,301 sq mi), and has a population of 5,619,400. London, England's capital, is also the capital of
+ * and the largest city in the United Kingdom.
+ *
+ * @link https://en.wikipedia.org/wiki/England
+ */
+class England extends UnitedKingdom
+{
+ /**
+ * Code to identify this Holiday Provider. Typically this is the ISO3166 code corresponding to the respective
+ * country or sub-region.
+ */
+ public const ID = 'GB-ENG';
+}
diff --git a/src/Yasumi/Provider/UnitedKingdom/NorthernIreland.php b/src/Yasumi/Provider/UnitedKingdom/NorthernIreland.php
new file mode 100644
index 000000000..28fb7af6d
--- /dev/null
+++ b/src/Yasumi/Provider/UnitedKingdom/NorthernIreland.php
@@ -0,0 +1,149 @@
+
+ */
+
+namespace Yasumi\Provider\UnitedKingdom;
+
+use DateTime;
+use DateTimeZone;
+use Yasumi\Exception\InvalidDateException;
+use Yasumi\Exception\UnknownLocaleException;
+use Yasumi\Holiday;
+use Yasumi\Provider\UnitedKingdom;
+use Yasumi\SubstituteHoliday;
+
+/**
+ * Provider for all holidays in Northern Ireland (United Kingdom).
+ *
+ * Northern Ireland is a country that is part of the United Kingdom. It covers an area of 14,130 square kilometres
+ * (5,460 sq mi), and has a population of 1,885,400. Belfast, Northern Ireland's capital and largest city,
+ * is the 12th largest city in the United Kingdom.
+ *
+ * @link https://en.wikipedia.org/wiki/Northern_Ireland
+ */
+class NorthernIreland extends UnitedKingdom
+{
+ /**
+ * Code to identify this Holiday Provider. Typically this is the ISO3166 code corresponding to the respective
+ * country or sub-region.
+ */
+ public const ID = 'GB-NIR';
+
+ /**
+ * Initialize holidays for Northern Ireland (United Kingdom).
+ *
+ * @throws InvalidDateException
+ * @throws \InvalidArgumentException
+ * @throws UnknownLocaleException
+ * @throws \Exception
+ */
+ public function initialize(): void
+ {
+ parent::initialize();
+
+ $this->calculateStPatricksDay();
+ $this->calculateBattleOfTheBoyne();
+ }
+
+ /**
+ * St. Patrick's Day.
+ *
+ * Saint Patrick's Day, or the Feast of Saint Patrick (Irish: Lá Fhéile Pádraig, "the Day of the Festival of
+ * Patrick"), is a cultural and religious celebration held on 17 March, the traditional death date of Saint Patrick
+ * (c. AD 385–461), the foremost patron saint of Ireland. Saint Patrick's Day is a public holiday in the Republic
+ * of Ireland, Northern Ireland, the Canadian province of Newfoundland and Labrador, and the British Overseas
+ * Territory of Montserrat.
+ *
+ * @link https://en.wikipedia.org/wiki/Saint_Patrick%27s_Day
+ *
+ * @throws InvalidDateException
+ * @throws \InvalidArgumentException
+ * @throws UnknownLocaleException
+ * @throws \Exception
+ * @throws \Exception
+ */
+ private function calculateStPatricksDay(): void
+ {
+ if ($this->year < 1971) {
+ return;
+ }
+
+ $holiday = new Holiday(
+ 'stPatricksDay',
+ ['en' => 'St. Patrick\'s Day'],
+ new DateTime($this->year . '-3-17', new DateTimeZone($this->timezone)),
+ $this->locale,
+ Holiday::TYPE_BANK
+ );
+
+ $this->addHoliday($holiday);
+
+ // Substitute holiday is on the next available weekday if a holiday falls on a Saturday or Sunday
+ if (\in_array((int)$holiday->format('w'), [0, 6], true)) {
+ $date = clone $holiday;
+ $date->modify('next monday');
+
+ $this->addHoliday(new SubstituteHoliday(
+ $holiday,
+ [],
+ $date,
+ $this->locale,
+ Holiday::TYPE_BANK
+ ));
+ }
+ }
+
+ /**
+ * Battle of the Boyne.
+ *
+ * Orangemen's Day, also called The Twelfth or Glorious Twelfth) celebrates the Glorious Revolution (1688)
+ * and victory of Protestant King William of Orange over Catholic king James II at the Battle of the
+ * Boyne (1690), which began the Protestant Ascendancy in Ireland.
+ *
+ * @link https://en.wikipedia.org/wiki/The_Twelfth
+ *
+ * @throws InvalidDateException
+ * @throws \InvalidArgumentException
+ * @throws UnknownLocaleException
+ * @throws \Exception
+ * @throws \Exception
+ */
+ private function calculateBattleOfTheBoyne(): void
+ {
+ if ($this->year < 1926) {
+ return;
+ }
+
+ $holiday = new Holiday(
+ 'battleOfTheBoyne',
+ ['en' => 'Battle of the Boyne'],
+ new DateTime($this->year . '-7-12', new DateTimeZone($this->timezone)),
+ $this->locale,
+ Holiday::TYPE_BANK
+ );
+
+ $this->addHoliday($holiday);
+
+ // Substitute holiday is on the next available weekday if a holiday falls on a Saturday or Sunday
+ if (\in_array((int)$holiday->format('w'), [0, 6], true)) {
+ $date = clone $holiday;
+ $date->modify('next monday');
+
+ $this->addHoliday(new SubstituteHoliday(
+ $holiday,
+ [],
+ $date,
+ $this->locale,
+ Holiday::TYPE_BANK
+ ));
+ }
+ }
+}
diff --git a/src/Yasumi/Provider/UnitedKingdom/Scotland.php b/src/Yasumi/Provider/UnitedKingdom/Scotland.php
new file mode 100644
index 000000000..91782564f
--- /dev/null
+++ b/src/Yasumi/Provider/UnitedKingdom/Scotland.php
@@ -0,0 +1,205 @@
+
+ */
+
+namespace Yasumi\Provider\UnitedKingdom;
+
+use DateInterval;
+use DateTime;
+use DateTimeZone;
+use Yasumi\Exception\InvalidDateException;
+use Yasumi\Exception\UnknownLocaleException;
+use Yasumi\Holiday;
+use Yasumi\Provider\UnitedKingdom;
+use Yasumi\SubstituteHoliday;
+
+/**
+ * Provider for all holidays in Scotland (United Kingdom).
+ *
+ * Scotland is a country that is part of the United Kingdom. It covers an area of 77,933 square kilometres
+ * (30,090 sq mi), and has a population of 5,424,800. The capital is Edinburgh. Glasgow, Scotland's
+ * largest city, is the fifth largest city in the United Kingdom.
+ *
+ * Bank and public holidays in Scotland are determined under the Banking and Financial Dealings Act 1971
+ * and the St Andrew's Day Bank Holiday (Scotland) Act 2007. Unlike the rest of United Kingdom, most bank
+ * holidays are not recognised as statutory public holidays in Scotland, as most public holidays are
+ * determined by local authorities across Scotland.
+ *
+ * @link https://en.wikipedia.org/wiki/Scotland
+ */
+class Scotland extends UnitedKingdom
+{
+ /**
+ * Code to identify this Holiday Provider. Typically this is the ISO3166 code corresponding to the respective
+ * country or sub-region.
+ */
+ public const ID = 'GB-SCT';
+
+ /**
+ * Initialize holidays for the United Kingdom.
+ *
+ * @throws InvalidDateException
+ * @throws \InvalidArgumentException
+ * @throws UnknownLocaleException
+ * @throws \Exception
+ */
+ public function initialize(): void
+ {
+ parent::initialize();
+
+ // Add common holidays
+ $this->calculateNewYearsHolidays();
+ $this->calculateMayDayBankHoliday();
+ $this->calculateSpringBankHoliday();
+ $this->calculateSummerBankHoliday();
+
+ // Add common Christian holidays
+ $this->addHoliday($this->goodFriday($this->year, $this->timezone, $this->locale, Holiday::TYPE_BANK));
+ $this->calculateStAndrewsDay();
+ $this->calculateChristmasHolidays(Holiday::TYPE_BANK);
+ }
+
+ /**
+ * New Year's Day is a public holiday in the United Kingdom on January 1 each year. It marks
+ * the start of the New Year in the Gregorian calendar. For many people have a quiet day on
+ * January 1, which marks the end of the Christmas break before they return to work.
+ *
+ * In Scotland, January 2 is also a bank holiday. If January 2 falls on a Saturday, the following Monday is a bank holiday.
+ * If New Years Day falls on a Saturday, the following Monday and Tuesday are bank holidays.
+ *
+ * @link https://en.wikipedia.org/wiki/Public_holidays_in_Scotland
+ * @link https://www.timeanddate.com/holidays/uk/new-year-day
+ *
+ * @throws InvalidDateException
+ * @throws \InvalidArgumentException
+ * @throws UnknownLocaleException
+ * @throws \Exception
+ */
+ protected function calculateNewYearsHolidays(): void
+ {
+ // Before 1871 it was not an observed or statutory holiday
+ if ($this->year < 1871) {
+ return;
+ }
+
+ if ($this->year <= 1974) {
+ $type = Holiday::TYPE_OBSERVANCE;
+ } else {
+ $type = Holiday::TYPE_BANK;
+ }
+
+ $newYearsDay = $this->newYearsDay($this->year, $this->timezone, $this->locale, $type);
+ $secondNewYearsDay = new Holiday(
+ 'secondNewYearsDay',
+ [],
+ new DateTime("$this->year-1-2", new DateTimeZone($this->timezone)),
+ $this->locale,
+ $type
+ );
+
+ $this->addHoliday($newYearsDay);
+ $this->addHoliday($secondNewYearsDay);
+
+ if (\in_array((int)$newYearsDay->format('w'), [0, 6], true)) {
+ $date = clone $newYearsDay;
+ $date->add(new DateInterval('P2D'));
+ $this->addHoliday(new SubstituteHoliday(
+ $newYearsDay,
+ [],
+ $date,
+ $this->locale,
+ $type
+ ));
+ }
+
+ if (\in_array((int)$secondNewYearsDay->format('w'), [0, 6], true)) {
+ $date = clone $secondNewYearsDay;
+ $date->add(new DateInterval('P2D'));
+ $this->addHoliday(new SubstituteHoliday(
+ $secondNewYearsDay,
+ [],
+ $date,
+ $this->locale,
+ $type
+ ));
+ }
+ }
+
+ /**
+ * The Summer Bank holiday, also known as the Late Summer bank holiday, is a time for people in the United Kingdom
+ * to have a day off work or school. In Scotland it falls on the first Monday of August.
+ *
+ * @link https://www.timeanddate.com/holidays/uk/summer-bank-holiday
+ * @link https://en.wikipedia.org/wiki/Public_holidays_in_Scotland
+ *
+ * @throws InvalidDateException
+ * @throws \InvalidArgumentException
+ * @throws UnknownLocaleException
+ * @throws \Exception
+ */
+ protected function calculateSummerBankHoliday(): void
+ {
+ if ($this->year < 1871) {
+ return;
+ }
+
+ $this->addHoliday(new Holiday(
+ 'summerBankHoliday',
+ ['en' => 'August Bank Holiday'],
+ new DateTime("first monday of august $this->year", new DateTimeZone($this->timezone)),
+ $this->locale,
+ Holiday::TYPE_BANK
+ ));
+ }
+
+ /**
+ * St. Andrew's Day.
+ *
+ * Saint Andrew's Day is Scotland's national day, celebrated on 30 November.
+ *
+ * @link https://en.wikipedia.org/wiki/Saint_Andrew%27s_Day
+ *
+ * @throws InvalidDateException
+ * @throws \InvalidArgumentException
+ * @throws UnknownLocaleException
+ * @throws \Exception
+ * @throws \Exception
+ */
+ private function calculateStAndrewsDay(): void
+ {
+ if ($this->year < 2007) {
+ return;
+ }
+ $holiday = new Holiday(
+ 'stAndrewsDay',
+ [],
+ new DateTime($this->year . '-11-30', new DateTimeZone($this->timezone)),
+ $this->locale,
+ Holiday::TYPE_BANK
+ );
+
+ $this->addHoliday($holiday);
+
+ // Substitute holiday is on the next available weekday if a holiday falls on a Saturday or Sunday
+ if (\in_array((int)$holiday->format('w'), [0, 6], true)) {
+ $date = clone $holiday;
+ $date->modify('next monday');
+
+ $this->addHoliday(new SubstituteHoliday(
+ $holiday,
+ [],
+ $date,
+ $this->locale,
+ Holiday::TYPE_BANK
+ ));
+ }
+ }
+}
diff --git a/src/Yasumi/Provider/UnitedKingdom/Wales.php b/src/Yasumi/Provider/UnitedKingdom/Wales.php
new file mode 100644
index 000000000..7d7783477
--- /dev/null
+++ b/src/Yasumi/Provider/UnitedKingdom/Wales.php
@@ -0,0 +1,33 @@
+
+ */
+
+namespace Yasumi\Provider\UnitedKingdom;
+
+use Yasumi\Provider\UnitedKingdom;
+
+/**
+ * Provider for all holidays in Wales (United Kingdom).
+ *
+ * Wales is a country that is part of the United Kingdom. It covers an area of 20,779 square kilometres
+ * (8,023 sq mi), and has a population of 3,125,000. Cardiff, Wales's capital and largest city, is the
+ * eleventh largest city in the United Kingdom.
+ *
+ * @link https://en.wikipedia.org/wiki/Wales
+ */
+class Wales extends UnitedKingdom
+{
+ /**
+ * Code to identify this Holiday Provider. Typically this is the ISO3166 code corresponding to the respective
+ * country or sub-region.
+ */
+ public const ID = 'GB-WLS';
+}
diff --git a/src/Yasumi/ProviderInterface.php b/src/Yasumi/ProviderInterface.php
index 3cfd4625c..9c52175f3 100755
--- a/src/Yasumi/ProviderInterface.php
+++ b/src/Yasumi/ProviderInterface.php
@@ -1,4 +1,4 @@
-
+ */
+
+namespace Yasumi;
+
+use Yasumi\Exception\InvalidDateException;
+use Yasumi\Exception\UnknownLocaleException;
+
+/**
+ * Class SubstituteHoliday.
+ *
+ * A substitute holiday is a holiday given in lieu of another holiday, if that day falls in a weekend or
+ * overlaps with other holidays, so that people do not "lose" a day off in these years.
+ *
+ * @link https://en.wikipedia.org/wiki/Substitute_holiday
+ */
+class SubstituteHoliday extends Holiday
+{
+ /**
+ * @var Holiday
+ */
+ public $substitutedHoliday;
+
+ /**
+ * @var array list of translations of the "{0} observed" pattern
+ */
+ public $substituteHolidayTranslations;
+
+ /**
+ * Creates a new SubstituteHoliday.
+ *
+ * If a holiday date needs to be defined for a specific timezone, make sure that the date instance
+ * (DateTimeInterface) has the correct timezone set. Otherwise the default system timezone is used.
+ *
+ * @param Holiday $substitutedHoliday The holiday being substituted
+ * @param array $names An array containing the name/description of this holiday
+ * in various languages. Overrides global translations
+ * @param \DateTimeInterface $date A DateTimeInterface instance representing the date of the holiday
+ * @param string $displayLocale Locale (i.e. language) in which the holiday information needs to
+ * be displayed in. (Default 'en_US')
+ * @param string $type The type of holiday. Use the following constants: TYPE_OFFICIAL,
+ * TYPE_OBSERVANCE, TYPE_SEASON, TYPE_BANK or TYPE_OTHER. By default
+ * an official holiday is considered.
+ *
+ * @throws InvalidDateException
+ * @throws UnknownLocaleException
+ * @throws \InvalidArgumentException
+ * @throws \Exception
+ */
+ public function __construct(
+ Holiday $substitutedHoliday,
+ array $names,
+ \DateTimeInterface $date,
+ string $displayLocale = self::DEFAULT_LOCALE,
+ string $type = self::TYPE_OFFICIAL
+ ) {
+ $this->substitutedHoliday = $substitutedHoliday;
+
+ $shortName = 'substituteHoliday:' . $substitutedHoliday->shortName;
+
+ if ($date == $substitutedHoliday) {
+ throw new \InvalidArgumentException('Date must differ from the substituted holiday');
+ }
+
+ // Construct instance
+ parent::__construct($shortName, $names, $date, $displayLocale, $type);
+ }
+
+ /**
+ * Returns the name of this holiday.
+ *
+ * The name of this holiday is returned translated in the given locale. If for the given locale no translation is
+ * defined, the name in the default locale ('en_US') is returned. In case there is no translation at all, the short
+ * internal name is returned.
+ */
+ public function getName(): string
+ {
+ $name = parent::getName();
+
+ if ($name === $this->shortName) {
+ $pattern = $this->substituteHolidayTranslations[$this->displayLocale]
+ ?? $this->substituteHolidayTranslations[self::DEFAULT_LOCALE]
+ ?? $this->shortName;
+
+ $name = \str_replace('{0}', $this->substitutedHoliday->getName(), $pattern);
+ }
+
+ return $name;
+ }
+
+ /**
+ * Merges local translations (preferred) with global translations.
+ *
+ * @param TranslationsInterface $globalTranslations global translations
+ */
+ public function mergeGlobalTranslations(TranslationsInterface $globalTranslations)
+ {
+ $this->substituteHolidayTranslations = $globalTranslations->getTranslations('substituteHoliday');
+
+ parent::mergeGlobalTranslations($globalTranslations);
+
+ $this->substitutedHoliday->mergeGlobalTranslations($globalTranslations);
+ }
+}
diff --git a/src/Yasumi/Translations.php b/src/Yasumi/Translations.php
index 2ac7576f3..ec4abe1d5 100644
--- a/src/Yasumi/Translations.php
+++ b/src/Yasumi/Translations.php
@@ -1,4 +1,4 @@
-isDot() || $file->isDir()) {
@@ -68,7 +68,7 @@ public function loadTranslations(string $directoryPath): void
continue;
}
- $filename = $file->getFilename();
+ $filename = $file->getFilename();
$shortName = $file->getBasename('.' . $extension);
$translations = require $directoryPath . $filename;
@@ -88,14 +88,14 @@ public function loadTranslations(string $directoryPath): void
*
* @param string $locale locale the locale to be validated
*
+ * @return true upon success, otherwise an UnknownLocaleException is thrown
* @throws UnknownLocaleException An UnknownLocaleException is thrown if the given locale is not
* valid/available.
*
- * @return true upon success, otherwise an UnknownLocaleException is thrown
*/
protected function isValidLocale(string $locale): bool
{
- if (! \in_array($locale, $this->availableLocales, true)) {
+ if (!\in_array($locale, $this->availableLocales, true)) {
throw new UnknownLocaleException(\sprintf('Locale "%s" is not a valid locale.', $locale));
}
@@ -105,17 +105,17 @@ protected function isValidLocale(string $locale): bool
/**
* Adds translation for holiday in specific locale.
*
- * @param string $shortName holiday short name
- * @param string $locale locale
+ * @param string $shortName holiday short name
+ * @param string $locale locale
* @param string $translation translation
*
- * @throws \Yasumi\Exception\UnknownLocaleException
+ * @throws UnknownLocaleException
*/
public function addTranslation(string $shortName, string $locale, string $translation): void
{
$this->isValidLocale($locale); // Validate the given locale
- if (! \array_key_exists($shortName, $this->translations)) {
+ if (!\array_key_exists($shortName, $this->translations)) {
$this->translations[$shortName] = [];
}
@@ -126,17 +126,14 @@ public function addTranslation(string $shortName, string $locale, string $transl
* Returns translation for holiday in specific locale.
*
* @param string $shortName holiday short name
- * @param string $locale locale
+ * @param string $locale locale
*
* @return string|null translated holiday name
*/
public function getTranslation(string $shortName, string $locale): ?string
{
- if (! \array_key_exists($shortName, $this->translations)) {
- return null;
- }
-
- if (! \array_key_exists($locale, $this->translations[$shortName])) {
+ if (!\array_key_exists($shortName, $this->translations)
+ || !\array_key_exists($locale, $this->translations[$shortName])) {
return null;
}
@@ -152,7 +149,7 @@ public function getTranslation(string $shortName, string $locale): ?string
*/
public function getTranslations(string $shortName): array
{
- if (! \array_key_exists($shortName, $this->translations)) {
+ if (!\array_key_exists($shortName, $this->translations)) {
return [];
}
diff --git a/src/Yasumi/TranslationsInterface.php b/src/Yasumi/TranslationsInterface.php
index ec58213a7..94545cc3b 100644
--- a/src/Yasumi/TranslationsInterface.php
+++ b/src/Yasumi/TranslationsInterface.php
@@ -1,4 +1,4 @@
- 0) {
$date = $date->add(new \DateInterval('P1D'));
- if (! $provider || $provider->getYear() !== \getdate()['year']) {
+ if (!$provider || $provider->getYear() !== \getdate()['year']) {
$provider = self::create($class, (int)$date->format('Y'));
}
if ($provider->isWorkingDay($date)) {
@@ -108,18 +111,18 @@ public static function nextWorkingDay(
* already with Yasumi, or your own provider by giving the name of your class in the first parameter. Your provider
* class needs to implement the 'ProviderInterface' class.
*
- * @param string $class holiday provider name
- * @param int $year year for which the country provider needs to be created. Year needs to be a valid integer
+ * @param string $class holiday provider name
+ * @param int $year year for which the country provider needs to be created. Year needs to be a valid integer
* between 1000 and 9999.
* @param string $locale The locale to use. If empty we'll use the default locale (en_US)
*
- * @throws \ReflectionException
- * @throws RuntimeException If no such holiday provider is found
- * @throws InvalidArgumentException if the year parameter is not between 1000 and 9999
- * @throws UnknownLocaleException if the locale parameter is invalid
- * @throws InvalidArgumentException if the holiday provider for the given country does not exist
- *
* @return AbstractProvider An instance of class $class is created and returned
+ *
+ * @throws RuntimeException If no such holiday provider is found
+ * @throws InvalidYearException if the year parameter is not between 1000 and 9999
+ * @throws UnknownLocaleException if the locale parameter is invalid
+ * @throws ProviderNotFoundException if the holiday provider for the given country does not exist
+ * @throws \ReflectionException
*/
public static function create(string $class, int $year = 0, string $locale = self::DEFAULT_LOCALE): ProviderInterface
{
@@ -130,13 +133,13 @@ public static function create(string $class, int $year = 0, string $locale = sel
$providerClass = $class;
}
- if ($class === 'AbstractProvider' || ! \class_exists($providerClass)) {
- throw new InvalidArgumentException(\sprintf('Unable to find holiday provider "%s".', $class));
+ if ('AbstractProvider' === $class || !\class_exists($providerClass)) {
+ throw new ProviderNotFoundException(\sprintf('Unable to find holiday provider "%s".', $class));
}
// Assert year input
if ($year < 1000 || $year > 9999) {
- throw new InvalidArgumentException(\sprintf('Year needs to be between 1000 and 9999 (%s given).', $year));
+ throw new InvalidYearException(\sprintf('Year needs to be between 1000 and 9999 (%d given).', $year));
}
// Load internal locales variable
@@ -151,7 +154,7 @@ public static function create(string $class, int $year = 0, string $locale = sel
}
// Assert locale input
- if (! \in_array($locale, self::$locales, true)) {
+ if (!\in_array($locale, self::$locales, true)) {
throw new UnknownLocaleException(\sprintf('Locale "%s" is not a valid locale.', $locale));
}
@@ -176,17 +179,17 @@ public static function getAvailableLocales(): array
* your class in the first parameter. Your provider class needs to implement the 'ProviderInterface' class.
*
* @param string $iso3166_2 ISO3166-2 Coded region, holiday provider will be searched for
- * @param int $year year for which the country provider needs to be created. Year needs to be a valid
+ * @param int $year year for which the country provider needs to be created. Year needs to be a valid
* integer between 1000 and 9999.
- * @param string $locale The locale to use. If empty we'll use the default locale (en_US)
- *
- * @throws \ReflectionException
- * @throws RuntimeException If no such holiday provider is found
- * @throws InvalidArgumentException if the year parameter is not between 1000 and 9999
- * @throws UnknownLocaleException if the locale parameter is invalid
- * @throws InvalidArgumentException if the holiday provider for the given ISO3166-2 code does not exist
+ * @param string $locale The locale to use. If empty we'll use the default locale (en_US)
*
* @return AbstractProvider An instance of class $class is created and returned
+ *
+ * @throws RuntimeException If no such holiday provider is found
+ * @throws InvalidArgumentException if the year parameter is not between 1000 and 9999
+ * @throws UnknownLocaleException if the locale parameter is invalid
+ * @throws ProviderNotFoundException if the holiday provider for the given ISO3166-2 code does not exist
+ * @throws \ReflectionException
*/
public static function createByISO3166_2(
string $iso3166_2,
@@ -196,7 +199,7 @@ public static function createByISO3166_2(
$availableProviders = self::getProviders();
if (false === isset($availableProviders[$iso3166_2])) {
- throw new InvalidArgumentException(\sprintf(
+ throw new ProviderNotFoundException(\sprintf(
'Unable to find holiday provider by ISO3166-2 "%s".',
$iso3166_2
));
@@ -220,16 +223,16 @@ public static function getProviders(): array
return $providers;
}
- $providers = [];
+ $providers = [];
$filesIterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(
__DIR__ . DIRECTORY_SEPARATOR . 'Provider',
FilesystemIterator::SKIP_DOTS
), RecursiveIteratorIterator::SELF_FIRST);
foreach ($filesIterator as $file) {
- if ($file->isDir() || $file->getExtension() !== 'php' || \in_array(
+ if ($file->isDir() || 'php' !== $file->getExtension() || \in_array(
$file->getBasename('.php'),
- self::$ignoredProvider,
+ self::$ignoredProvider,
true
)) {
continue;
@@ -256,21 +259,20 @@ public static function getProviders(): array
* by this Holiday Provider. The workingDays parameter can be used how far back (in days) the previous working day
* must be searched for.
*
- * @param string $class Holiday Provider name
- * @param \DateTimeInterface $startDate Start date, defaults to today
- * @param int $workingDays Number of days to look back for the (first) previous working day
+ * @param string $class Holiday Provider name
+ * @param \DateTimeInterface $startDate Start date, defaults to today
+ * @param int $workingDays Number of days to look back for the (first) previous working day
*
* @return \DateTimeInterface
*
* @throws \ReflectionException
- * @throws \Yasumi\Exception\UnknownLocaleException
- * @throws \RuntimeException
- * @throws \InvalidArgumentException
+ * @throws UnknownLocaleException
+ * @throws RuntimeException
+ * @throws InvalidArgumentException
* @throws \Exception
- * @throws \Yasumi\Exception\InvalidDateException
+ * @throws InvalidDateException
*
* @TODO we should accept a timezone so we can accept int/string for $startDate
- *
*/
public static function prevWorkingDay(
string $class,
@@ -285,7 +287,7 @@ public static function prevWorkingDay(
while ($workingDays > 0) {
$date = $date->sub(new \DateInterval('P1D'));
- if (! $provider || $provider->getYear() !== \getdate()['year']) {
+ if (!$provider || $provider->getYear() !== \getdate()['year']) {
$provider = self::create($class, (int)$date->format('Y'));
}
if ($provider->isWorkingDay($date)) {
diff --git a/src/Yasumi/data/locales.php b/src/Yasumi/data/locales.php
index 9b8a65476..e4cd6102d 100644
--- a/src/Yasumi/data/locales.php
+++ b/src/Yasumi/data/locales.php
@@ -1,4 +1,4 @@
- 'Allerheiligen',
- 'de_CH' => 'Allerheiligen',
- 'de_DE' => 'Allerheiligen',
- 'el_GR' => 'Άγιοι Πάντες',
- 'en_US' => 'All Saints\' Day',
- 'es_ES' => 'Día de todos los Santos',
- 'fi_FI' => 'Pyhäinpäivä',
+ 'de' => 'Allerheiligen',
+ 'el' => 'Άγιοι Πάντες',
+ 'en' => 'All Saints\' Day',
+ 'es' => 'Día de todos los Santos',
+ 'fi' => 'Pyhäinpäivä',
'fr_BE' => 'La Toussaint',
- 'fr_CH' => 'Toussaint',
- 'fr_FR' => 'La Toussaint',
- 'hr_HR' => 'Dan svih svetih',
- 'hu_HU' => 'Mindenszentek',
+ 'fr' => 'Toussaint',
+ 'hr' => 'Dan svih svetih',
+ 'hu' => 'Mindenszentek',
+ 'it' => 'Festa di Tutti i Santi',
'it_CH' => 'Ognissanti',
- 'it_IT' => 'Festa di Tutti i Santi',
- 'lt_LT' => 'Visų šventųjų diena (Vėlinės)',
- 'nl_BE' => 'Allerheiligen',
- 'nl_NL' => 'Allerheiligen',
- 'pl_PL' => 'Uroczystość Wszystkich Świętych',
- 'pt_PT' => 'Dia de todos os Santos',
- 'ro_RO' => 'Ziua tuturor sfinților',
- 'sk_SK' => 'Sviatok Všetkých svätých',
- 'sv_SE' => 'alla helgons dag',
+ 'lt' => 'Visų šventųjų diena (Vėlinės)',
+ 'nl' => 'Allerheiligen',
+ 'pl' => 'Uroczystość Wszystkich Świętych',
+ 'pt' => 'Dia de todos os Santos',
+ 'ro' => 'Ziua tuturor sfinților',
+ 'sk' => 'Sviatok Všetkých svätých',
+ 'sv' => 'alla helgons dag',
];
diff --git a/src/Yasumi/data/translations/allSaintsEve.php b/src/Yasumi/data/translations/allSaintsEve.php
new file mode 100755
index 000000000..27a222c7e
--- /dev/null
+++ b/src/Yasumi/data/translations/allSaintsEve.php
@@ -0,0 +1,18 @@
+
+ */
+
+// Translations for All Saints' Eve
+return [
+ 'da' => 'Allehelgensaften',
+ 'en' => 'All Saints\' Eve',
+ 'sv' => 'alla helgons afton',
+];
diff --git a/src/Yasumi/data/translations/annunciation.php b/src/Yasumi/data/translations/annunciation.php
index eb2bb79b3..1a8f148b0 100644
--- a/src/Yasumi/data/translations/annunciation.php
+++ b/src/Yasumi/data/translations/annunciation.php
@@ -1,4 +1,4 @@
- 'Ευαγγελισμός της Θεοτόκου',
- 'en_US' => 'Annunciation',
- 'fr_BE' => 'Annonciation',
- 'fr_FR' => 'Annonciation',
+ 'el' => 'Ευαγγελισμός της Θεοτόκου',
+ 'en' => 'Annunciation',
+ 'fr' => 'Annonciation',
];
diff --git a/src/Yasumi/data/translations/anzacDay.php b/src/Yasumi/data/translations/anzacDay.php
index ecae451ef..632b1bec9 100644
--- a/src/Yasumi/data/translations/anzacDay.php
+++ b/src/Yasumi/data/translations/anzacDay.php
@@ -1,4 +1,4 @@
- 'ANZAC Day',
- 'en_NZ' => 'ANZAC Day',
- 'en_US' => 'ANZAC Day',
+ 'en' => 'ANZAC Day',
];
diff --git a/src/Yasumi/data/translations/armisticeDay.php b/src/Yasumi/data/translations/armisticeDay.php
index 3649e008d..f9cb906b4 100644
--- a/src/Yasumi/data/translations/armisticeDay.php
+++ b/src/Yasumi/data/translations/armisticeDay.php
@@ -1,4 +1,4 @@
- 'Ημέρα Ανακωχής',
- 'en_US' => 'Armistice Day',
- 'fr_BE' => 'Armistice',
- 'fr_FR' => 'Armistice',
- 'nl_BE' => 'Wapenstilstand',
+ 'el' => 'Ημέρα Ανακωχής',
+ 'en' => 'Armistice Day',
+ 'fr' => 'Armistice',
+ 'fr_FR' => 'Armistice 1918',
+ 'nl' => 'Wapenstilstand',
];
diff --git a/src/Yasumi/data/translations/ascensionDay.php b/src/Yasumi/data/translations/ascensionDay.php
index 5ac109f69..8e2f97906 100644
--- a/src/Yasumi/data/translations/ascensionDay.php
+++ b/src/Yasumi/data/translations/ascensionDay.php
@@ -1,4 +1,4 @@
- 'Kristi himmelfartsdag',
- 'de_AT' => 'Christi Himmelfahrt',
+ 'da' => 'Kristi himmelfartsdag',
+ 'de' => 'Christi Himmelfahrt',
'de_CH' => 'Auffahrt',
- 'de_DE' => 'Christi Himmelfahrt',
- 'el_GR' => 'Ανάληψη του Χριστού',
- 'en_US' => 'Ascension Day',
- 'fi_FI' => 'Helatorstai',
- 'fr_BE' => 'Ascension',
- 'fr_CH' => 'Ascension',
- 'fr_FR' => 'Ascension',
- 'it_CH' => 'Ascensione',
- 'nb_NO' => 'Kristi himmelfartsdag',
- 'nl_BE' => 'Hemelvaart',
- 'nl_NL' => 'Hemelvaart',
- 'sv_SE' => 'Kristi himmelsfärdsdag',
+ 'el' => 'Ανάληψη του Χριστού',
+ 'en' => 'Ascension Day',
+ 'fi' => 'Helatorstai',
+ 'fr' => 'Ascension',
+ 'it' => 'Ascensione',
+ 'nb' => 'Kristi himmelfartsdag',
+ 'nl' => 'Hemelvaart',
+ 'sv' => 'Kristi himmelsfärdsdag',
];
diff --git a/src/Yasumi/data/translations/ashWednesday.php b/src/Yasumi/data/translations/ashWednesday.php
index ec9019b52..7f15e9ee5 100644
--- a/src/Yasumi/data/translations/ashWednesday.php
+++ b/src/Yasumi/data/translations/ashWednesday.php
@@ -1,4 +1,4 @@
- 'Aschermittwoch',
- 'en_US' => 'Ash Wednesday',
- 'es_ES' => 'Miércoles de Ceniza',
- 'fr_BE' => 'Mercredi des Cendres',
- 'fr_CH' => 'Mercredi des Cendres',
- 'it_CH' => 'Mercoledi delle Ceneri',
- 'nl_BE' => 'Aswoensdag',
- 'nl_NL' => 'Aswoensdag',
- 'pt_BR' => 'Quarta-feira de Cinzas',
+ 'de' => 'Aschermittwoch',
+ 'en' => 'Ash Wednesday',
+ 'es' => 'Miércoles de Ceniza',
+ 'fr' => 'Mercredi des Cendres',
+ 'it' => 'Mercoledi delle Ceneri',
+ 'nl' => 'Aswoensdag',
+ 'pt' => 'Quarta-feira de Cinzas',
];
diff --git a/src/Yasumi/data/translations/assumptionOfMary.php b/src/Yasumi/data/translations/assumptionOfMary.php
index 7b3c4e52d..2659f2bf2 100755
--- a/src/Yasumi/data/translations/assumptionOfMary.php
+++ b/src/Yasumi/data/translations/assumptionOfMary.php
@@ -1,4 +1,4 @@
- 'Mariä Himmelfahrt',
- 'de_CH' => 'Mariä Himmelfahrt',
- 'de_DE' => 'Mariä Himmelfahrt',
- 'el_GR' => 'Κοίμηση της Θεοτόκου',
- 'en_US' => 'Assumption of Mary',
- 'es_ES' => 'Asunción de la Virgen María',
- 'fr_BE' => 'Assomption',
- 'fr_CH' => 'Assomption',
- 'fr_FR' => 'L\'Assomption de Marie',
- 'hr_HR' => 'Velika Gospa',
+ 'de' => 'Mariä Himmelfahrt',
+ 'el' => 'Κοίμηση της Θεοτόκου',
+ 'en' => 'Assumption of Mary',
+ 'es' => 'Asunción de la Virgen María',
+ 'fr' => 'Assomption',
+ 'hr' => 'Velika Gospa',
+ 'it' => 'Assunzione di Maria Vergine',
'it_CH' => 'Assunzione',
- 'it_IT' => 'Assunzione di Maria Vergine',
- 'lt_LT' => 'Žolinė (Švč. Mergelės Marijos ėmimo į dangų diena)',
- 'nl_BE' => 'Onze Lieve Vrouw hemelvaart',
- 'nl_NL' => 'Onze Lieve Vrouw hemelvaart',
- 'pl_PL' => 'Wniebowzięcie Najświętszej Marii Panny',
- 'pt_PT' => 'Assunção de Nossa Senhora',
- 'ro_RO' => 'Adormirea Maicii Domnului',
- 'sk_SK' => 'Nanebovzatie Panny Márie',
+ 'lt' => 'Žolinė (Švč. Mergelės Marijos ėmimo į dangų diena)',
+ 'nl' => 'Onze Lieve Vrouw hemelvaart',
+ 'pl' => 'Wniebowzięcie Najświętszej Marii Panny',
+ 'pt' => 'Assunção de Nossa Senhora',
+ 'ro' => 'Adormirea Maicii Domnului',
+ 'sk' => 'Nanebovzatie Panny Márie',
];
diff --git a/src/Yasumi/data/translations/australiaDay.php b/src/Yasumi/data/translations/australiaDay.php
index ee2b3640b..a07d969b1 100644
--- a/src/Yasumi/data/translations/australiaDay.php
+++ b/src/Yasumi/data/translations/australiaDay.php
@@ -1,4 +1,4 @@
- 'Australia Day',
- 'en_US' => 'Australia Day',
+ 'en' => 'Australia Day',
];
diff --git a/src/Yasumi/data/translations/carnationRevolutionDay.php b/src/Yasumi/data/translations/carnationRevolutionDay.php
index 0943891e4..b223b2d9c 100644
--- a/src/Yasumi/data/translations/carnationRevolutionDay.php
+++ b/src/Yasumi/data/translations/carnationRevolutionDay.php
@@ -1,4 +1,4 @@
- 'Freedom Day',
- 'pt_PT' => 'Dia da Liberdade',
+ 'en' => 'Freedom Day',
+ 'pt' => 'Dia da Liberdade',
];
diff --git a/src/Yasumi/data/translations/christmasDay.php b/src/Yasumi/data/translations/christmasDay.php
index db2c3c616..04332e431 100755
--- a/src/Yasumi/data/translations/christmasDay.php
+++ b/src/Yasumi/data/translations/christmasDay.php
@@ -1,4 +1,4 @@
- 'Božić',
- 'cs_CZ' => '1. svátek vánoční',
- 'cy_GB' => 'Nadolig',
- 'da_DK' => 'Juledag',
+ 'bs_Latn' => 'Božić',
+ 'cs' => '1. svátek vánoční',
+ 'cy' => 'Nadolig',
+ 'da' => 'Juledag',
+ 'de' => '1. Weihnachtsfeiertag',
'de_AT' => 'Christtag',
'de_CH' => 'Weihnachtstag',
- 'de_DE' => '1. Weihnachtsfeiertag',
- 'el_GR' => 'Χριστούγεννα',
- 'en_AU' => 'Christmas Day',
- 'en_GB' => 'Christmas Day',
- 'en_NZ' => 'Christmas Day',
+ 'el' => 'Χριστούγεννα',
+ 'en' => 'Christmas Day',
'en_US' => 'Christmas',
- 'en_ZA' => 'Christmas Day',
- 'es_ES' => 'Navidad',
- 'et_EE' => 'Esimene jõulupüha',
- 'fi_FI' => 'Joulupäivä',
- 'fr_BE' => 'Noël',
- 'fr_CH' => 'Noël',
- 'fr_FR' => 'Noël',
- 'hr_HR' => 'Božić',
- 'hu_HU' => 'Karácsony',
- 'it_CH' => 'Natale',
- 'it_IT' => 'Natale',
- 'lt_LT' => 'Šv. Kalėdos',
- 'lv_LV' => 'Ziemassvētki',
- 'nb_NO' => 'Første juledag',
+ 'es' => 'Navidad',
+ 'et' => 'Esimene jõulupüha',
+ 'fi' => 'Joulupäivä',
+ 'fr' => 'Noël',
+ 'hr' => 'Božić',
+ 'hu' => 'Karácsony',
+ 'it' => 'Natale',
+ 'ko' => '기독탄신일',
+ 'lt' => 'Šv. Kalėdos',
+ 'lv' => 'Ziemassvētki',
+ 'nb' => 'Første juledag',
+ 'nl' => 'Eerste kerstdag',
'nl_BE' => 'Kerstmis',
- 'nl_NL' => 'Kerstmis',
- 'pl_PL' => 'pierwszy dzień Bożego Narodzenia',
- 'pt_BR' => 'Natal',
- 'pt_PT' => 'Natal',
- 'ro_RO' => 'Crăciunul',
- 'ru_UA' => 'Рождество',
- 'sk_SK' => 'Prvý sviatok vianočný',
- 'sv_SE' => 'juldagen',
- 'uk_UA' => 'Різдво',
+ 'pl' => 'pierwszy dzień Bożego Narodzenia',
+ 'pt' => 'Natal',
+ 'ro' => 'Crăciunul',
+ 'ru' => 'Рождество',
+ 'sk' => 'Prvý sviatok vianočný',
+ 'sv' => 'juldagen',
+ 'uk' => 'Різдво',
];
diff --git a/src/Yasumi/data/translations/christmasEve.php b/src/Yasumi/data/translations/christmasEve.php
index 4583a1143..9315fcd27 100755
--- a/src/Yasumi/data/translations/christmasEve.php
+++ b/src/Yasumi/data/translations/christmasEve.php
@@ -1,4 +1,4 @@
- 'Štědrý den',
- 'cy_GB' => 'Noswyl Nadolig',
- 'da_DK' => 'Juleaften',
- 'de_CH' => 'Heiliger Abend',
- 'en_US' => 'Christmas Eve',
- 'et_EE' => 'Jõululaupäev',
- 'fr_BE' => 'Réveillon de Noël',
- 'fr_CH' => 'Réveillon de Noël',
- 'it_CH' => 'Vigilia di Natale',
- 'lt_LT' => 'Šv. Kūčios',
- 'lv_LV' => 'Ziemassvētku vakars',
- 'pt_PT' => 'Véspera de Natal',
- 'ro_RO' => 'Ajunul Crãciunului',
- 'sk_SK' => 'Štedrý deň',
- 'sv_SE' => 'julafton',
+ 'cs' => 'Štědrý den',
+ 'cy' => 'Noswyl Nadolig',
+ 'da' => 'Juleaften',
+ 'de' => 'Heiliger Abend',
+ 'en' => 'Christmas Eve',
+ 'et' => 'Jõululaupäev',
+ 'fr' => 'Réveillon de Noël',
+ 'it' => 'Vigilia di Natale',
+ 'ko' => '크리스마스 이브',
+ 'lt' => 'Šv. Kūčios',
+ 'lv' => 'Ziemassvētku vakars',
+ 'pt' => 'Véspera de Natal',
+ 'ro' => 'Ajunul Crãciunului',
+ 'sk' => 'Štedrý deň',
+ 'sv' => 'julafton',
];
diff --git a/src/Yasumi/data/translations/corpusChristi.php b/src/Yasumi/data/translations/corpusChristi.php
index 731842810..4506cea6d 100644
--- a/src/Yasumi/data/translations/corpusChristi.php
+++ b/src/Yasumi/data/translations/corpusChristi.php
@@ -1,4 +1,4 @@
- 'Fronleichnam',
- 'de_CH' => 'Fronleichnam',
- 'de_DE' => 'Fronleichnam',
- 'en_US' => 'Corpus Christi',
- 'es_ES' => 'Corpus Christi',
- 'fr_CH' => 'Fête-Dieu',
- 'hr_HR' => 'Tijelovo',
- 'it_CH' => 'Corpus Domini',
- 'pl_PL' => 'Boże Ciało',
- 'pt_BR' => 'Corpus Christi',
+ 'de' => 'Fronleichnam',
+ 'en' => 'Corpus Christi',
+ 'fr' => 'Fête-Dieu',
+ 'hr' => 'Tijelovo',
+ 'it' => 'Corpus Domini',
+ 'pl' => 'Boże Ciało',
+ 'pt' => 'Corpus Christi',
'pt_PT' => 'Corpo de Deus',
];
diff --git a/src/Yasumi/data/translations/dayAfterNewYearsDay.php b/src/Yasumi/data/translations/dayAfterNewYearsDay.php
index ece5d9031..53c0692dd 100644
--- a/src/Yasumi/data/translations/dayAfterNewYearsDay.php
+++ b/src/Yasumi/data/translations/dayAfterNewYearsDay.php
@@ -1,4 +1,4 @@
- 'Day after New Year\'s Day',
- 'en_US' => 'Day after New Year\'s Day',
+ 'en' => 'Day after New Year\'s Day',
+ 'ko' => '새해 연휴',
+ 'ro' => 'A doua zi după Anul Nou',
];
diff --git a/src/Yasumi/data/translations/dayOfReformation.php b/src/Yasumi/data/translations/dayOfReformation.php
index a0d17a2f3..acbac8543 100755
--- a/src/Yasumi/data/translations/dayOfReformation.php
+++ b/src/Yasumi/data/translations/dayOfReformation.php
@@ -1,4 +1,4 @@
- 'Tag der Reformation',
- 'en_US' => 'Day of Reformation',
+ 'de' => 'Tag der Reformation',
+ 'en' => 'Day of Reformation',
];
diff --git a/src/Yasumi/data/translations/easter.php b/src/Yasumi/data/translations/easter.php
index 1c1ba739a..4c431f116 100644
--- a/src/Yasumi/data/translations/easter.php
+++ b/src/Yasumi/data/translations/easter.php
@@ -1,4 +1,4 @@
- 'Uskrs',
- 'cy_GB' => 'Sul y Pasg',
- 'da_DK' => 'Påskedag',
- 'de_AT' => 'Ostersonntag',
+ 'bs_Latn' => 'Uskrs',
+ 'cy' => 'Sul y Pasg',
+ 'da' => 'Påskedag',
+ 'de' => 'Ostersonntag',
'de_CH' => 'Ostern',
- 'de_DE' => 'Ostersonntag',
- 'el_GR' => 'Κυριακή του Πάσχα',
- 'en_IE' => 'Easter Sunday',
- 'en_US' => 'Easter Sunday',
- 'et_EE' => 'Ülestõusmispühade 1. püha',
- 'fi_FI' => 'Pääsiäispäivä',
- 'fr_BE' => 'Pâques',
- 'fr_CH' => 'Pâques',
- 'ga_IE' => 'Domhnach Cásca',
- 'hr_HR' => 'Uskrs',
- 'hu_HU' => 'Húsvét',
- 'it_CH' => 'Pasqua',
- 'it_IT' => 'Pasqua',
- 'lt_LT' => 'Velykos',
- 'lv_LV' => 'Lieldienas',
- 'nb_NO' => 'Første påskedag',
- 'nl_BE' => 'Eerste Paasdag',
- 'nl_NL' => 'Eerste Paasdag',
- 'pl_PL' => 'Wielkanoc',
- 'pt_BR' => 'Páscoa',
- 'pt_PT' => 'Páscoa',
- 'ro_RO' => 'Paștele',
- 'ru_UA' => 'Пасха',
- 'sv_SE' => 'påskdagen',
- 'uk_UA' => 'Великдень',
+ 'el' => 'Κυριακή του Πάσχα',
+ 'en' => 'Easter Sunday',
+ 'et' => 'Ülestõusmispühade 1. püha',
+ 'fi' => 'Pääsiäispäivä',
+ 'fr' => 'Pâques',
+ 'ga' => 'Domhnach Cásca',
+ 'hr' => 'Uskrs',
+ 'hu' => 'Húsvét',
+ 'it' => 'Pasqua',
+ 'lt' => 'Velykos',
+ 'lv' => 'Lieldienas',
+ 'nb' => 'Første påskedag',
+ 'nl' => 'Eerste paasdag',
+ 'pl' => 'Wielkanoc',
+ 'pt' => 'Páscoa',
+ 'ro' => 'Paștele',
+ 'ru' => 'Пасха',
+ 'sv' => 'påskdagen',
+ 'uk' => 'Великдень',
];
diff --git a/src/Yasumi/data/translations/easterMonday.php b/src/Yasumi/data/translations/easterMonday.php
index 45cf0e624..ce6d42379 100644
--- a/src/Yasumi/data/translations/easterMonday.php
+++ b/src/Yasumi/data/translations/easterMonday.php
@@ -1,4 +1,4 @@
- 'Velikonoční pondělí',
- 'cy_GB' => 'Llun y Pasg',
- 'da_DK' => '2. påskedag',
- 'de_AT' => 'Ostermontag',
- 'de_CH' => 'Ostermontag',
- 'de_DE' => 'Ostermontag',
- 'el_GR' => 'Δευτέρα του Πάσχα',
- 'en_AU' => 'Easter Monday',
- 'en_GB' => 'Easter Monday',
- 'en_IE' => 'Easter Monday',
- 'en_NZ' => 'Easter Monday',
- 'en_US' => 'Easter Monday',
- 'es_ES' => 'Lunes de Pascua',
- 'fi_FI' => '2. pääsiäispäivä',
- 'fr_BE' => 'Lundi de Pâques',
- 'fr_CH' => 'Lundi de Pâques',
- 'fr_FR' => 'Lundi de Pâques',
- 'ga_IE' => 'Luan Cásca',
- 'hr_HR' => 'Uskršnji ponedjeljak',
- 'hu_HU' => 'Húsvéthétfő',
+ 'cs' => 'Velikonoční pondělí',
+ 'cy' => 'Llun y Pasg',
+ 'da' => '2. påskedag',
+ 'de' => 'Ostermontag',
+ 'el' => 'Δευτέρα του Πάσχα',
+ 'en' => 'Easter Monday',
+ 'es' => 'Lunes de Pascua',
+ 'fi' => '2. pääsiäispäivä',
+ 'fr' => 'Lundi de Pâques',
+ 'ga' => 'Luan Cásca',
+ 'hr' => 'Uskršnji ponedjeljak',
+ 'hu' => 'Húsvéthétfő',
+ 'it' => 'Lunedì dell\'Angelo',
'it_CH' => 'Lunedi di Pasqua',
- 'it_IT' => 'Lunedi` dell\'Angelo',
- 'lt_LT' => 'Antroji Velykų diena',
- 'lv_LV' => 'Otrās Lieldienas',
- 'nb_NO' => 'Andre påskedag',
+ 'lt' => 'Antroji Velykų diena',
+ 'lv' => 'Otrās Lieldienas',
+ 'nb' => 'Andre påskedag',
'nl_BE' => 'Paasmaandag',
- 'nl_NL' => 'Tweede Paasdag',
- 'pl_PL' => 'Poniedziałek Wielkanocny',
- 'ro_RO' => 'A doua zi de Paște',
- 'sk_SK' => 'Veľkonočný pondelok',
- 'sv_SE' => 'annandag påsk',
+ 'nl' => 'Tweede paasdag',
+ 'pl' => 'Poniedziałek Wielkanocny',
+ 'ro' => 'A doua zi de Paște',
+ 'sk' => 'Veľkonočný pondelok',
+ 'sv' => 'annandag påsk',
];
diff --git a/src/Yasumi/data/translations/epiphany.php b/src/Yasumi/data/translations/epiphany.php
index 9e1bbb216..6f882d100 100644
--- a/src/Yasumi/data/translations/epiphany.php
+++ b/src/Yasumi/data/translations/epiphany.php
@@ -1,4 +1,4 @@
- 'Heilige Drei Könige',
'de_CH' => 'Heilige Drei Könige',
- 'de_DE' => 'Heilige 3 Könige',
- 'el_GR' => 'Θεοφάνεια',
- 'en_US' => 'Epiphany',
- 'es_ES' => 'Día de Reyes',
- 'fi_FI' => 'Loppiainen',
- 'fr_BE' => 'Epiphanie',
- 'fr_CH' => 'Epiphanie',
- 'hr_HR' => 'Sveta tri kralja',
- 'it_CH' => 'Epifania',
- 'it_IT' => 'Epifania',
- 'ja_JP' => 'エピファニー',
- 'nl_BE' => 'Drie Koningen',
- 'nl_NL' => 'Drie Koningen',
- 'pl_PL' => 'Święto Trzech Króli',
- 'sk_SK' => 'Zjavenie Pána / Traja králi',
- 'sv_SE' => 'trettondedag jul',
+ 'de' => 'Heilige 3 Könige',
+ 'el' => 'Θεοφάνεια',
+ 'en' => 'Epiphany',
+ 'es' => 'Día de Reyes',
+ 'fi' => 'Loppiainen',
+ 'fr' => 'Epiphanie',
+ 'hr' => 'Sveta tri kralja',
+ 'it' => 'Epifania',
+ 'ja' => 'エピファニー',
+ 'nl' => 'Drie Koningen',
+ 'pl' => 'Święto Trzech Króli',
+ 'sk' => 'Zjavenie Pána / Traja králi',
+ 'sv' => 'trettondedag jul',
];
diff --git a/src/Yasumi/data/translations/epiphanyEve.php b/src/Yasumi/data/translations/epiphanyEve.php
new file mode 100644
index 000000000..5b24ddaff
--- /dev/null
+++ b/src/Yasumi/data/translations/epiphanyEve.php
@@ -0,0 +1,18 @@
+
+ */
+
+// Translations for Epiphany Eve
+return [
+ 'da' => 'Helligtrekongersaften',
+ 'en' => 'Epiphany Eve',
+ 'sv' => 'trettondagsafton',
+];
diff --git a/src/Yasumi/data/translations/fathersDay.php b/src/Yasumi/data/translations/fathersDay.php
index 0a87da240..9d8b68cd8 100755
--- a/src/Yasumi/data/translations/fathersDay.php
+++ b/src/Yasumi/data/translations/fathersDay.php
@@ -1,4 +1,4 @@
- 'Vatertag',
- 'el_GR' => 'Γιορτή του πατέρα',
- 'en_US' => 'Father\'s Day',
- 'fr_BE' => 'Fête des pères',
- 'fr_CH' => 'Fête des pères',
- 'it_CH' => 'Festa del papà',
- 'nl_BE' => 'Vaderdag',
- 'nl_NL' => 'Vaderdag',
- 'pt_PT' => 'Dia do Pai',
- 'ro_RO' => 'Ziua Tatălui',
- 'sk_SK' => 'Deň otcov',
+ 'de' => 'Vatertag',
+ 'el' => 'Γιορτή του πατέρα',
+ 'en' => 'Father\'s Day',
+ 'fr' => 'Fête des pères',
+ 'it' => 'Festa del papà',
+ 'nl' => 'Vaderdag',
+ 'pt' => 'Dia do Pai',
+ 'ro' => 'Ziua Tatălui',
+ 'sk' => 'Deň otcov',
];
diff --git a/src/Yasumi/data/translations/goodFriday.php b/src/Yasumi/data/translations/goodFriday.php
index 02823ca89..3fc7edb8e 100644
--- a/src/Yasumi/data/translations/goodFriday.php
+++ b/src/Yasumi/data/translations/goodFriday.php
@@ -1,4 +1,4 @@
- 'Velký pátek',
- 'cy_GB' => 'Gwener y Groglith',
- 'da_DK' => 'Langfredag',
- 'de_CH' => 'Karfreitag',
- 'de_DE' => 'Karfreitag',
- 'el_GR' => 'Μεγάλη Παρασκευή',
- 'en_AU' => 'Good Friday',
- 'en_GB' => 'Good Friday',
- 'en_IE' => 'Good Friday',
- 'en_NZ' => 'Good Friday',
- 'en_US' => 'Good Friday',
- 'en_ZA' => 'Good Friday',
- 'es_ES' => 'Viernes Santo',
- 'et_EE' => 'Suur Reede',
- 'fi_FI' => 'Pitkäperjantai',
- 'fr_BE' => 'Vendredi Saint',
- 'fr_CH' => 'Vendredi Saint',
- 'fr_FR' => 'Vendredi Saint',
- 'ga_IE' => 'Aoine an Chéasta',
- 'hu_HU' => 'Nagypéntek',
- 'it_CH' => 'Venerdi Santo',
- 'ja_JP' => 'グッドフライデー',
- 'lv_LV' => 'Lielā Piektdiena',
- 'nb_NO' => 'Langfredag',
- 'nl_BE' => 'Goede Vrijdag',
- 'nl_NL' => 'Goede Vrijdag',
- 'pl_PL' => 'Wielki Piątek',
- 'pt_BR' => 'Sexta feira santa',
+ 'cs' => 'Velký pátek',
+ 'cy' => 'Gwener y Groglith',
+ 'da' => 'Langfredag',
+ 'de' => 'Karfreitag',
+ 'el' => 'Μεγάλη Παρασκευή',
+ 'en' => 'Good Friday',
+ 'es' => 'Viernes Santo',
+ 'et' => 'Suur Reede',
+ 'fi' => 'Pitkäperjantai',
+ 'fr' => 'Vendredi Saint',
+ 'ga' => 'Aoine an Chéasta',
+ 'hu' => 'Nagypéntek',
+ 'it' => 'Venerdi Santo',
+ 'ja' => 'グッドフライデー',
+ 'lv' => 'Lielā Piektdiena',
+ 'nb' => 'Langfredag',
+ 'nl' => 'Goede Vrijdag',
+ 'pl' => 'Wielki Piątek',
+ 'pt' => 'Sexta feira santa',
'pt_PT' => 'Sexta-feira Santa',
- 'sk_SK' => 'Veľký piatok',
- 'sv_SE' => 'långfredagen',
+ 'sk' => 'Veľký piatok',
+ 'sv' => 'långfredagen',
];
diff --git a/src/Yasumi/data/translations/immaculateConception.php b/src/Yasumi/data/translations/immaculateConception.php
index c7e677a4a..bace8be7f 100644
--- a/src/Yasumi/data/translations/immaculateConception.php
+++ b/src/Yasumi/data/translations/immaculateConception.php
@@ -1,4 +1,4 @@
- 'Mariä Empfängnis',
- 'de_CH' => 'Mariä Empfängnis',
- 'el_GR' => 'Ευαγγελισμός της Θεοτόκου',
- 'en_US' => 'Immaculate Conception',
- 'es_ES' => 'Inmaculada Concepción',
- 'fr_BE' => 'Immaculée Conception',
- 'fr_CH' => 'Immaculée Conception',
- 'it_CH' => 'Immacolata Concezione',
- 'it_IT' => 'Immacolata Concezione',
- 'pt_PT' => 'Dia da Imaculada Conceição',
+ 'de' => 'Mariä Empfängnis',
+ 'el' => 'Ευαγγελισμός της Θεοτόκου',
+ 'en' => 'Immaculate Conception',
+ 'es' => 'Inmaculada Concepción',
+ 'fr' => 'Immaculée Conception',
+ 'it' => 'Immacolata Concezione',
+ 'pt' => 'Dia da Imaculada Conceição',
];
diff --git a/src/Yasumi/data/translations/internationalWomensDay.php b/src/Yasumi/data/translations/internationalWomensDay.php
index 56267a472..a1ea9c00a 100755
--- a/src/Yasumi/data/translations/internationalWomensDay.php
+++ b/src/Yasumi/data/translations/internationalWomensDay.php
@@ -1,4 +1,4 @@
- 'Internationaler Frauentag',
- 'en_US' => 'International Women\'s Day',
- 'ru_RU' => 'Международный женский день',
- 'uk_UA' => 'Міжнародний жіночий день',
- 'ru_UA' => 'Международный женский день',
+ 'de' => 'Internationaler Frauentag',
+ 'en' => 'International Women\'s Day',
+ 'ko' => '국제 여성의 날',
+ 'ru' => 'Международный женский день',
+ 'uk' => 'Міжнародний жіночий день',
];
diff --git a/src/Yasumi/data/translations/internationalWorkersDay.php b/src/Yasumi/data/translations/internationalWorkersDay.php
index cea79b49d..267337b3e 100755
--- a/src/Yasumi/data/translations/internationalWorkersDay.php
+++ b/src/Yasumi/data/translations/internationalWorkersDay.php
@@ -1,4 +1,4 @@
- 'Praznik rada',
- 'cs_CZ' => 'Svátek práce',
- 'da_DK' => 'Første maj',
+ 'bs_Latn' => 'Praznik rada',
+ 'cs' => 'Svátek práce',
+ 'da' => 'Første maj',
+ 'de' => 'Tag der Arbeit',
'de_AT' => 'Staatsfeiertag',
- 'de_CH' => 'Tag der Arbeit',
- 'de_DE' => 'Tag der Arbeit',
- 'el_GR' => 'Εργατική Πρωτομαγιά',
+ 'el' => 'Εργατική Πρωτομαγιά',
'en_US' => 'International Workers\' Day',
'en_ZA' => 'Workers\' Day',
- 'es_ES' => 'Día del Trabajador',
- 'et_EE' => 'Kevadpüha',
- 'fi_FI' => 'Vappu',
- 'fr_BE' => 'Fête du Travail',
- 'fr_CH' => 'Fête du Travail',
- 'fr_FR' => 'Fête du Travail',
- 'hr_HR' => 'Praznik rada',
- 'hu_HU' => 'A munka ünnepe',
+ 'es' => 'Día del Trabajador',
+ 'et' => 'Kevadpüha',
+ 'fi' => 'Vappu',
+ 'fr' => 'Fête du Travail',
+ 'hr' => 'Praznik rada',
+ 'hu' => 'A munka ünnepe',
+ 'it' => 'Festa del Lavoro',
'it_CH' => 'Festa dei lavoratori',
- 'it_IT' => 'Festa del Lavoro',
- 'ja_JP' => '労働の日',
- 'lt_LT' => 'Tarptautinė darbo diena',
- 'lv_LV' => 'Darba svētki',
- 'nb_NO' => 'Arbeidernes dag',
- 'nl_BE' => 'Dag van de arbeid',
- 'nl_NL' => 'Dag van de arbeid',
- 'pl_PL' => 'Święto Pracy',
- 'pt_BR' => 'Dia internacional do trabalhador',
+ 'ja' => '労働の日',
+ 'ko' => '노동절',
+ 'lt' => 'Tarptautinė darbo diena',
+ 'lv' => 'Darba svētki',
+ 'nb' => 'Arbeidernes dag',
+ 'nl' => 'Dag van de arbeid',
+ 'pl' => 'Święto Pracy',
+ 'pt' => 'Dia internacional do trabalhador',
'pt_PT' => 'Dia do Trabalhador',
- 'ro_RO' => 'Ziua internațională a muncii',
- 'ru_UA' => 'День международной солидарности трудящихся',
- 'sk_SK' => 'Sviatok práce',
- 'sv_SE' => 'Första maj',
- 'uk_UA' => 'День міжнародної солідарності трудящих',
+ 'ro' => 'Ziua internațională a muncii',
+ 'ru' => 'День международной солидарности трудящихся',
+ 'sk' => 'Sviatok práce',
+ 'sv' => 'Första maj',
+ 'uk' => 'День міжнародної солідарності трудящих',
];
diff --git a/src/Yasumi/data/translations/labourDay.php b/src/Yasumi/data/translations/labourDay.php
index 50ebce393..5c7a060df 100644
--- a/src/Yasumi/data/translations/labourDay.php
+++ b/src/Yasumi/data/translations/labourDay.php
@@ -1,4 +1,4 @@
- 'Labour Day',
- 'en_NZ' => 'Labour Day',
- 'en_US' => 'Labour Day',
- 'ja_JP' => '労働の日',
- 'nl_BE' => 'Dag van de arbeid',
- 'nl_NL' => 'Dag van de arbeid',
- 'sk_SK' => 'Sviatok práce',
+ 'en' => 'Labour Day',
+ 'ja' => '労働の日',
+ 'ko' => '노동절',
+ 'nl' => 'Dag van de arbeid',
+ 'sk' => 'Sviatok práce',
];
diff --git a/src/Yasumi/data/translations/maundyThursday.php b/src/Yasumi/data/translations/maundyThursday.php
index f3ca528b1..4c1f321d4 100644
--- a/src/Yasumi/data/translations/maundyThursday.php
+++ b/src/Yasumi/data/translations/maundyThursday.php
@@ -1,4 +1,4 @@
- 'Skærtorsdag',
- 'el_GR' => 'Μεγάλη Πέμπτη',
- 'en_US' => 'Maundy Thursday',
- 'es_ES' => 'Jueves Santo',
- 'nb_NO' => 'Skjærtorsdag',
+ 'da' => 'Skærtorsdag',
+ 'el' => 'Μεγάλη Πέμπτη',
+ 'en' => 'Maundy Thursday',
+ 'es' => 'Jueves Santo',
+ 'nb' => 'Skjærtorsdag',
];
diff --git a/src/Yasumi/data/translations/mothersDay.php b/src/Yasumi/data/translations/mothersDay.php
index 2680faac2..0ee75170c 100755
--- a/src/Yasumi/data/translations/mothersDay.php
+++ b/src/Yasumi/data/translations/mothersDay.php
@@ -1,4 +1,4 @@
- 'Muttertag',
- 'el_GR' => 'Ημέρα της μητέρας',
- 'en_US' => 'Mother\'s Day',
- 'fr_BE' => 'Fête des mères',
- 'fr_CH' => 'Fête des mères',
- 'it_CH' => 'Festa della mamma',
- 'nl_BE' => 'Moederdag',
- 'nl_NL' => 'Moederdag',
- 'pt_PT' => 'Dia da Mãe',
- 'ro_RO' => 'Ziua Mamei',
- 'sk_SK' => 'Deň matiek',
+ 'de' => 'Muttertag',
+ 'el' => 'Ημέρα της μητέρας',
+ 'en' => 'Mother\'s Day',
+ 'fr' => 'Fête des mères',
+ 'it' => 'Festa della mamma',
+ 'nl' => 'Moederdag',
+ 'pt' => 'Dia da Mãe',
+ 'ro' => 'Ziua Mamei',
+ 'sk' => 'Deň matiek',
];
diff --git a/src/Yasumi/data/translations/newYearsDay.php b/src/Yasumi/data/translations/newYearsDay.php
index 77f3fbf7b..5a787ffac 100755
--- a/src/Yasumi/data/translations/newYearsDay.php
+++ b/src/Yasumi/data/translations/newYearsDay.php
@@ -1,4 +1,4 @@
- 'Nova godina',
- 'cs_CZ' => 'Den obnovy samostatného českého státu a Nový rok',
- 'cy_GB' => 'Dydd Calan',
- 'da_DK' => 'Nytårsdag',
- 'de_AT' => 'Neujahr',
- 'de_CH' => 'Neujahr',
- 'de_DE' => 'Neujahr',
- 'el_GR' => 'Πρωτοχρονιά',
- 'en_AU' => 'New Year\'s Day',
- 'en_GB' => 'New Year\'s Day',
- 'en_IE' => 'New Year\'s Day',
- 'en_NZ' => 'New Year\'s Day',
- 'en_US' => 'New Year\'s Day',
- 'en_ZA' => 'New Year\'s Day',
- 'es_ES' => 'Año Nuevo',
- 'et_EE' => 'Uusaasta',
- 'fi_FI' => 'Uudenvuodenpäivä',
+ 'bs_Latn' => 'Nova godina',
+ 'cs' => 'Nový rok',
+ 'cy' => 'Dydd Calan',
+ 'da' => 'Nytårsdag',
+ 'de' => 'Neujahr',
+ 'el' => 'Πρωτοχρονιά',
+ 'en' => 'New Year\'s Day',
+ 'es' => 'Año Nuevo',
+ 'et' => 'Uusaasta',
+ 'fi' => 'Uudenvuodenpäivä',
'fr_BE' => 'Nouvel An',
'fr_CH' => 'Nouvel An',
- 'fr_FR' => 'Jour de l\'An',
- 'ga_IE' => 'Lá Caille',
- 'hr_HR' => 'Nova godina',
- 'hu_HU' => 'Újév',
- 'it_CH' => 'Capodanno',
- 'it_IT' => 'Capodanno',
- 'ja_JP' => '元日',
- 'lt_LT' => 'Naujųjų metų diena',
- 'lv_LV' => 'Jaunais Gads',
- 'nb_NO' => 'Første nyttårsdag',
- 'nl_BE' => 'Nieuwjaar',
- 'nl_NL' => 'Nieuwjaar',
- 'pl_PL' => 'Nowy Rok',
- 'pt_BR' => 'Ano novo',
+ 'fr' => 'Jour de l\'An',
+ 'ga' => 'Lá Caille',
+ 'hr' => 'Nova godina',
+ 'hu' => 'Újév',
+ 'it' => 'Capodanno',
+ 'ja' => '元日',
+ 'ko' => '새해',
+ 'lt' => 'Naujųjų metų diena',
+ 'lv' => 'Jaunais Gads',
+ 'nb' => 'Første nyttårsdag',
+ 'nl' => 'Nieuwjaar',
+ 'pl' => 'Nowy Rok',
+ 'pt' => 'Ano novo',
'pt_PT' => 'Dia de Ano Novo',
- 'ro_RO' => 'Anul Nou',
- 'ru_RU' => 'Новый год',
- 'ru_UA' => 'Новый Год',
- 'sk_SK' => 'Deň vzniku Slovenskej republiky',
- 'sv_SE' => 'nyårsdagen',
- 'uk_UA' => 'Новий Рік',
+ 'ro' => 'Anul Nou',
+ 'ru' => 'Новый год',
+ 'sk' => 'Nový rok',
+ 'sv' => 'nyårsdagen',
+ 'uk' => 'Новий Рік',
];
diff --git a/src/Yasumi/data/translations/newYearsEve.php b/src/Yasumi/data/translations/newYearsEve.php
index d080aa58a..995e8dc01 100755
--- a/src/Yasumi/data/translations/newYearsEve.php
+++ b/src/Yasumi/data/translations/newYearsEve.php
@@ -1,4 +1,4 @@
- 'Nytårsaften',
- 'en_US' => 'New Year\'s Eve',
- 'lv_LV' => 'Vecgada vakars',
+ 'da' => 'Nytårsaften',
+ 'en' => 'New Year\'s Eve',
+ 'ko' => '신년전야',
+ 'lv' => 'Vecgada vakars',
+ 'sv' => 'nyårsafton',
];
diff --git a/src/Yasumi/data/translations/pentecost.php b/src/Yasumi/data/translations/pentecost.php
index 630db0ed4..345feabd1 100755
--- a/src/Yasumi/data/translations/pentecost.php
+++ b/src/Yasumi/data/translations/pentecost.php
@@ -1,4 +1,4 @@
- 'Pinsedag',
+ 'da' => 'Pinsedag',
+ 'de' => 'Pfingstsonntag',
'de_AT' => 'Pfingsten',
'de_CH' => 'Pfingsten',
- 'de_DE' => 'Pfingstsonntag',
- 'el_GR' => 'Πεντηκοστή',
- 'en_IE' => 'Whitsunday',
- 'en_US' => 'Whitsunday',
- 'et_EE' => 'Nelipühade 1. püha',
- 'fi_FI' => 'Helluntaipäivä',
- 'fr_BE' => 'Pentecôte',
- 'fr_CH' => 'Pentecôte',
- 'ga_IE' => 'Domhnach Cincíse',
- 'hu_HU' => 'Pünkösd',
- 'it_CH' => 'Pentecoste',
- 'nb_NO' => 'Første pinsedag',
- 'nl_BE' => 'Eerste Pinksterdag',
- 'nl_NL' => 'Eerste Pinksterdag',
- 'pl_PL' => 'Zielone Świątki',
- 'ro_RO' => 'Rusaliile',
- 'ru_UA' => 'Троица',
- 'sv_SE' => 'Pingstdagen',
- 'uk_UA' => 'Трійця',
+ 'el' => 'Πεντηκοστή',
+ 'en' => 'Whitsunday',
+ 'et' => 'Nelipühade 1. püha',
+ 'fi' => 'Helluntaipäivä',
+ 'fr' => 'Pentecôte',
+ 'ga' => 'Domhnach Cincíse',
+ 'hu' => 'Pünkösd',
+ 'it' => 'Pentecoste',
+ 'nb' => 'Første pinsedag',
+ 'nl' => 'Eerste pinksterdag',
+ 'pl' => 'Zielone Świątki',
+ 'ro' => 'Rusaliile',
+ 'ru' => 'Троица',
+ 'sv' => 'Pingstdagen',
+ 'uk' => 'Трійця',
];
diff --git a/src/Yasumi/data/translations/pentecostMonday.php b/src/Yasumi/data/translations/pentecostMonday.php
index 1390391db..dc592f80f 100755
--- a/src/Yasumi/data/translations/pentecostMonday.php
+++ b/src/Yasumi/data/translations/pentecostMonday.php
@@ -1,4 +1,4 @@
- '2. pinsedag',
- 'de_AT' => 'Pfingstmontag',
- 'de_CH' => 'Pfingstmontag',
- 'de_DE' => 'Pfingstmontag',
- 'el_GR' => 'Αγίου Πνεύματος',
- 'en_IE' => 'Whitmonday',
- 'en_US' => 'Whitmonday',
- 'fr_BE' => 'Lundi de Pentecôte',
- 'fr_CH' => 'Lundi de Pentecôte',
- 'fr_FR' => 'Lundi de Pentecôte',
- 'ga_IE' => 'Luan Cincíse',
- 'hu_HU' => 'Pünkösdhétfő',
- 'it_CH' => 'Lunedi di Pentecoste',
- 'nb_NO' => 'Andre pinsedag',
+ 'da' => '2. pinsedag',
+ 'de' => 'Pfingstmontag',
+ 'el' => 'Αγίου Πνεύματος',
+ 'en' => 'Whitmonday',
+ 'fr' => 'Lundi de Pentecôte',
+ 'ga' => 'Luan Cincíse',
+ 'hu' => 'Pünkösdhétfő',
+ 'it' => 'Lunedi di Pentecoste',
+ 'nb' => 'Andre pinsedag',
+ 'nl' => 'Tweede pinksterdag',
'nl_BE' => 'Pinkstermaandag',
- 'nl_NL' => 'Tweede Pinksterdag',
- 'ro_RO' => 'A doua zi de Rusalii',
+ 'ro' => 'A doua zi de Rusalii',
];
diff --git a/src/Yasumi/data/translations/portugalDay.php b/src/Yasumi/data/translations/portugalDay.php
index d91a0a165..456677086 100644
--- a/src/Yasumi/data/translations/portugalDay.php
+++ b/src/Yasumi/data/translations/portugalDay.php
@@ -1,4 +1,4 @@
- 'Portugal Day',
- 'pt_PT' => 'Dia de Portugal',
+ 'en' => 'Portugal Day',
+ 'pt' => 'Dia de Portugal',
];
diff --git a/src/Yasumi/data/translations/portugueseRepublicDay.php b/src/Yasumi/data/translations/portugueseRepublicDay.php
index 22d37b3fd..a05c1ad48 100644
--- a/src/Yasumi/data/translations/portugueseRepublicDay.php
+++ b/src/Yasumi/data/translations/portugueseRepublicDay.php
@@ -1,4 +1,4 @@
- 'Implantation of the Portuguese Republic',
- 'pt_PT' => 'Implantação da República Portuguesa',
+ 'en' => 'Implantation of the Portuguese Republic',
+ 'pt' => 'Implantação da República Portuguesa',
];
diff --git a/src/Yasumi/data/translations/reformationDay.php b/src/Yasumi/data/translations/reformationDay.php
index 1e29c045a..1cdfb1e25 100755
--- a/src/Yasumi/data/translations/reformationDay.php
+++ b/src/Yasumi/data/translations/reformationDay.php
@@ -1,4 +1,4 @@
- 'Reformationstag',
- 'en_US' => 'Reformation Day',
+ 'de' => 'Reformationstag',
+ 'en' => 'Reformation Day',
];
diff --git a/src/Yasumi/data/translations/restorationOfIndepence.php b/src/Yasumi/data/translations/restorationOfIndepence.php
index 50dfdcfbf..725850a39 100644
--- a/src/Yasumi/data/translations/restorationOfIndepence.php
+++ b/src/Yasumi/data/translations/restorationOfIndepence.php
@@ -1,4 +1,4 @@
- 'Restoration of Independence',
- 'pt_PT' => 'Restauração da Independência',
+ 'en' => 'Restoration of Independence',
+ 'pt' => 'Restauração da Independência',
];
diff --git a/src/Yasumi/data/translations/secondChristmasDay.php b/src/Yasumi/data/translations/secondChristmasDay.php
index d7c9af1b3..252abc852 100755
--- a/src/Yasumi/data/translations/secondChristmasDay.php
+++ b/src/Yasumi/data/translations/secondChristmasDay.php
@@ -1,4 +1,4 @@
- '2. svátek vánoční',
- 'da_DK' => '2. Juledag',
+ 'cs' => '2. svátek vánoční',
+ 'da' => '2. juledag',
+ 'de' => '2. Weihnachtsfeiertag',
'de_AT' => 'Stefanitag',
- 'de_DE' => '2. Weihnachtsfeiertag',
- 'el_GR' => 'Σύναξις Υπεραγίας Θεοτόκου Μαρίας',
- 'en_AU' => 'Boxing Day',
- 'en_GB' => 'Boxing Day',
- 'en_NZ' => 'Boxing Day',
+ 'el' => 'Σύναξις Υπεραγίας Θεοτόκου Μαρίας',
+ 'en' => 'Boxing Day',
'en_US' => 'Second Christmas Day',
'en_ZA' => 'Day of Goodwill',
- 'et_EE' => 'Teine Jõulupüha',
- 'fi_FI' => '2. joulupäivä',
- 'hu_HU' => 'Karácsony másnapja',
- 'lt_LT' => 'Kalėdos (antra diena)',
- 'lv_LV' => 'Otrie Ziemassvētki',
- 'nb_NO' => 'Andre juledag',
- 'nl_BE' => 'Tweede Kerstdag',
- 'nl_NL' => 'Tweede Kerstdag',
- 'pl_PL' => 'drugi dzień Bożego Narodzenia',
- 'ro_RO' => 'A doua zi de Crăciun',
- 'sk_SK' => 'Druhý sviatok vianočný',
- 'sv_SE' => 'annandag jul',
+ 'et' => 'Teine Jõulupüha',
+ 'fi' => '2. joulupäivä',
+ 'hu' => 'Karácsony másnapja',
+ 'ko' => '성탄절 연휴',
+ 'lt' => 'Kalėdos (antra diena)',
+ 'lv' => 'Otrie Ziemassvētki',
+ 'nb' => 'Andre juledag',
+ 'nl' => 'Tweede kerstdag',
+ 'pl' => 'drugi dzień Bożego Narodzenia',
+ 'ro' => 'A doua zi de Crăciun',
+ 'sk' => 'Druhý sviatok vianočný',
+ 'sv' => 'annandag jul',
];
diff --git a/src/Yasumi/data/translations/secondNewYearsDay.php b/src/Yasumi/data/translations/secondNewYearsDay.php
new file mode 100755
index 000000000..8a0df1847
--- /dev/null
+++ b/src/Yasumi/data/translations/secondNewYearsDay.php
@@ -0,0 +1,17 @@
+
+ */
+
+// Translations for New Year's Day
+return [
+ 'da' => '2. nytårsdag',
+ 'en' => '2nd January',
+];
diff --git a/src/Yasumi/data/translations/stAndrewsDay.php b/src/Yasumi/data/translations/stAndrewsDay.php
new file mode 100644
index 000000000..197f198e4
--- /dev/null
+++ b/src/Yasumi/data/translations/stAndrewsDay.php
@@ -0,0 +1,17 @@
+
+ */
+
+// Translations for St. Andrew's Day
+return [
+ 'en' => 'St. Andrew\'s Day',
+ 'ro' => 'Sfântul Andrei',
+];
diff --git a/src/Yasumi/data/translations/stDavidsDay.php b/src/Yasumi/data/translations/stDavidsDay.php
index b721ee90e..564b88b8f 100644
--- a/src/Yasumi/data/translations/stDavidsDay.php
+++ b/src/Yasumi/data/translations/stDavidsDay.php
@@ -1,4 +1,4 @@
- 'Dydd Gŵyl Dewi',
- 'en_GB' => 'St. David\'s Day',
- 'en_US' => 'St. David\'s Day',
+ 'cy' => 'Dydd Gŵyl Dewi',
+ 'en' => 'St. David\'s Day',
];
diff --git a/src/Yasumi/data/translations/stGeorgesDay.php b/src/Yasumi/data/translations/stGeorgesDay.php
index d43a97688..c8ab6e1a4 100644
--- a/src/Yasumi/data/translations/stGeorgesDay.php
+++ b/src/Yasumi/data/translations/stGeorgesDay.php
@@ -1,4 +1,4 @@
- 'Αγίου Γεωργίου',
- 'en_US' => 'St. George\'s Day',
- 'es_ES' => 'San Jorge',
+ 'el' => 'Αγίου Γεωργίου',
+ 'en' => 'St. George\'s Day',
+ 'es' => 'San Jorge',
];
diff --git a/src/Yasumi/data/translations/stJohnsDay.php b/src/Yasumi/data/translations/stJohnsDay.php
index 3e2b272e6..50a4e577c 100644
--- a/src/Yasumi/data/translations/stJohnsDay.php
+++ b/src/Yasumi/data/translations/stJohnsDay.php
@@ -1,4 +1,4 @@
- 'Σύναξις Προφήτου Προδρόμου και Βαπτιστού Ιωάννου',
- 'en_US' => 'St. John\'s Day',
- 'es_ES' => 'Sant Joan',
- 'et_EE' => 'Jaanipäev',
- 'fi_FI' => 'Juhannuspäivä',
- 'lt_LT' => 'Rasos ir Joninių diena',
- 'lv_LV' => 'Jāņi',
- 'sv_SE' => 'midsommardagen',
+ 'da' => 'Sankthansaften',
+ 'el' => 'Σύναξις Προφήτου Προδρόμου και Βαπτιστού Ιωάννου',
+ 'en' => 'St. John\'s Day',
+ 'es' => 'Sant Joan',
+ 'et' => 'Jaanipäev',
+ 'fi' => 'Juhannuspäivä',
+ 'lt' => 'Rasos ir Joninių diena',
+ 'lv' => 'Jāņi',
+ 'sv' => 'midsommardagen',
];
diff --git a/src/Yasumi/data/translations/stJohnsEve.php b/src/Yasumi/data/translations/stJohnsEve.php
new file mode 100644
index 000000000..0027bd417
--- /dev/null
+++ b/src/Yasumi/data/translations/stJohnsEve.php
@@ -0,0 +1,18 @@
+
+ */
+
+// Translations for St. John's Eve
+return [
+ 'da' => 'Sankthansaften',
+ 'en' => 'St. John\'s Eve',
+ 'sv' => 'midsommarafton',
+];
diff --git a/src/Yasumi/data/translations/stJosephsDay.php b/src/Yasumi/data/translations/stJosephsDay.php
index 9cf6ba0bd..61f45db59 100644
--- a/src/Yasumi/data/translations/stJosephsDay.php
+++ b/src/Yasumi/data/translations/stJosephsDay.php
@@ -1,4 +1,4 @@
- 'Josephstag',
- 'en_US' => 'St. Joseph\'s Day',
- 'es_ES' => 'San José',
- 'fr_CH' => 'Saint-Joseph',
- 'it_CH' => 'San Giuseppe',
+ 'de' => 'Josephstag',
+ 'en' => 'St. Joseph\'s Day',
+ 'es' => 'San José',
+ 'fr' => 'Saint-Joseph',
+ 'it' => 'San Giuseppe',
];
diff --git a/src/Yasumi/data/translations/stMartinsDay.php b/src/Yasumi/data/translations/stMartinsDay.php
index c7472a78e..384ae2b20 100644
--- a/src/Yasumi/data/translations/stMartinsDay.php
+++ b/src/Yasumi/data/translations/stMartinsDay.php
@@ -1,4 +1,4 @@
- 'St. Martin\'s Day',
- 'nl_BE' => 'Sint Maarten',
- 'nl_NL' => 'Sint Maarten',
+ 'en' => 'St. Martin\'s Day',
+ 'nl' => 'Sint Maarten',
];
diff --git a/src/Yasumi/data/translations/stStephensDay.php b/src/Yasumi/data/translations/stStephensDay.php
index b1b6a71a3..6259a6ed7 100644
--- a/src/Yasumi/data/translations/stStephensDay.php
+++ b/src/Yasumi/data/translations/stStephensDay.php
@@ -1,4 +1,4 @@
- 'Gŵyl San Steffan',
- 'de_CH' => 'Stephanstag',
- 'en_IE' => 'St. Stephen\'s Day',
- 'en_US' => 'St. Stephen\'s Day',
- 'es_ES' => 'Sant Esteve',
- 'fr_CH' => 'Saint-Etienne',
- 'fr_FR' => 'Saint-Étienne',
- 'ga_IE' => 'Lá Fhéile Stiofáin',
- 'hr_HR' => 'Sveti Stjepan',
- 'it_CH' => 'Santo Stefano',
- 'it_IT' => 'Santo Stefano',
+ 'cy' => 'Gŵyl San Steffan',
+ 'de' => 'Stephanstag',
+ 'en' => 'St. Stephen\'s Day',
+ 'es' => 'Sant Esteve',
+ 'fr' => 'Saint-Étienne',
+ 'ga' => 'Lá Fhéile Stiofáin',
+ 'hr' => 'Sveti Stjepan',
+ 'it' => 'Santo Stefano',
];
diff --git a/src/Yasumi/data/translations/substituteHoliday.php b/src/Yasumi/data/translations/substituteHoliday.php
new file mode 100755
index 000000000..a6333cf32
--- /dev/null
+++ b/src/Yasumi/data/translations/substituteHoliday.php
@@ -0,0 +1,21 @@
+
+ */
+
+// Translation pattern for substitute holidays.
+return [
+ 'da' => '{0} (erstatning)',
+ 'en' => '{0} (substitute day)',
+ 'en_US' => '{0} observed',
+ 'en_CA' => '{0} observed',
+ 'ja' => '振替休日 ({0})',
+ 'ko' => '대체공휴일',
+];
diff --git a/src/Yasumi/data/translations/summerTime.php b/src/Yasumi/data/translations/summerTime.php
index 4e7cf2428..5a6df066c 100644
--- a/src/Yasumi/data/translations/summerTime.php
+++ b/src/Yasumi/data/translations/summerTime.php
@@ -1,4 +1,4 @@
- 'Sommertid starter',
- 'en_US' => 'Summertime',
- 'nl_NL' => 'Zomertijd',
+ 'da' => 'Sommertid starter',
+ 'en' => 'Summertime',
+ 'ko' => '서머타임',
+ 'nl' => 'Zomertijd',
];
diff --git a/src/Yasumi/data/translations/valentinesDay.php b/src/Yasumi/data/translations/valentinesDay.php
index 31abe86d9..fbd6db79d 100644
--- a/src/Yasumi/data/translations/valentinesDay.php
+++ b/src/Yasumi/data/translations/valentinesDay.php
@@ -1,4 +1,4 @@
- 'Valentinstag',
- 'el_GR' => 'Αγίου Βαλεντίνου',
- 'en_US' => 'Valentine\'s Day',
- 'es_ES' => 'San Valentín',
- 'fr_BE' => 'Saint-Valentin',
- 'fr_CH' => 'Saint-Valentin',
- 'it_CH' => 'San Valentino',
- 'ja_JP' => 'バレンタイン·デー',
- 'nl_BE' => 'Valentijnsdag',
- 'nl_NL' => 'Valentijnsdag',
- 'pl_PL' => 'Walentynki',
- 'pt_PT' => 'Dia dos Namorados',
+ 'de' => 'Valentinstag',
+ 'el' => 'Αγίου Βαλεντίνου',
+ 'en' => 'Valentine\'s Day',
+ 'es' => 'San Valentín',
+ 'fr' => 'Saint-Valentin',
+ 'it' => 'San Valentino',
+ 'ja' => 'バレンタイン·デー',
+ 'ko' => '발렌타인 데이',
+ 'nl' => 'Valentijnsdag',
+ 'pl' => 'Walentynki',
+ 'pt' => 'Dia dos Namorados',
];
diff --git a/src/Yasumi/data/translations/victoryInEuropeDay.php b/src/Yasumi/data/translations/victoryInEuropeDay.php
index b02aa3dc3..6222f5f5a 100644
--- a/src/Yasumi/data/translations/victoryInEuropeDay.php
+++ b/src/Yasumi/data/translations/victoryInEuropeDay.php
@@ -1,4 +1,4 @@
- 'Den vítězství',
- 'en_US' => 'Victory in Europe Day',
- 'fr_FR' => 'Fête de la Victoire',
- 'sk_SK' => 'Deň víťazstva nad fašizmom',
+ 'cs' => 'Den vítězství',
+ 'en' => 'Victory in Europe Day',
+ 'fr' => 'Victoire 1945',
+ 'sk' => 'Deň víťazstva nad fašizmom',
];
diff --git a/src/Yasumi/data/translations/waitangiDay.php b/src/Yasumi/data/translations/waitangiDay.php
index a7d64b2c6..a91cf8c31 100644
--- a/src/Yasumi/data/translations/waitangiDay.php
+++ b/src/Yasumi/data/translations/waitangiDay.php
@@ -1,4 +1,4 @@
- 'Waitangi Day',
- 'en_US' => 'Waitangi Day',
+ 'en' => 'Waitangi Day',
];
diff --git a/src/Yasumi/data/translations/walpurgisEve.php b/src/Yasumi/data/translations/walpurgisEve.php
new file mode 100755
index 000000000..67efc4b2e
--- /dev/null
+++ b/src/Yasumi/data/translations/walpurgisEve.php
@@ -0,0 +1,17 @@
+
+ */
+
+// Translations for Walpurgis Night
+return [
+ 'en' => 'Walpurgis Night',
+ 'sv' => 'valborgsmässoafton',
+];
diff --git a/src/Yasumi/data/translations/winterTime.php b/src/Yasumi/data/translations/winterTime.php
index 06f5bdd19..5c702cdc1 100644
--- a/src/Yasumi/data/translations/winterTime.php
+++ b/src/Yasumi/data/translations/winterTime.php
@@ -1,4 +1,4 @@
- 'Sommertid slutter',
- 'en_US' => 'Wintertime',
- 'nl_NL' => 'Wintertijd',
+ 'da' => 'Sommertid slutter',
+ 'en' => 'Wintertime',
+ 'nl' => 'Wintertijd',
];
diff --git a/src/Yasumi/data/translations/worldAnimalDay.php b/src/Yasumi/data/translations/worldAnimalDay.php
index cfb7f1da9..5a4106beb 100644
--- a/src/Yasumi/data/translations/worldAnimalDay.php
+++ b/src/Yasumi/data/translations/worldAnimalDay.php
@@ -1,4 +1,4 @@
- 'World Animal Day',
- 'nl_BE' => 'Werelddierendag',
- 'nl_NL' => 'Werelddierendag',
+ 'en' => 'World Animal Day',
+ 'nl' => 'Werelddierendag',
];
diff --git a/tests/Australia/ACT/ACTBaseTestCase.php b/tests/Australia/ACT/ACTBaseTestCase.php
index b11f23907..b09b2a4d9 100644
--- a/tests/Australia/ACT/ACTBaseTestCase.php
+++ b/tests/Australia/ACT/ACTBaseTestCase.php
@@ -1,4 +1,4 @@
-region, $this->year, Holiday::TYPE_OFFICIAL);
}
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(2018, 2100);
}
diff --git a/tests/Australia/ACT/AnzacDayTest.php b/tests/Australia/ACT/AnzacDayTest.php
index 39c85bb1d..8f1085c71 100644
--- a/tests/Australia/ACT/AnzacDayTest.php
+++ b/tests/Australia/ACT/AnzacDayTest.php
@@ -1,4 +1,4 @@
-year = $this->generateRandomYear(1987);
}
diff --git a/tests/Australia/BoxingDayTest.php b/tests/Australia/BoxingDayTest.php
index 2ddf836e3..3ab1e7e2c 100644
--- a/tests/Australia/BoxingDayTest.php
+++ b/tests/Australia/BoxingDayTest.php
@@ -1,4 +1,4 @@
-timezone))
);
- if ($expectedExtra === null) {
+ if (null === $expectedExtra) {
$this->assertNotHoliday(
$this->region,
self::HOLIDAY2,
@@ -91,7 +93,7 @@ public function HolidayDataProvider(): array
/**
* Tests the translated name of the holiday defined in this test.
*
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -112,7 +114,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
*
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Australia/ChristmasDayTest.php b/tests/Australia/ChristmasDayTest.php
index 70bc08cab..25e8fa41b 100644
--- a/tests/Australia/ChristmasDayTest.php
+++ b/tests/Australia/ChristmasDayTest.php
@@ -1,4 +1,4 @@
-timezone))
);
- if ($expectedExtra === null) {
+ if (null === $expectedExtra) {
$this->assertNotHoliday(
$this->region,
self::HOLIDAY2,
@@ -91,7 +93,7 @@ public function HolidayDataProvider(): array
/**
* Tests the translated name of the holiday defined in this test.
*
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -112,7 +114,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
*
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Australia/EasterMondayTest.php b/tests/Australia/EasterMondayTest.php
index f0039d19b..a1f4e9a13 100644
--- a/tests/Australia/EasterMondayTest.php
+++ b/tests/Australia/EasterMondayTest.php
@@ -1,4 +1,4 @@
-year = $this->generateRandomYear(1921);
}
diff --git a/tests/Australia/NSW/NewYearsDayTest.php b/tests/Australia/NSW/NewYearsDayTest.php
index d218e6e59..83c806d6d 100644
--- a/tests/Australia/NSW/NewYearsDayTest.php
+++ b/tests/Australia/NSW/NewYearsDayTest.php
@@ -1,4 +1,4 @@
-year = $this->generateRandomYear(1921);
}
diff --git a/tests/Australia/NT/NewYearsDayTest.php b/tests/Australia/NT/NewYearsDayTest.php
index 16aa4cdf6..04e24cd0b 100644
--- a/tests/Australia/NT/NewYearsDayTest.php
+++ b/tests/Australia/NT/NewYearsDayTest.php
@@ -1,4 +1,4 @@
-timezone))
);
- if ($expectedExtra === null) {
+ if (null === $expectedExtra) {
$this->assertNotHoliday(
$this->region,
self::HOLIDAY2,
@@ -91,7 +93,7 @@ public function HolidayDataProvider(): array
/**
* Tests the translated name of the holiday defined in this test.
*
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -112,7 +114,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
*
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Australia/Queensland/AnzacDayTest.php b/tests/Australia/Queensland/AnzacDayTest.php
index 61c58c4bb..41d96d9b2 100644
--- a/tests/Australia/Queensland/AnzacDayTest.php
+++ b/tests/Australia/Queensland/AnzacDayTest.php
@@ -1,4 +1,4 @@
-year = $this->generateRandomYear(1921);
}
diff --git a/tests/Australia/Queensland/Brisbane/ChristmasDayTest.php b/tests/Australia/Queensland/Brisbane/ChristmasDayTest.php
index c998796c2..7574d1be3 100644
--- a/tests/Australia/Queensland/Brisbane/ChristmasDayTest.php
+++ b/tests/Australia/Queensland/Brisbane/ChristmasDayTest.php
@@ -1,4 +1,4 @@
-year = $this->generateRandomYear(1921);
}
diff --git a/tests/Australia/SA/AdelaideCupDayTest.php b/tests/Australia/SA/AdelaideCupDayTest.php
index 559b939a3..35c5a1ea7 100644
--- a/tests/Australia/SA/AdelaideCupDayTest.php
+++ b/tests/Australia/SA/AdelaideCupDayTest.php
@@ -1,4 +1,4 @@
-timezone))
);
- if ($expectedExtra === null) {
+ if (null === $expectedExtra) {
$this->assertNotHoliday(
$this->region,
self::HOLIDAY2,
@@ -91,7 +93,7 @@ public function HolidayDataProvider(): array
/**
* Tests the translated name of the holiday defined in this test.
*
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -112,7 +114,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
*
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Australia/SA/EasterMondayTest.php b/tests/Australia/SA/EasterMondayTest.php
index e6e43ca9b..fb559a017 100644
--- a/tests/Australia/SA/EasterMondayTest.php
+++ b/tests/Australia/SA/EasterMondayTest.php
@@ -1,4 +1,4 @@
-region, $this->year, Holiday::TYPE_OFFICIAL);
}
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1973);
}
diff --git a/tests/Australia/Tasmania/AnzacDayTest.php b/tests/Australia/Tasmania/AnzacDayTest.php
index b2dd07789..1681139c0 100644
--- a/tests/Australia/Tasmania/AnzacDayTest.php
+++ b/tests/Australia/Tasmania/AnzacDayTest.php
@@ -1,4 +1,4 @@
-region, $this->year, Holiday::TYPE_OFFICIAL);
}
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1921);
}
diff --git a/tests/Australia/Tasmania/CentralNorth/ChristmasDayTest.php b/tests/Australia/Tasmania/CentralNorth/ChristmasDayTest.php
index 023e55c52..106234972 100644
--- a/tests/Australia/Tasmania/CentralNorth/ChristmasDayTest.php
+++ b/tests/Australia/Tasmania/CentralNorth/ChristmasDayTest.php
@@ -1,4 +1,4 @@
-region, $this->year, Holiday::TYPE_OFFICIAL);
}
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1921);
}
diff --git a/tests/Australia/Tasmania/FlindersIsland/GoodFridayTest.php b/tests/Australia/Tasmania/FlindersIsland/GoodFridayTest.php
index 067967bd4..d22df4f64 100644
--- a/tests/Australia/Tasmania/FlindersIsland/GoodFridayTest.php
+++ b/tests/Australia/Tasmania/FlindersIsland/GoodFridayTest.php
@@ -1,4 +1,4 @@
-region, $this->year, Holiday::TYPE_OFFICIAL);
}
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1921);
}
diff --git a/tests/Australia/Tasmania/KingIsland/NewYearsDayTest.php b/tests/Australia/Tasmania/KingIsland/NewYearsDayTest.php
index 46b718343..19f9f1989 100644
--- a/tests/Australia/Tasmania/KingIsland/NewYearsDayTest.php
+++ b/tests/Australia/Tasmania/KingIsland/NewYearsDayTest.php
@@ -1,4 +1,4 @@
-region, $this->year, Holiday::TYPE_OFFICIAL);
}
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1921);
}
diff --git a/tests/Australia/Tasmania/Northeast/QueensBirthdayTest.php b/tests/Australia/Tasmania/Northeast/QueensBirthdayTest.php
index 7802e766b..5b4049a67 100644
--- a/tests/Australia/Tasmania/Northeast/QueensBirthdayTest.php
+++ b/tests/Australia/Tasmania/Northeast/QueensBirthdayTest.php
@@ -1,4 +1,4 @@
-year = $this->generateRandomYear(1921);
}
diff --git a/tests/Australia/Tasmania/Northwest/CircularHead/EasterMondayTest.php b/tests/Australia/Tasmania/Northwest/CircularHead/EasterMondayTest.php
index 79c4d2d1a..d1770daf6 100644
--- a/tests/Australia/Tasmania/Northwest/CircularHead/EasterMondayTest.php
+++ b/tests/Australia/Tasmania/Northwest/CircularHead/EasterMondayTest.php
@@ -1,4 +1,4 @@
-region, $this->year, Holiday::TYPE_OFFICIAL);
}
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1921);
}
diff --git a/tests/Australia/Tasmania/Northwest/QueensBirthdayTest.php b/tests/Australia/Tasmania/Northwest/QueensBirthdayTest.php
index 7cf5ba4e1..702718b3b 100644
--- a/tests/Australia/Tasmania/Northwest/QueensBirthdayTest.php
+++ b/tests/Australia/Tasmania/Northwest/QueensBirthdayTest.php
@@ -1,4 +1,4 @@
-region, $this->year, Holiday::TYPE_OFFICIAL);
}
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1921);
}
diff --git a/tests/Australia/Tasmania/South/Southeast/AnzacDayTest.php b/tests/Australia/Tasmania/South/Southeast/AnzacDayTest.php
index c39d68b6b..47980d195 100644
--- a/tests/Australia/Tasmania/South/Southeast/AnzacDayTest.php
+++ b/tests/Australia/Tasmania/South/Southeast/AnzacDayTest.php
@@ -1,4 +1,4 @@
-year = $this->generateRandomYear(1921);
}
diff --git a/tests/Australia/Tasmania/TasmaniaBaseTestCase.php b/tests/Australia/Tasmania/TasmaniaBaseTestCase.php
index 42628ec02..5185a3732 100644
--- a/tests/Australia/Tasmania/TasmaniaBaseTestCase.php
+++ b/tests/Australia/Tasmania/TasmaniaBaseTestCase.php
@@ -1,4 +1,4 @@
-year = $this->generateRandomYear(1921);
}
diff --git a/tests/Australia/Victoria/AFLGrandFinalFridayTest.php b/tests/Australia/Victoria/AFLGrandFinalFridayTest.php
index 07c9a6ef1..303ce70aa 100644
--- a/tests/Australia/Victoria/AFLGrandFinalFridayTest.php
+++ b/tests/Australia/Victoria/AFLGrandFinalFridayTest.php
@@ -1,4 +1,4 @@
-region, $this->year, Holiday::TYPE_OFFICIAL);
}
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(2015, 2018);
}
diff --git a/tests/Australia/WA/AnzacDayTest.php b/tests/Australia/WA/AnzacDayTest.php
index 8399a86b7..6af012b98 100644
--- a/tests/Australia/WA/AnzacDayTest.php
+++ b/tests/Australia/WA/AnzacDayTest.php
@@ -1,4 +1,4 @@
-year = $this->generateRandomYear(1921);
}
diff --git a/tests/Australia/WA/WesternAustraliaDayTest.php b/tests/Australia/WA/WesternAustraliaDayTest.php
index 8c1148dbf..406767267 100644
--- a/tests/Australia/WA/WesternAustraliaDayTest.php
+++ b/tests/Australia/WA/WesternAustraliaDayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OFFICIAL);
}
/**
* Tests if all observed holidays in Austria are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -58,7 +59,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Austria are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -67,7 +68,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Austria are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -76,7 +77,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Austria are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -86,7 +87,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1955);
}
diff --git a/tests/Austria/ChristmasTest.php b/tests/Austria/ChristmasTest.php
index 1a1b3e0ed..5813ed158 100644
--- a/tests/Austria/ChristmasTest.php
+++ b/tests/Austria/ChristmasTest.php
@@ -1,4 +1,4 @@
-between(
- new \DateTimeImmutable('03/25/2016', new \DateTimeZone($timezone)),
- new \DateTimeImmutable('07/25/2016', new \DateTimeZone($timezone))
+ new DateTimeImmutable('03/25/2016', new DateTimeZone($timezone)),
+ new DateTimeImmutable('07/25/2016', new DateTimeZone($timezone))
);
$betweenHolidays = \iterator_to_array($between);
@@ -141,8 +144,8 @@ public function testHolidaysBetweenDateRangeWithDateTimeImmutable(): void
/**
* Tests that BetweenFilter considers the date and ignores timezones and time of day.
*
- * @throws \Exception
- * @throws \ReflectionException
+ * @throws Exception
+ * @throws ReflectionException
*/
public function testHolidaysBetweenDateRangeDifferentTimezone(): void
{
@@ -168,8 +171,8 @@ public function testHolidaysBetweenDateRangeDifferentTimezone(): void
/**
* Tests the BetweenFilter with date range where start and end date are exclusive of the comparison.
*
- * @throws \Exception
- * @throws \ReflectionException
+ * @throws Exception
+ * @throws ReflectionException
*/
public function testHolidaysBetweenDateRangeExclusiveStartEndDate(): void
{
@@ -224,12 +227,12 @@ public function testHolidaysBetweenDateRangeExclusiveStartEndDate(): void
/**
* Tests the BetweenFilter where the start date lies before the year of the Holiday Provider instance.
*
- * @throws \Exception
- * @throws \ReflectionException
+ * @throws Exception
+ * @throws ReflectionException
*/
public function testHolidaysBetweenDateRangeWithStartBeforeInstanceYear(): void
{
- $year = 2015;
+ $year = 2015;
$timezone = 'Europe/Oslo';
$holidays = Yasumi::create('Norway', $year);
@@ -264,12 +267,12 @@ public function testHolidaysBetweenDateRangeWithStartBeforeInstanceYear(): void
/**
* Tests the BetweenFilter where the end date lies beyond the year of the Holiday Provider instance.
*
- * @throws \Exception
- * @throws \ReflectionException
+ * @throws Exception
+ * @throws ReflectionException
*/
public function testHolidaysBetweenDateRangeWithEndAfterInstanceYear(): void
{
- $year = 2000;
+ $year = 2000;
$timezone = 'Europe/Rome';
$holidays = Yasumi::create('Italy', $year);
@@ -304,13 +307,14 @@ public function testHolidaysBetweenDateRangeWithEndAfterInstanceYear(): void
/**
* Tests that an InvalidArgumentException is thrown in case an invalid holiday provider is given.
*
- * @expectedException InvalidArgumentException
- * @throws \Exception
- * @throws \ReflectionException
+ * @throws Exception
+ * @throws ReflectionException
*/
public function testWrongDates(): void
{
- $year = 2017;
+ $this->expectException(InvalidArgumentException::class);
+
+ $year = 2017;
$timezone = 'America/New_York';
$holidays = Yasumi::create('USA', $year);
@@ -325,13 +329,13 @@ public function testWrongDates(): void
*
* This test covers the scenario that the requested date range covers all know holidays.
*
- * @throws \Exception
- * @throws \ReflectionException
+ * @throws Exception
+ * @throws ReflectionException
*/
public function testCountBetweenWithSubstitutes(): void
{
// There are official 12 holidays in Ireland in the year 2018, with 1 substituted holiday.
- $year = 2018;
+ $year = 2018;
$timezone = 'Europe/Dublin';
$holidays = Yasumi::create('Ireland', $year);
@@ -366,13 +370,13 @@ public function testCountBetweenWithSubstitutes(): void
*
* This test covers the scenario that the requested date range excludes a substituted holiday.
*
- * @throws \Exception
- * @throws \ReflectionException
+ * @throws Exception
+ * @throws ReflectionException
*/
public function testCountBetweenExcludingSubstituteHoliday(): void
{
// There are 2 official holidays in Ireland in the given date range, with 1 substituted holiday.
- $year = 2018;
+ $year = 2018;
$timezone = 'Europe/Dublin';
$holidays = Yasumi::create('Ireland', $year);
@@ -411,13 +415,13 @@ public function testCountBetweenExcludingSubstituteHoliday(): void
* This test covers the scenario that the requested date range excludes a substituted holiday, but includes
* the original substituted holiday.
*
- * @throws \Exception
- * @throws \ReflectionException
+ * @throws Exception
+ * @throws ReflectionException
*/
public function testCountBetweenExcludingSubstituteHolidayIncludingOriginalHoliday(): void
{
// There are 2 official holidays in Ireland in the given date range, with 1 substituted holiday.
- $year = 2018;
+ $year = 2018;
$timezone = 'Europe/Dublin';
$holidays = Yasumi::create('Ireland', $year);
@@ -457,13 +461,13 @@ public function testCountBetweenExcludingSubstituteHolidayIncludingOriginalHolid
* This test covers the scenario that the requested date range excludes a substituted holiday and also
* the original substituted holiday.
*
- * @throws \Exception
- * @throws \ReflectionException
+ * @throws Exception
+ * @throws ReflectionException
*/
public function testCountBetweenExcludingSubstituteHolidayAndOriginalHoliday(): void
{
// There is 1 official holidays in Ireland in the given date range.
- $year = 2018;
+ $year = 2018;
$timezone = 'Europe/Dublin';
$holidays = Yasumi::create('Ireland', $year);
diff --git a/tests/Base/HolidayFiltersTest.php b/tests/Base/HolidayFiltersTest.php
index fac3abb26..22da23fc9 100644
--- a/tests/Base/HolidayFiltersTest.php
+++ b/tests/Base/HolidayFiltersTest.php
@@ -1,4 +1,4 @@
-getIterator());
+ $filteredHolidays = new OfficialHolidaysFilter($holidays->getIterator());
$filteredHolidaysArray = \iterator_to_array($filteredHolidays);
// Assert array definitions
@@ -66,14 +67,14 @@ public function testOfficialHolidaysFilter(): void
/**
* Tests the Observed Holidays filter
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidaysFilter(): void
{
// There are 2 observed holidays in Ireland in the year 2018.
$holidays = Yasumi::create('Ireland', 2018);
- $filteredHolidays = new ObservedHolidaysFilter($holidays->getIterator());
+ $filteredHolidays = new ObservedHolidaysFilter($holidays->getIterator());
$filteredHolidaysArray = \iterator_to_array($filteredHolidays);
// Assert array definitions
@@ -100,14 +101,14 @@ public function testObservedHolidaysFilter(): void
/**
* Tests Bank Holidays
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidaysFilter(): void
{
// There are no bank holidays in Ireland in the year 2018.
$holidays = Yasumi::create('Ireland', 2018);
- $filteredHolidays = new BankHolidaysFilter($holidays->getIterator());
+ $filteredHolidays = new BankHolidaysFilter($holidays->getIterator());
$filteredHolidaysArray = \iterator_to_array($filteredHolidays);
// Assert array definitions
@@ -134,13 +135,13 @@ public function testBankHolidaysFilter(): void
/**
* Tests Seasonal Holidays
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidaysFilter(): void
{
$holidays = Yasumi::create('Netherlands', 2017);
- $filteredHolidays = new SeasonalHolidaysFilter($holidays->getIterator());
+ $filteredHolidays = new SeasonalHolidaysFilter($holidays->getIterator());
$filteredHolidaysArray = \iterator_to_array($filteredHolidays);
// Assert array definitions
@@ -182,13 +183,13 @@ public function testSeasonalHolidaysFilter(): void
/**
* Tests other type of Holidays
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidaysFilter(): void
{
$holidays = Yasumi::create('Netherlands', 2017);
- $filteredHolidays = new OtherHolidaysFilter($holidays->getIterator());
+ $filteredHolidays = new OtherHolidaysFilter($holidays->getIterator());
$filteredHolidaysArray = \iterator_to_array($filteredHolidays);
// Assert array definitions
diff --git a/tests/Base/HolidayOnFilterTest.php b/tests/Base/HolidayOnFilterTest.php
index 21d7bc787..b895041bd 100644
--- a/tests/Base/HolidayOnFilterTest.php
+++ b/tests/Base/HolidayOnFilterTest.php
@@ -1,4 +1,4 @@
- new DateTime('03/25/2016', new DateTimeZone($timezone)),
'easter' => new DateTime('03/27/2016', new DateTimeZone($timezone)),
- 'summerTime' => new DateTime('03/27/2016', new DateTimeZone($timezone))
+ 'summerTime' => new DateTime('03/27/2016', new DateTimeZone($timezone)),
];
foreach ($holidayDates as $name => $date) {
@@ -54,8 +56,8 @@ public function testHolidaysOnDate(): void
}
/**
- * @throws \ReflectionException
- * @throws \Exception
+ * @throws ReflectionException
+ * @throws Exception
*/
public function testHolidaysNotOnDate(): void
{
@@ -65,7 +67,7 @@ public function testHolidaysNotOnDate(): void
$holidayWrongDates = [
'goodFriday' => new DateTime('04/25/2016', new DateTimeZone($timezone)),
'easter' => new DateTime('03/22/2016', new DateTimeZone($timezone)),
- 'summerTime' => new DateTime('12/27/2016', new DateTimeZone($timezone))
+ 'summerTime' => new DateTime('12/27/2016', new DateTimeZone($timezone)),
];
foreach ($holidayWrongDates as $name => $date) {
@@ -78,8 +80,8 @@ public function testHolidaysNotOnDate(): void
}
/**
- * @throws \ReflectionException
- * @throws \Exception
+ * @throws ReflectionException
+ * @throws Exception
*/
public function testCorrectNumberOfHolidaysOnDate(): void
{
@@ -87,15 +89,15 @@ public function testCorrectNumberOfHolidaysOnDate(): void
$holidays = Yasumi::create('Netherlands', 2016);
// No holidays
- $holidaysOnDate = $holidays->on(new \DateTime('11/19/2016', new DateTimeZone($timezone)));
+ $holidaysOnDate = $holidays->on(new DateTime('11/19/2016', new DateTimeZone($timezone)));
$this->assertEquals(0, $holidaysOnDate->count());
// One holiday
- $holidaysOnDate = $holidays->on(new \DateTime('12/25/2016', new DateTimeZone($timezone)));
+ $holidaysOnDate = $holidays->on(new DateTime('12/25/2016', new DateTimeZone($timezone)));
$this->assertEquals(1, $holidaysOnDate->count());
// Multiple holidays
- $holidaysOnDate = $holidays->on(new \DateTime('03/27/2016', new DateTimeZone($timezone)));
+ $holidaysOnDate = $holidays->on(new DateTime('03/27/2016', new DateTimeZone($timezone)));
$this->assertGreaterThan(1, $holidaysOnDate->count());
}
}
diff --git a/tests/Base/HolidayTest.php b/tests/Base/HolidayTest.php
index 4f7608064..4a1972051 100644
--- a/tests/Base/HolidayTest.php
+++ b/tests/Base/HolidayTest.php
@@ -1,4 +1,4 @@
-expectException(InvalidArgumentException::class);
+
+ new Holiday('', [], new DateTime());
}
/**
* Tests that an Yasumi\Exception\UnknownLocaleException is thrown in case an invalid locale is given.
*
- * @expectedException \Yasumi\Exception\UnknownLocaleException
- * @throws \Exception
+ * @throws Exception
*/
public function testCreateHolidayUnknownLocaleException(): void
{
+ $this->expectException(UnknownLocaleException::class);
+
new Holiday('testHoliday', [], new DateTime(), 'wx-YZ');
}
/**
* Tests that a Yasumi holiday instance can be serialized to a JSON object.
- * @throws \Exception
+ * @throws Exception
*/
public function testHolidayIsJsonSerializable(): void
{
- $holiday = new Holiday('testHoliday', [], new DateTime(), 'en_US');
- $json = \json_encode($holiday);
+ $holiday = new Holiday('testHoliday', [], new DateTime(), 'en_US');
+ $json = \json_encode($holiday);
$instance = \json_decode($json, true);
$this->assertIsArray($instance);
@@ -68,44 +73,58 @@ public function testHolidayIsJsonSerializable(): void
/**
* Tests that a Yasumi holiday instance can be created using an object that implements the DateTimeInterface (e.g.
* DateTime or DateTimeImmutable)
- * @throws \Exception
+ * @throws Exception
*/
public function testHolidayWithDateTimeInterface(): void
{
// Assert with DateTime instance
- $holiday = new Holiday('testHoliday', [], new \DateTime(), 'en_US');
+ $holiday = new Holiday('testHoliday', [], new DateTime(), 'en_US');
$this->assertNotNull($holiday);
$this->assertInstanceOf(Holiday::class, $holiday);
// Assert with DateTimeImmutable instance
- $holiday = new Holiday('testHoliday', [], new \DateTimeImmutable(), 'en_US');
+ $holiday = new Holiday('testHoliday', [], new DateTimeImmutable(), 'en_US');
$this->assertNotNull($holiday);
$this->assertInstanceOf(Holiday::class, $holiday);
}
/**
* Tests the getName function of the Holiday object with no translations for the name given.
- * @throws \Exception
+ * @throws Exception
*/
public function testHolidayGetNameWithNoTranslations(): void
{
- $name = 'testHoliday';
+ $name = 'testHoliday';
$holiday = new Holiday($name, [], new DateTime(), 'en_US');
$this->assertIsString($holiday->getName());
$this->assertEquals($name, $holiday->getName());
}
+ /**
+ * Tests the getName function of the Holiday object with only a parent translation for the name given.
+ * @throws Exception
+ */
+ public function testHolidayGetNameWithParentLocaleTranslation(): void
+ {
+ $name = 'testHoliday';
+ $translation = 'My Holiday';
+ $holiday = new Holiday($name, ['de' => $translation], new DateTime(), 'de_DE');
+
+ $this->assertIsString($holiday->getName());
+ $this->assertEquals($translation, $holiday->getName());
+ }
+
/**
* Tests the getName function of the Holiday object with only a default translation for the name given.
- * @throws \Exception
+ * @throws Exception
*/
public function testHolidayGetNameWithOnlyDefaultTranslation(): void
{
- $name = 'testHoliday';
+ $name = 'testHoliday';
$translation = 'My Holiday';
- $locale = 'en_US';
- $holiday = new Holiday($name, [$locale => $translation], new DateTime(), $locale);
+ $locale = 'en_US';
+ $holiday = new Holiday($name, [$locale => $translation], new DateTime(), $locale);
$this->assertIsString($holiday->getName());
$this->assertEquals($translation, $holiday->getName());
@@ -114,13 +133,13 @@ public function testHolidayGetNameWithOnlyDefaultTranslation(): void
/**
* Tests the getName function of the Holiday object with only a default translation for the name given.
*
- * @throws \Exception
+ * @throws Exception
*/
public function testHolidayGetNameWithOneNonDefaultTranslation(): void
{
- $name = 'testHoliday';
+ $name = 'testHoliday';
$translation = 'My Holiday';
- $holiday = new Holiday($name, ['en_US' => $translation], new DateTime(), 'nl_NL');
+ $holiday = new Holiday($name, ['en_US' => $translation], new DateTime(), 'nl_NL');
$this->assertNotNull($holiday->getName());
$this->assertIsString($holiday->getName());
@@ -129,7 +148,7 @@ public function testHolidayGetNameWithOneNonDefaultTranslation(): void
/**
* Tests the getName function of the Holiday object with global translations and no custom translation.
- * @throws \Exception
+ * @throws Exception
*/
public function testHolidayGetNameWithGlobalTranslations(): void
{
@@ -153,9 +172,35 @@ public function testHolidayGetNameWithGlobalTranslations(): void
$this->assertEquals($translations[$locale], $holiday->getName());
}
+ /**
+ * Tests the getName function of the Holiday object with global translations and no custom translation.
+ * @throws Exception
+ */
+ public function testHolidayGetNameWithGlobalParentLocaleTranslations(): void
+ {
+ /** @var TranslationsInterface|PHPUnit_Framework_MockObject_MockObject $translationsStub */
+ $translationsStub = $this->getMockBuilder(TranslationsInterface::class)->getMock();
+
+ $translations = [
+ 'en_US' => 'New Year\'s Day',
+ 'pl' => 'Nowy Rok',
+ ];
+
+ $translationsStub->expects($this->once())->method('getTranslations')->with($this->equalTo('newYearsDay'))->willReturn($translations);
+
+ $locale = 'pl_PL';
+
+ $holiday = new Holiday('newYearsDay', [], new DateTime('2015-01-01'), $locale);
+ $holiday->mergeGlobalTranslations($translationsStub);
+
+ $this->assertNotNull($holiday->getName());
+ $this->assertIsString($holiday->getName());
+ $this->assertEquals($translations['pl'], $holiday->getName());
+ }
+
/**
* Tests the getName function of the Holiday object with global translations and a new custom translation.
- * @throws \Exception
+ * @throws Exception
*/
public function testHolidayGetNameWithGlobalAndCustomTranslations(): void
{
@@ -169,7 +214,7 @@ public function testHolidayGetNameWithGlobalAndCustomTranslations(): void
$translationsStub->expects($this->once())->method('getTranslations')->with($this->equalTo('newYearsDay'))->willReturn($translations);
- $customLocale = 'nl_NL';
+ $customLocale = 'nl_NL';
$customTranslation = 'Nieuwjaar';
$holiday = new Holiday(
@@ -187,7 +232,7 @@ public function testHolidayGetNameWithGlobalAndCustomTranslations(): void
/**
* Tests the getName function of the Holiday object with global translations and an overriding custom translation.
- * @throws \Exception
+ * @throws Exception
*/
public function testHolidayGetNameWithOverridenGlobalTranslations(): void
{
@@ -201,7 +246,7 @@ public function testHolidayGetNameWithOverridenGlobalTranslations(): void
$translationsStub->expects($this->once())->method('getTranslations')->with($this->equalTo('newYearsDay'))->willReturn($translations);
- $customLocale = 'pl_PL';
+ $customLocale = 'pl_PL';
$customTranslation = 'Bardzo Nowy Rok';
$holiday = new Holiday(
diff --git a/tests/Base/SubstituteHolidayTest.php b/tests/Base/SubstituteHolidayTest.php
new file mode 100644
index 000000000..9937835d3
--- /dev/null
+++ b/tests/Base/SubstituteHolidayTest.php
@@ -0,0 +1,194 @@
+
+ */
+
+namespace Yasumi\tests\Base;
+
+use DateTime;
+use InvalidArgumentException;
+use PHPUnit\Framework\TestCase;
+use Yasumi\Exception\UnknownLocaleException;
+use Yasumi\Holiday;
+use Yasumi\SubstituteHoliday;
+use Yasumi\tests\YasumiBase;
+use Yasumi\TranslationsInterface;
+
+/**
+ * Class SubstituteHolidayTest.
+ *
+ * Contains tests for testing the SubstituteHoliday class
+ */
+class SubstituteHolidayTest extends TestCase
+{
+ use YasumiBase;
+
+ /**
+ * Tests that an UnknownLocaleException is thrown in case an invalid locale is given.
+ *
+ * @throws \Exception
+ */
+ public function testCreateSubstituteHolidayUnknownLocaleException(): void
+ {
+ $holiday = new Holiday('testHoliday', [], new DateTime());
+
+ $this->expectException(UnknownLocaleException::class);
+
+ new SubstituteHoliday($holiday, [], new DateTime(), 'wx-YZ');
+ }
+
+ /**
+ * Tests that an InvalidArgumentException is thrown in case the substitute is on the same date as the substituted.
+ * @throws \Exception
+ */
+ public function testCreateSubstituteHolidaySameDate(): void
+ {
+ $holiday = new Holiday('testHoliday', [], new DateTime('2019-01-01'));
+
+ $this->expectException(InvalidArgumentException::class);
+
+ new SubstituteHoliday($holiday, [], new DateTime('2019-01-01'));
+ }
+
+ /**
+ * Tests the constructor.
+ *
+ * @throws \Exception
+ */
+ public function testConstructor(): void
+ {
+ $holiday = new Holiday('testHoliday', [], new DateTime('2019-01-01'), 'en_US', Holiday::TYPE_BANK);
+ $substitute = new SubstituteHoliday($holiday, [], new DateTime('2019-01-02'), 'en_US', Holiday::TYPE_SEASON);
+
+ $this->assertSame($holiday, $substitute->substitutedHoliday);
+ $this->assertEquals('substituteHoliday:testHoliday', $substitute->shortName);
+ $this->assertEquals(Holiday::TYPE_SEASON, $substitute->getType());
+ $this->assertEquals(new DateTime('2019-01-02'), $substitute);
+ }
+
+ /**
+ * Tests that a Yasumi holiday instance can be serialized to a JSON object.
+ * @throws \Exception
+ */
+ public function testSubstituteHolidayIsJsonSerializable(): void
+ {
+ $holiday = new Holiday('testHoliday', [], new DateTime('2019-01-01'), 'en_US');
+ $substitute = new SubstituteHoliday($holiday, [], new DateTime('2019-01-02'), 'en_US');
+ $json = \json_encode($substitute);
+ $instance = \json_decode($json, true);
+
+ $this->assertIsArray($instance);
+ $this->assertNotNull($instance);
+ $this->assertArrayHasKey('shortName', $instance);
+ $this->assertArrayHasKey('substitutedHoliday', $instance);
+ }
+
+ /**
+ * Tests that a Yasumi holiday instance can be created using an object that implements the DateTimeInterface (e.g.
+ * DateTime or DateTimeImmutable)
+ * @throws \Exception
+ */
+ public function testSubstituteHolidayWithDateTimeInterface(): void
+ {
+ // Assert with DateTime instance
+ $holiday = new Holiday('testHoliday', [], new DateTime('2019-01-01'), 'en_US');
+ $substitute = new SubstituteHoliday($holiday, [], new DateTime('2019-01-02'), 'en_US');
+ $this->assertNotNull($holiday);
+ $this->assertInstanceOf(SubstituteHoliday::class, $substitute);
+
+ // Assert with DateTimeImmutable instance
+ $substitute = new SubstituteHoliday($holiday, [], new \DateTimeImmutable(), 'en_US');
+ $this->assertNotNull($holiday);
+ $this->assertInstanceOf(SubstituteHoliday::class, $substitute);
+ }
+
+ /**
+ * Tests the getName function of the SubstituteHoliday object with no translations for the name given.
+ * @throws \Exception
+ */
+ public function testSubstituteHolidayGetNameWithNoTranslations(): void
+ {
+ $name = 'testHoliday';
+ $holiday = new Holiday($name, [], new DateTime('2019-01-01'));
+ $substitute = new SubstituteHoliday($holiday, [], new DateTime('2019-01-02'), 'en_US');
+
+ $this->assertIsString($substitute->getName());
+ $this->assertEquals('substituteHoliday:' . $name, $substitute->getName());
+ }
+
+ /**
+ * Tests the getName function of the SubstituteHoliday object when it has a custom translation.
+ * @throws \Exception
+ */
+ public function testSubstituteHolidayGetNameWithCustomSubstituteTranslation(): void
+ {
+ $name = 'testHoliday';
+ $translation = 'My Holiday';
+ $locale = 'en_US';
+ $holiday = new Holiday($name, [$locale => 'foo'], new DateTime('2019-01-01'), $locale);
+ $substitute = new SubstituteHoliday($holiday, [$locale => $translation], new DateTime('2019-01-02'), $locale);
+
+ $translationsStub = $this->getMockBuilder(TranslationsInterface::class)->getMock();
+ $translationsStub->expects($this->at(0))->method('getTranslations')->with($this->equalTo('substituteHoliday'))->willReturn([$locale => 'foo']);
+ $translationsStub->expects($this->at(1))->method('getTranslations')->with($this->equalTo('substituteHoliday:testHoliday'))->willReturn([$locale => 'foo']);
+ $translationsStub->expects($this->at(2))->method('getTranslations')->with($this->equalTo('testHoliday'))->willReturn([$locale => 'foo']);
+
+ $substitute->mergeGlobalTranslations($translationsStub);
+
+ $this->assertIsString($substitute->getName());
+ $this->assertEquals($translation, $substitute->getName());
+ }
+
+ /**
+ * Tests the getName function of the SubstituteHoliday object when it has a global translation.
+ * @throws \Exception
+ */
+ public function testSubstituteHolidayGetNameWithGlobalSubstituteTranslation(): void
+ {
+ $name = 'testHoliday';
+ $translation = 'My Substitute';
+ $locale = 'en_US';
+ $holiday = new Holiday($name, [$locale => 'foo'], new DateTime('2019-01-01'), $locale);
+ $substitute = new SubstituteHoliday($holiday, [$locale => $translation], new DateTime('2019-01-02'), $locale);
+
+ $translationsStub = $this->getMockBuilder(TranslationsInterface::class)->getMock();
+ $translationsStub->expects($this->at(0))->method('getTranslations')->with($this->equalTo('substituteHoliday'))->willReturn([$locale => '{0} observed']);
+ $translationsStub->expects($this->at(1))->method('getTranslations')->with($this->equalTo('substituteHoliday:testHoliday'))->willReturn([$locale => $translation]);
+ $translationsStub->expects($this->at(2))->method('getTranslations')->with($this->equalTo('testHoliday'))->willReturn([$locale => 'foo']);
+
+ $substitute->mergeGlobalTranslations($translationsStub);
+
+ $this->assertIsString($substitute->getName());
+ $this->assertEquals($translation, $substitute->getName());
+ }
+
+ /**
+ * Tests the getName function of the SubstituteHoliday object when only the substituted holiday has a translation.
+ * @throws \Exception
+ */
+ public function testSubstituteHolidayGetNameWithSubstitutedTranslation(): void
+ {
+ $name = 'testHoliday';
+ $translation = 'My Holiday';
+ $locale = 'en_US';
+ $holiday = new Holiday($name, [$locale => $translation], new DateTime('2019-01-01'), $locale);
+ $substitute = new SubstituteHoliday($holiday, [], new DateTime('2019-01-02'), $locale);
+
+ $translationsStub = $this->getMockBuilder(TranslationsInterface::class)->getMock();
+ $translationsStub->expects($this->at(0))->method('getTranslations')->with($this->equalTo('substituteHoliday'))->willReturn([$locale => '{0} observed']);
+ $translationsStub->expects($this->at(1))->method('getTranslations')->with($this->equalTo('substituteHoliday:testHoliday'))->willReturn([]);
+ $translationsStub->expects($this->at(2))->method('getTranslations')->with($this->equalTo('testHoliday'))->willReturn([$locale => $translation]);
+
+ $substitute->mergeGlobalTranslations($translationsStub);
+
+ $this->assertIsString($substitute->getName());
+ $this->assertEquals('My Holiday observed', $substitute->getName());
+ }
+}
diff --git a/tests/Base/TranslationsTest.php b/tests/Base/TranslationsTest.php
index e5b3cc7ca..77c983ea1 100644
--- a/tests/Base/TranslationsTest.php
+++ b/tests/Base/TranslationsTest.php
@@ -1,4 +1,4 @@
-assertNull($translations->getTranslation($shortName, $locale));
@@ -62,8 +63,8 @@ public function testAddMultipleTranslations(): void
{
$translations = new Translations(self::LOCALES);
- $firstLocale = 'en_US';
- $firstShortName = 'newYearsDay';
+ $firstLocale = 'en_US';
+ $firstShortName = 'newYearsDay';
$firstTranslation = 'New Year\'s Day';
$translations->addTranslation($firstShortName, $firstLocale, $firstTranslation);
@@ -76,9 +77,9 @@ public function testAddMultipleTranslations(): void
$this->assertIsString($translations->getTranslation($firstShortName, $firstLocale));
$this->assertEquals($firstTranslation, $translations->getTranslation($firstShortName, $firstLocale));
- $secondLocale = 'nl_NL';
- $secondShortName = 'easter';
- $secondTranslation = 'Eerste Paasdag';
+ $secondLocale = 'nl_NL';
+ $secondShortName = 'easter';
+ $secondTranslation = 'Eerste paasdag';
$translations->addTranslation($secondShortName, $secondLocale, $secondTranslation);
@@ -90,8 +91,8 @@ public function testAddMultipleTranslations(): void
$this->assertIsString($translations->getTranslation($secondShortName, $secondLocale));
$this->assertEquals($secondTranslation, $translations->getTranslation($secondShortName, $secondLocale));
- $thirdLocale = 'en_US';
- $thirdShortName = 'easter';
+ $thirdLocale = 'en_US';
+ $thirdShortName = 'easter';
$thirdTranslation = 'Easter Sunday';
$translations->addTranslation($thirdShortName, $thirdLocale, $thirdTranslation);
@@ -111,15 +112,16 @@ public function testAddMultipleTranslations(): void
/**
* Tests that an UnknownLocaleException is thrown when adding translation for unknown locale.
*
- * @expectedException \Yasumi\Exception\UnknownLocaleException
*/
public function testAddTranslationUnknownLocaleException(): void
{
+ $this->expectException(UnknownLocaleException::class);
+
$translations = new Translations(self::LOCALES);
$unknownLocale = 'en_XY';
- $shortName = 'newYearsDay';
- $translation = 'New Year\'s Day';
+ $shortName = 'newYearsDay';
+ $translation = 'New Year\'s Day';
$translations->addTranslation($shortName, $unknownLocale, $translation);
}
@@ -131,8 +133,8 @@ public function testNoTranslationForUnknownHoliday(): void
{
$translations = new Translations(self::LOCALES);
- $locale = 'en_US';
- $shortName = 'newYearsDay';
+ $locale = 'en_US';
+ $shortName = 'newYearsDay';
$translation = 'New Year\'s Day';
$unknownShortName = 'unknownHoliday';
@@ -150,8 +152,8 @@ public function testNoTranslationForNotTranslatedLocale(): void
{
$translations = new Translations(self::LOCALES);
- $locale = 'en_US';
- $shortName = 'newYearsDay';
+ $locale = 'en_US';
+ $shortName = 'newYearsDay';
$translation = 'New Year\'s Day';
$unknownLocale = 'pl_PL';
@@ -166,7 +168,7 @@ public function testNoTranslationForNotTranslatedLocale(): void
*/
public function testLoadingTranslationsFromDirectory(): void
{
- $shortName = 'newYearsDay';
+ $shortName = 'newYearsDay';
$fileContents = <<<'FILE'
loadTranslations(vfsStream::url('root/lang'));
- $locale = 'en_US';
+ $locale = 'en_US';
$translation = 'New Year\'s Day';
$this->assertNotNull($translations->getTranslations($shortName));
@@ -195,7 +197,7 @@ public function testLoadingTranslationsFromDirectory(): void
*/
public function testNotLoadingTranslationsFromFileWithInvalidExtension(): void
{
- $shortName = 'newYearsDay';
+ $shortName = 'newYearsDay';
$fileContents = <<<'FILE'
expectException(UnknownLocaleException::class);
+
+ $shortName = 'newYearsDay';
$fileContents = <<<'FILE'
expectException(InvalidArgumentException::class);
+
vfsStream::setup();
$translations = new Translations(self::LOCALES);
@@ -254,7 +258,7 @@ public function testLoadingTranslationsFromInexistentDirectory(): void
*/
public function testLoadingMultipleTranslationsFromDirectory(): void
{
- $firstShortName = 'newYearsDay';
+ $firstShortName = 'newYearsDay';
$firstFileContents = <<<'FILE'
[
- $firstShortName . '.php' => $firstFileContents,
- $secondShortName . '.php' => $secondFileContents
- ]
+ $firstShortName . '.php' => $firstFileContents,
+ $secondShortName . '.php' => $secondFileContents,
+ ],
]);
$translations = new Translations(self::LOCALES);
$translations->loadTranslations(vfsStream::url('root/lang'));
- $locale = 'en_US';
+ $locale = 'en_US';
$translation = 'New Year\'s Day';
$this->assertNotNull($translations->getTranslations($firstShortName));
@@ -292,7 +296,7 @@ public function testLoadingMultipleTranslationsFromDirectory(): void
$this->assertIsString($translations->getTranslation($firstShortName, $locale));
$this->assertEquals($translation, $translations->getTranslation($firstShortName, $locale));
- $locale = 'nl_NL';
+ $locale = 'nl_NL';
$translation = 'Eerste Paasdag';
$this->assertNotNull($translations->getTranslations($secondShortName));
diff --git a/tests/Base/YasumiExternalProvider.php b/tests/Base/YasumiExternalProvider.php
index 7502e9709..2dccb5642 100644
--- a/tests/Base/YasumiExternalProvider.php
+++ b/tests/Base/YasumiExternalProvider.php
@@ -1,4 +1,4 @@
-expectException(InvalidYearException::class);
+
Yasumi::create('Japan', 10100);
}
/**
* Tests that an InvalidArgumentException is thrown in case an invalid holiday provider is given.
*
- * @expectedException InvalidArgumentException
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testCreateWithInvalidProvider(): void
{
+ $this->expectException(ProviderNotFoundException::class);
+
Yasumi::create('Mars');
}
/**
* Tests that an InvalidArgumentException is thrown in case we try to load a Trait as provider.
*
- * @expectedException InvalidArgumentException
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testCreateWithInvalidProviderBecauseItsATrait(): void
{
+ $this->expectException(InvalidArgumentException::class);
+
Yasumi::create('CommonHolidays');
}
/**
* Tests that an InvalidArgumentException is thrown in case we try to load the AbstractProvider as provider.
*
- * @expectedException InvalidArgumentException
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testCreateWithAbstractClassProvider(): void
{
+ $this->expectException(InvalidArgumentException::class);
+
Yasumi::create('AbstractProvider');
}
/**
* Tests that Yasumi allows external classes that extend the ProviderInterface.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testCreateWithAbstractExtension(): void
{
- $class = YasumiExternalProvider::class;
+ $class = YasumiExternalProvider::class;
$instance = Yasumi::create(
$class,
Factory::create()->numberBetween(self::YEAR_LOWER_BOUND, self::YEAR_UPPER_BOUND)
@@ -98,11 +114,12 @@ public function testCreateWithAbstractExtension(): void
/**
* Tests that an Yasumi\Exception\UnknownLocaleException is thrown in case an invalid locale is given.
*
- * @expectedException \Yasumi\Exception\UnknownLocaleException
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testCreateWithInvalidLocale(): void
{
+ $this->expectException(UnknownLocaleException::class);
+
Yasumi::create(
'Japan',
Factory::create()->numberBetween(self::YEAR_LOWER_BOUND, self::YEAR_UPPER_BOUND),
@@ -112,7 +129,7 @@ public function testCreateWithInvalidLocale(): void
/**
* Tests that the getIterator function returns an ArrayIterator object
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testGetIterator(): void
{
@@ -121,12 +138,12 @@ public function testGetIterator(): void
Factory::create()->numberBetween(self::YEAR_LOWER_BOUND, self::YEAR_UPPER_BOUND)
);
- $this->assertInstanceOf(\ArrayIterator::class, $holidays->getIterator());
+ $this->assertInstanceOf(ArrayIterator::class, $holidays->getIterator());
}
/**
* Tests that the count function returns an integer and a correct count for the test holiday provider
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testCount(): void
{
@@ -140,23 +157,23 @@ public function testCount(): void
/**
* Tests that the getType function returns a string for the test holiday provider
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testGetType(): void
{
$holidays = Yasumi::create('Japan', Factory::create()->numberBetween(1949, self::YEAR_UPPER_BOUND));
- $holiday = $holidays->getHoliday('newYearsDay');
+ $holiday = $holidays->getHoliday('newYearsDay');
$this->assertIsString($holiday->getType());
}
/**
* Tests that the getYear function returns an integer for the test holiday provider
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testGetYear(): void
{
- $year = Factory::create()->numberBetween(self::YEAR_LOWER_BOUND, self::YEAR_UPPER_BOUND);
+ $year = Factory::create()->numberBetween(self::YEAR_LOWER_BOUND, self::YEAR_UPPER_BOUND);
$holidays = Yasumi::create('Netherlands', $year);
$this->assertIsInt($holidays->getYear());
@@ -166,35 +183,31 @@ public function testGetYear(): void
/**
* Tests that the next function returns the next upcoming date (i.e. next year) for the given holiday
*
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testNext(): void
{
$country = 'Japan';
- $name = 'childrensDay';
- $year = Factory::create()->numberBetween(1949, self::YEAR_UPPER_BOUND);
+ $name = 'childrensDay';
+ $year = Factory::create()->numberBetween(1949, self::YEAR_UPPER_BOUND - 1);
$holidays = Yasumi::create($country, $year);
- $this->assertHoliday(
- $country,
- $name,
- (($year < self::YEAR_UPPER_BOUND) ? $year + 1 : self::YEAR_UPPER_BOUND),
- $holidays->next($name)
- );
+ $this->assertHoliday($country, $name, $year + 1, $holidays->next($name));
}
/**
* Tests the next function that an InvalidArgumentException is thrown in case a blank name is given.
*
- * @expectedException InvalidArgumentException
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testNextWithBlankName(): void
{
+ $this->expectException(InvalidArgumentException::class);
+
$holidays = Yasumi::create(
'Netherlands',
- Factory::create()->numberBetween(self::YEAR_LOWER_BOUND, self::YEAR_UPPER_BOUND)
+ Factory::create()->numberBetween(self::YEAR_LOWER_BOUND, self::YEAR_UPPER_BOUND - 1)
);
$holidays->next(null);
}
@@ -202,14 +215,14 @@ public function testNextWithBlankName(): void
/**
* Tests the previous function returns the previous date (i.e. previous year) for the given holiday
*
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testPrevious(): void
{
- $country = 'Netherlands';
- $name = 'liberationDay';
+ $country = 'Netherlands';
+ $name = 'liberationDay';
$year_lower_limit = 1949;
- $year = Factory::create()->numberBetween($year_lower_limit, self::YEAR_UPPER_BOUND);
+ $year = Factory::create()->numberBetween($year_lower_limit, self::YEAR_UPPER_BOUND);
$holidays = Yasumi::create($country, $year);
@@ -224,25 +237,26 @@ public function testPrevious(): void
/**
* Tests the previous function that an InvalidArgumentException is thrown in case a blank name is given.
*
- * @expectedException InvalidArgumentException
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testPreviousWithBlankName(): void
{
+ $this->expectException(InvalidArgumentException::class);
+
$holidays = Yasumi::create(
'Netherlands',
- Factory::create()->numberBetween(self::YEAR_LOWER_BOUND, self::YEAR_UPPER_BOUND)
+ Factory::create()->numberBetween(self::YEAR_LOWER_BOUND + 1, self::YEAR_UPPER_BOUND)
);
$holidays->previous(null);
}
/**
* Tests that the getHolidayNames function returns an array and a correct count for the test holiday provider
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testGetHolidayNames(): void
{
- $holidays = Yasumi::create('Japan', 2015);
+ $holidays = Yasumi::create('Japan', 2015);
$holidayNames = $holidays->getHolidayNames();
$this->assertIsArray($holidayNames);
@@ -252,7 +266,7 @@ public function testGetHolidayNames(): void
/**
* Tests that the WhenIs function returns a string representation of the date the given holiday occurs.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testWhenIs(): void
{
@@ -267,11 +281,12 @@ public function testWhenIs(): void
/**
* Tests that the WhenIs function throws an InvalidArgumentException when a blank name is given.
*
- * @expectedException InvalidArgumentException
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testWhenIsWithBlankName(): void
{
+ $this->expectException(InvalidArgumentException::class);
+
$holidays = Yasumi::create('Japan', 2010);
$holidays->whenIs(null);
}
@@ -279,11 +294,12 @@ public function testWhenIsWithBlankName(): void
/**
* Tests that an InvalidArgumentException is thrown in case a blank name is given for the getHoliday function.
*
- * @expectedException InvalidArgumentException
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testGetHolidayWithBlankName(): void
{
+ $this->expectException(InvalidArgumentException::class);
+
$holidays = Yasumi::create('Netherlands', 1999);
$holidays->getHoliday(null);
}
@@ -291,12 +307,12 @@ public function testGetHolidayWithBlankName(): void
/**
* Tests that the whatWeekDayIs function returns an integer representation of the day of the week the given holiday
* is occurring.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testWhatWeekDayIs(): void
{
$holidays = Yasumi::create('Netherlands', 2110);
- $weekDay = $holidays->whatWeekDayIs('stMartinsDay');
+ $weekDay = $holidays->whatWeekDayIs('stMartinsDay');
$this->assertIsInt($weekDay);
$this->assertEquals(2, $weekDay);
@@ -305,18 +321,19 @@ public function testWhatWeekDayIs(): void
/**
* Tests that the whatWeekDayIs function throws an InvalidArgumentException when a blank name is given.
*
- * @expectedException InvalidArgumentException
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testWhatWeekDayIsWithBlankName(): void
{
+ $this->expectException(InvalidArgumentException::class);
+
$holidays = Yasumi::create('Netherlands', 2388);
$holidays->whatWeekDayIs(null);
}
/**
* Tests that the getProviders function returns an array containing all available holiday providers.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testGetProviders(): void
{
@@ -332,12 +349,12 @@ public function testGetProviders(): void
/**
* Tests that the getProviders function (static call) returns the same data when called again.
*
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testGetProvidersStaticCall(): void
{
- $provider = 'Ireland';
- $providers = Yasumi::getProviders();
+ $provider = 'Ireland';
+ $providers = Yasumi::getProviders();
$initial_providers = $providers;
$this->assertNotEmpty($providers);
@@ -353,24 +370,24 @@ public function testGetProvidersStaticCall(): void
/**
* Tests that the isHoliday function returns a boolean true for a date that is defined as a holiday.
- * @throws \Exception
- * @throws \ReflectionException
- * @throws \Exception
- * @throws \ReflectionException
+ * @throws Exception
+ * @throws ReflectionException
+ * @throws Exception
+ * @throws ReflectionException
*/
public function testIsHoliday(): void
{
- $year = 2110;
+ $year = 2110;
$provider = 'Spain';
- $date = $year . '-08-15';
+ $date = $year . '-08-15';
// Assertion using a DateTime instance
- $isHoliday = Yasumi::create($provider, $year)->isHoliday(new \DateTime($date));
+ $isHoliday = Yasumi::create($provider, $year)->isHoliday(new DateTime($date));
$this->assertIsBool($isHoliday);
$this->assertTrue($isHoliday);
// Assertion using a DateTimeImmutable instance
- $isHoliday = Yasumi::create($provider, $year)->isHoliday(new \DateTimeImmutable($date));
+ $isHoliday = Yasumi::create($provider, $year)->isHoliday(new DateTimeImmutable($date));
$this->assertIsBool($isHoliday);
$this->assertTrue($isHoliday);
@@ -379,24 +396,24 @@ public function testIsHoliday(): void
/**
* Tests that the isHoliday function returns a boolean false for a date that is not defined as a holiday.
- * @throws \Exception
- * @throws \ReflectionException
- * @throws \Exception
- * @throws \ReflectionException
+ * @throws Exception
+ * @throws ReflectionException
+ * @throws Exception
+ * @throws ReflectionException
*/
public function testIsNotHoliday(): void
{
- $year = 5220;
+ $year = 5220;
$provider = 'Japan';
- $date = $year . '-06-10';
+ $date = $year . '-06-10';
// Assertion using a DateTime instance
- $isHoliday = Yasumi::create($provider, $year)->isHoliday(new \DateTime($date));
+ $isHoliday = Yasumi::create($provider, $year)->isHoliday(new DateTime($date));
$this->assertIsBool($isHoliday);
$this->assertFalse($isHoliday);
// Assertion using a DateTimeImmutable instance
- $isHoliday = Yasumi::create($provider, $year)->isHoliday(new \DateTimeImmutable($date));
+ $isHoliday = Yasumi::create($provider, $year)->isHoliday(new DateTimeImmutable($date));
$this->assertIsBool($isHoliday);
$this->assertFalse($isHoliday);
@@ -406,16 +423,17 @@ public function testIsNotHoliday(): void
/**
* Tests that the isHoliday function throws a TypeError when the given argument is not an instance that
* implements the DateTimeInterface (e.g. DateTime or DateTimeImmutable)
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testIsHolidayException(): void
{
- $this->expectException(\TypeError::class);
+ $this->expectException(TypeError::class);
+ /** @noinspection PhpParamsInspection */
Yasumi::create('Spain', Factory::create()->numberBetween(
self::YEAR_LOWER_BOUND,
self::YEAR_UPPER_BOUND
- ))->isHoliday(new \stdClass());
+ ))->isHoliday(new stdClass());
}
/**
@@ -423,24 +441,24 @@ public function testIsHolidayException(): void
* the weekend.
*
* @TODO Add additional unit tests for those holiday providers that differ from the global definition
- * @throws \Exception
- * @throws \ReflectionException
- * @throws \Exception
- * @throws \ReflectionException
+ * @throws Exception
+ * @throws ReflectionException
+ * @throws Exception
+ * @throws ReflectionException
*/
public function testIsWorkingDay(): void
{
- $year = 2020;
+ $year = 2020;
$provider = 'Netherlands';
- $date = $year . '-06-02';
+ $date = $year . '-06-02';
// Assertion using a DateTime instance
- $isWorkingDay = Yasumi::create($provider, $year)->isWorkingDay(new \DateTime($date));
+ $isWorkingDay = Yasumi::create($provider, $year)->isWorkingDay(new DateTime($date));
$this->assertIsBool($isWorkingDay);
$this->assertTrue($isWorkingDay);
// Assertion using a DateTimeImmutable instance
- $isWorkingDay = Yasumi::create($provider, $year)->isWorkingDay(new \DateTimeImmutable($date));
+ $isWorkingDay = Yasumi::create($provider, $year)->isWorkingDay(new DateTimeImmutable($date));
$this->assertIsBool($isWorkingDay);
$this->assertTrue($isWorkingDay);
@@ -452,24 +470,24 @@ public function testIsWorkingDay(): void
* the weekend.
*
* @TODO Add additional unit tests for those holiday providers that differ from the global definition
- * @throws \Exception
- * @throws \ReflectionException
- * @throws \Exception
- * @throws \ReflectionException
+ * @throws Exception
+ * @throws ReflectionException
+ * @throws Exception
+ * @throws ReflectionException
*/
public function testIsNotWorkingDay(): void
{
- $year = 2016;
+ $year = 2016;
$provider = 'Japan';
- $date = $year . '-01-11';
+ $date = $year . '-01-11';
// Assertion using a DateTime instance
- $isNotWorkingDay = Yasumi::create($provider, $year)->isWorkingDay(new \DateTime($date));
+ $isNotWorkingDay = Yasumi::create($provider, $year)->isWorkingDay(new DateTime($date));
$this->assertIsBool($isNotWorkingDay);
$this->assertFalse($isNotWorkingDay);
// Assertion using a DateTimeImmutable instance
- $isNotWorkingDay = Yasumi::create($provider, $year)->isWorkingDay(new \DateTimeImmutable($date));
+ $isNotWorkingDay = Yasumi::create($provider, $year)->isWorkingDay(new DateTimeImmutable($date));
$this->assertIsBool($isNotWorkingDay);
$this->assertFalse($isNotWorkingDay);
@@ -481,22 +499,23 @@ public function testIsNotWorkingDay(): void
* that implements the DateTimeInterface (e.g. DateTime or DateTimeImmutable)
*
* @TODO Add additional unit tests for those holiday providers that differ from the global definition
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testIsWorkingDayException(): void
{
- $this->expectException(\TypeError::class);
+ $this->expectException(TypeError::class);
+ /** @noinspection PhpParamsInspection */
Yasumi::create('SouthAfrica', Factory::create()->numberBetween(
self::YEAR_LOWER_BOUND,
self::YEAR_UPPER_BOUND
- ))->isWorkingDay(new \stdClass());
+ ))->isWorkingDay(new stdClass());
}
/**
* Tests that holidays successfully can be removed from the list of holidays of a provider
*
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testRemoveHoliday(): void
{
@@ -541,4 +560,70 @@ public function testRemoveHoliday(): void
$this->assertArrayNotHasKey('augustHoliday', $holidaysAfterRemoval);
$this->assertArrayNotHasKey('octoberHoliday', $holidaysAfterRemoval);
}
+
+ /**
+ * Tests that a holiday provider instance can be created by using the ISO3166-2
+ * country/region code. (Using the Yasumi::createByISO3166_2 method)
+ *
+ * @throws ReflectionException
+ */
+ public function testCreateByISO3166_2(): void
+ {
+ $year = Factory::create()->numberBetween(
+ self::YEAR_LOWER_BOUND,
+ self::YEAR_UPPER_BOUND
+ );
+
+ $provider = Yasumi::createByISO3166_2(
+ 'JP',
+ $year
+ );
+
+ $this->assertInstanceOf(AbstractProvider::class, $provider);
+ $this->assertEquals($year, $provider->getYear());
+ }
+
+ /**
+ * Tests that a ProviderNotFoundException is thrown when providing a invalid
+ * ISO3166-2 code when using the Yasumi::createByISO3166_2 method.
+ *
+ * @throws ReflectionException
+ */
+ public function testCreateByISO3166_2WithInvalidCode(): void
+ {
+ $this->expectException(ProviderNotFoundException::class);
+
+ Yasumi::createByISO3166_2('XX', 2019);
+ }
+
+ /**
+ * Tests that a holiday can be added to a provider. In addition, it
+ * tests that the same holiday instance isn't added twice.
+ *
+ * @throws ReflectionException
+ * @throws Exception
+ */
+ public function testAddExistingHoliday(): void
+ {
+ $provider = Yasumi::createByISO3166_2('NL', 2019);
+ $holidayName = 'testHoliday';
+
+ $holiday = new Holiday($holidayName, [], new DateTime());
+ $originalHolidays = $provider->getHolidayNames();
+
+ // Add a new holiday
+ $provider->addHoliday($holiday);
+ $newHolidays = $provider->getHolidayNames();
+ $this->assertContains($holidayName, $provider->getHolidayNames());
+ $this->assertNotSameSize($originalHolidays, $newHolidays);
+ $this->assertNotEquals($newHolidays, $originalHolidays);
+
+ // Add same holiday again
+ $provider->addHoliday($holiday);
+ $this->assertContains($holidayName, $provider->getHolidayNames());
+ $this->assertSameSize($newHolidays, $provider->getHolidayNames());
+ $this->assertNotSameSize($originalHolidays, $provider->getHolidayNames());
+ $this->assertEquals($newHolidays, $provider->getHolidayNames());
+ $this->assertNotEquals($originalHolidays, $provider->getHolidayNames());
+ }
}
diff --git a/tests/Base/YasumiWorkdayTest.php b/tests/Base/YasumiWorkdayTest.php
index 8b0ce05f6..acb84fe20 100644
--- a/tests/Base/YasumiWorkdayTest.php
+++ b/tests/Base/YasumiWorkdayTest.php
@@ -1,4 +1,4 @@
-assertInstanceOf(\DateTime::class, $result);
+ $this->assertInstanceOf(DateTime::class, $result);
$this->assertEquals($expectedDate, $result->format(self::FORMAT_DATE));
// Assertion using a DateTimeImmutable instance
- $startDate = new \DateTimeImmutable($date, new \DateTimeZone($timezone));
- $result = Yasumi::nextWorkingDay($provider, $startDate);
+ $startDate = new DateTimeImmutable($date, new DateTimeZone($timezone));
+ $result = Yasumi::nextWorkingDay($provider, $startDate);
- $this->assertInstanceOf(\DateTimeImmutable::class, $result);
+ $this->assertInstanceOf(DateTimeImmutable::class, $result);
$this->assertEquals($expectedDate, $result->format(self::FORMAT_DATE));
}
/**
* Tests that the prevWorkingDay function returns an object that implements the DateTimeInterface (e.g. DateTime)
*
- * @throws \Exception
- * @throws \ReflectionException
+ * @throws Exception
+ * @throws ReflectionException
*/
public function testPreviousWorkingDay(): void
{
// Includes a weekend and a holiday
- $provider = 'USA';
- $date = '2016-07-05';
- $timezone = 'America/New_York';
+ $provider = 'USA';
+ $date = '2016-07-05';
+ $timezone = 'America/New_York';
$expectedDate = '2016-07-01';
// Assertion using a DateTime instance
- $startDate = new \DateTime($date, new \DateTimeZone($timezone));
- $result = Yasumi::prevWorkingDay($provider, $startDate);
+ $startDate = new DateTime($date, new DateTimeZone($timezone));
+ $result = Yasumi::prevWorkingDay($provider, $startDate);
- $this->assertInstanceOf(\DateTime::class, $result);
+ $this->assertInstanceOf(DateTime::class, $result);
$this->assertEquals($expectedDate, $result->format(self::FORMAT_DATE));
// Assertion using a DateTimeImmutable instance
- $startDate = new \DateTimeImmutable($date, new \DateTimeZone($timezone));
- $result = Yasumi::prevWorkingDay($provider, $startDate);
+ $startDate = new DateTimeImmutable($date, new DateTimeZone($timezone));
+ $result = Yasumi::prevWorkingDay($provider, $startDate);
- $this->assertInstanceOf(\DateTimeImmutable::class, $result);
+ $this->assertInstanceOf(DateTimeImmutable::class, $result);
$this->assertEquals($expectedDate, $result->format(self::FORMAT_DATE));
}
@@ -81,8 +91,8 @@ public function testPreviousWorkingDay(): void
* Tests that the prevWorkingDay and nextWorkingDay functions returns an object that implements the
* DateTimeInterface (e.g. DateTime) when an interval is chosen that passes the year boundary (i.e. beyond 12/31)
*
- * @throws \Exception
- * @throws \ReflectionException
+ * @throws Exception
+ * @throws ReflectionException
*/
public function testYearBoundary(): void
{
@@ -104,32 +114,32 @@ public function testYearBoundary(): void
* @see https://www.timeanddate.com/calendar/?year=2016&country=1
*/
- $provider = 'USA';
- $timezone = 'America/New_York';
- $interval = 20;
- $start = '2015-12-20';
- $expectedNext = '2016-01-20';
+ $provider = 'USA';
+ $timezone = 'America/New_York';
+ $interval = 20;
+ $start = '2015-12-20';
+ $expectedNext = '2016-01-20';
$expectedPrevious = '2015-12-18';
// Assertion using a DateTime instance
- $startDate = new \DateTime($start, new \DateTimeZone($timezone));
- $result = Yasumi::nextWorkingDay($provider, $startDate, $interval);
+ $startDate = new DateTime($start, new DateTimeZone($timezone));
+ $result = Yasumi::nextWorkingDay($provider, $startDate, $interval);
$this->assertEquals($expectedNext, $result->format(self::FORMAT_DATE));
- $startDate = new \DateTime($expectedNext, new \DateTimeZone($timezone));
- $result = Yasumi::prevWorkingDay($provider, $startDate, $interval);
+ $startDate = new DateTime($expectedNext, new DateTimeZone($timezone));
+ $result = Yasumi::prevWorkingDay($provider, $startDate, $interval);
$this->assertEquals($expectedPrevious, $result->format(self::FORMAT_DATE));
// Assertion using a DateTimeImmutable instance
- $startDate = new \DateTimeImmutable($start, new \DateTimeZone($timezone));
- $result = Yasumi::nextWorkingDay($provider, $startDate, $interval);
+ $startDate = new DateTimeImmutable($start, new DateTimeZone($timezone));
+ $result = Yasumi::nextWorkingDay($provider, $startDate, $interval);
$this->assertEquals($expectedNext, $result->format(self::FORMAT_DATE));
- $startDate = new \DateTimeImmutable($expectedNext, new \DateTimeZone($timezone));
- $result = Yasumi::prevWorkingDay($provider, $startDate, $interval);
+ $startDate = new DateTimeImmutable($expectedNext, new DateTimeZone($timezone));
+ $result = Yasumi::prevWorkingDay($provider, $startDate, $interval);
$this->assertEquals($expectedPrevious, $result->format(self::FORMAT_DATE));
}
}
diff --git a/tests/Belgium/AllSaintsDayTest.php b/tests/Belgium/AllSaintsDayTest.php
index b98bc74d1..f4734046d 100644
--- a/tests/Belgium/AllSaintsDayTest.php
+++ b/tests/Belgium/AllSaintsDayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OFFICIAL);
}
/**
* Tests if all observed holidays in Belgium are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -57,7 +58,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Belgium are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -66,7 +67,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Belgium are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -75,7 +76,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Belgium are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -85,7 +86,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear();
}
diff --git a/tests/Belgium/ChristmasTest.php b/tests/Belgium/ChristmasTest.php
index 1856d8a1e..d02079544 100644
--- a/tests/Belgium/ChristmasTest.php
+++ b/tests/Belgium/ChristmasTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(),
- [self::LOCALE => 'Eerste Paasdag']
+ [self::LOCALE => 'Eerste paasdag']
);
}
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Belgium/InternationalWorkersDayTest.php b/tests/Belgium/InternationalWorkersDayTest.php
index a8b41c4c8..f93e82b87 100644
--- a/tests/Belgium/InternationalWorkersDayTest.php
+++ b/tests/Belgium/InternationalWorkersDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(),
- [self::LOCALE => 'Eerste Pinksterdag']
+ [self::LOCALE => 'Eerste pinksterdag']
);
}
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Belgium/pentecostMondayTest.php b/tests/Belgium/pentecostMondayTest.php
index 8557851f1..6f4c0b99f 100644
--- a/tests/Belgium/pentecostMondayTest.php
+++ b/tests/Belgium/pentecostMondayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OFFICIAL);
}
/**
* Tests if all observed holidays in Bosnia are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -55,7 +56,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Bosnia are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -64,7 +65,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Bosnia are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -73,7 +74,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Bosnia are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -83,7 +84,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1992);
}
diff --git a/tests/Bosnia/ChristmasDayTest.php b/tests/Bosnia/ChristmasDayTest.php
index 60541e82c..a63b4ba2b 100644
--- a/tests/Bosnia/ChristmasDayTest.php
+++ b/tests/Bosnia/ChristmasDayTest.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -64,7 +67,7 @@ public function testTranslation(): void
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Bosnia/SecondLabourDay.php b/tests/Bosnia/SecondLabourDay.php
index 03b0e6451..26a91b376 100644
--- a/tests/Bosnia/SecondLabourDay.php
+++ b/tests/Bosnia/SecondLabourDay.php
@@ -1,4 +1,4 @@
-assertDefinedHolidays([
'newYearsDay',
- 'goodFriday',
'tiradentesDay',
'internationalWorkersDay',
'independenceDay',
'ourLadyOfAparecidaDay',
'allSoulsDay',
'proclamationOfRepublicDay',
- 'christmasDay'
+ 'christmasDay',
], self::REGION, $this->year, Holiday::TYPE_OFFICIAL);
}
/**
* Tests if all observed holidays in Brazil are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
$this->assertDefinedHolidays([
'carnavalMonday',
'carnavalTuesday',
+ 'goodFriday',
'easter',
'corpusChristi',
'ashWednesday',
@@ -60,7 +61,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Brazil are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -69,7 +70,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Brazil are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -78,7 +79,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Brazil are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -88,7 +89,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1980);
}
diff --git a/tests/Brazil/CarnavalMondayTest.php b/tests/Brazil/CarnavalMondayTest.php
index b207fc4c3..5dac0d750 100644
--- a/tests/Brazil/CarnavalMondayTest.php
+++ b/tests/Brazil/CarnavalMondayTest.php
@@ -1,4 +1,4 @@
-assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL);
+ $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OBSERVANCE);
}
}
diff --git a/tests/Brazil/IndependenceDayTest.php b/tests/Brazil/IndependenceDayTest.php
index e58f9cfbd..26d081923 100644
--- a/tests/Brazil/IndependenceDayTest.php
+++ b/tests/Brazil/IndependenceDayTest.php
@@ -1,4 +1,4 @@
-assertDefinedHolidays([
'newYearsDay',
+ 'czechRenewalOfIndependentStateDay',
'victoryInEuropeDay',
'goodFriday',
'easterMonday',
@@ -52,16 +54,16 @@ public function testOfficialHolidays(): void
/**
* Tests if all observed holidays in the Czech Republic are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
- $this->assertDefinedHolidays(['christmasEve',], self::REGION, $this->year, Holiday::TYPE_OBSERVANCE);
+ $this->assertDefinedHolidays(['christmasEve'], self::REGION, $this->year, Holiday::TYPE_OBSERVANCE);
}
/**
* Tests if all seasonal holidays in the Czech Republic are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -70,7 +72,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in the Czech Republic are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -79,7 +81,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in the Czech Republic are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -89,7 +91,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1990);
}
diff --git a/tests/CzechRepublic/CzechStateHoodDayTest.php b/tests/CzechRepublic/CzechStateHoodDayTest.php
index 9fe192d5f..bc186bd36 100644
--- a/tests/CzechRepublic/CzechStateHoodDayTest.php
+++ b/tests/CzechRepublic/CzechStateHoodDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(),
- [self::LOCALE => 'Den obnovy samostatného českého státu a Nový rok']
+ [self::LOCALE => 'Nový rok']
);
}
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/CzechRepublic/RenewalOfIndependentCzechStateDayTest.php b/tests/CzechRepublic/RenewalOfIndependentCzechStateDayTest.php
new file mode 100644
index 000000000..76b1ecc49
--- /dev/null
+++ b/tests/CzechRepublic/RenewalOfIndependentCzechStateDayTest.php
@@ -0,0 +1,84 @@
+
+ */
+
+namespace Yasumi\tests\CzechRepublic;
+
+use DateTime;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing Day of renewal of independent czech state in Czechia.
+ *
+ *
+ * @package Yasumi\tests\Slovakia
+ * @author Andrej Rypak (dakujem)
+ * @author Jan Langer
+ */
+class RenewalOfIndependentCzechStateDayTest extends CzechRepublicBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday to be tested
+ */
+ public const HOLIDAY = 'czechRenewalOfIndependentStateDay';
+
+ /**
+ * Tests the holiday defined in this test.
+ *
+ * @dataProvider HolidayDataProvider
+ *
+ * @param int $year the year for which the holiday defined in this test needs to be tested
+ * @param DateTime $expected the expected date
+ *
+ * @throws ReflectionException
+ */
+ public function testHoliday($year, $expected)
+ {
+ $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
+ }
+
+ /**
+ * Returns a list of random test dates used for assertion of the holiday defined in this test
+ *
+ * @return array list of test dates for the holiday defined in this test
+ * @throws Exception
+ */
+ public function HolidayDataProvider(): array
+ {
+ return $this->generateRandomDates(1, 1, self::TIMEZONE);
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(),
+ [self::LOCALE => 'Den obnovy samostatného českého státu']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL);
+ }
+}
diff --git a/tests/CzechRepublic/SaintsCyrilAndMethodiusDayTest.php b/tests/CzechRepublic/SaintsCyrilAndMethodiusDayTest.php
index 6bf231375..6d0ba2042 100644
--- a/tests/CzechRepublic/SaintsCyrilAndMethodiusDayTest.php
+++ b/tests/CzechRepublic/SaintsCyrilAndMethodiusDayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OFFICIAL);
}
/**
* Tests if all observed holidays in Denmark are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -61,7 +62,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Denmark are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -71,7 +72,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Denmark are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -80,7 +81,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Denmark are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -90,7 +91,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1849);
}
diff --git a/tests/Denmark/EasterMondayTest.php b/tests/Denmark/EasterMondayTest.php
index 5a6e067a8..49aff7ae5 100644
--- a/tests/Denmark/EasterMondayTest.php
+++ b/tests/Denmark/EasterMondayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(),
- [self::LOCALE => '2. Juledag']
+ [self::LOCALE => '2. juledag']
);
}
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Denmark/SummerTimeTest.php b/tests/Denmark/SummerTimeTest.php
index d706f5281..04e63ca8a 100644
--- a/tests/Denmark/SummerTimeTest.php
+++ b/tests/Denmark/SummerTimeTest.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -66,7 +69,7 @@ public function testTranslation(): void
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Estonia/ChristmasEveDayTest.php b/tests/Estonia/ChristmasEveDayTest.php
index 19f7fc7a7..ea85a12d1 100644
--- a/tests/Estonia/ChristmasEveDayTest.php
+++ b/tests/Estonia/ChristmasEveDayTest.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -66,7 +69,7 @@ public function testTranslation(): void
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Estonia/EasterDayTest.php b/tests/Estonia/EasterDayTest.php
index 39e0d0edb..1549eb631 100644
--- a/tests/Estonia/EasterDayTest.php
+++ b/tests/Estonia/EasterDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(Estonia::DECLARATION_OF_INDEPENDENCE_YEAR),
- ['en_US' => 'Independence Day']
+ ['en' => 'Independence Day']
);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Estonia/InternationalWorkersDayTest.php b/tests/Estonia/InternationalWorkersDayTest.php
index 7ac8c7f34..e91005593 100644
--- a/tests/Estonia/InternationalWorkersDayTest.php
+++ b/tests/Estonia/InternationalWorkersDayTest.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -66,7 +69,7 @@ public function testTranslation(): void
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Estonia/NewYearsDayTest.php b/tests/Estonia/NewYearsDayTest.php
index cbbf69e95..5d0f94cca 100644
--- a/tests/Estonia/NewYearsDayTest.php
+++ b/tests/Estonia/NewYearsDayTest.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -66,7 +69,7 @@ public function testTranslation(): void
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Estonia/PentecostTest.php b/tests/Estonia/PentecostTest.php
index 52221390b..92bdd46ac 100644
--- a/tests/Estonia/PentecostTest.php
+++ b/tests/Estonia/PentecostTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(Estonia::RESTORATION_OF_INDEPENDENCE_YEAR),
- ['en_US' => 'Day of Restoration of Independence']
+ ['en' => 'Day of Restoration of Independence']
);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Estonia/SecondChristmasDayTest.php b/tests/Estonia/SecondChristmasDayTest.php
index 694568422..9b43940bb 100644
--- a/tests/Estonia/SecondChristmasDayTest.php
+++ b/tests/Estonia/SecondChristmasDayTest.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -66,7 +69,7 @@ public function testTranslation(): void
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Estonia/StJohnsDayTest.php b/tests/Estonia/StJohnsDayTest.php
index 2a3bf590e..5a688fd88 100644
--- a/tests/Estonia/StJohnsDayTest.php
+++ b/tests/Estonia/StJohnsDayTest.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -66,7 +69,7 @@ public function testTranslation(): void
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Estonia/VictoryDayTest.php b/tests/Estonia/VictoryDayTest.php
index 4fcaa36c0..cd392d34f 100644
--- a/tests/Estonia/VictoryDayTest.php
+++ b/tests/Estonia/VictoryDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(Estonia::VICTORY_DAY_START_YEAR),
- ['en_US' => 'Victory Day']
+ ['en' => 'Victory Day']
);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Finland/AllSaintsDayTest.php b/tests/Finland/AllSaintsDayTest.php
index de92950aa..01cfce9f4 100644
--- a/tests/Finland/AllSaintsDayTest.php
+++ b/tests/Finland/AllSaintsDayTest.php
@@ -1,4 +1,4 @@
-format('l') === 'Saturday') {
+ if ('Saturday' === $date->format('l')) {
$data[] = [$year, $date];
break;
}
@@ -72,7 +74,7 @@ public function HolidayDataProvider(): array
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -86,7 +88,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Finland/AscensionDayTest.php b/tests/Finland/AscensionDayTest.php
index 5d848273f..53efe6949 100644
--- a/tests/Finland/AscensionDayTest.php
+++ b/tests/Finland/AscensionDayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OFFICIAL);
}
/**
* Tests if all observed holidays in Finland are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -58,7 +59,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Finland are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -67,7 +68,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Finland are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -76,7 +77,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Finland are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -86,7 +87,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1917);
}
diff --git a/tests/Finland/GoodFridayTest.php b/tests/Finland/GoodFridayTest.php
index c5e22985a..50bf6a15f 100644
--- a/tests/Finland/GoodFridayTest.php
+++ b/tests/Finland/GoodFridayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(self::ADJUSTMENT_YEAR);
$holidays = Yasumi::create(self::REGION, $year);
- $holiday = $holidays->getHoliday(self::HOLIDAY);
+ $holiday = $holidays->getHoliday(self::HOLIDAY);
// Some basic assertions
$this->assertInstanceOf('Yasumi\Provider\\' . \str_replace('/', '\\', self::REGION), $holidays);
@@ -79,7 +81,7 @@ public function testHolidayAfterAdjustment()
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -93,7 +95,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/France/AllSaintsDayTest.php b/tests/France/AllSaintsDayTest.php
index f7baff4bf..86918086a 100644
--- a/tests/France/AllSaintsDayTest.php
+++ b/tests/France/AllSaintsDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(),
- [self::LOCALE => 'La Toussaint']
+ [self::LOCALE => 'Toussaint']
);
}
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
@@ -68,7 +70,7 @@ public function testHolidayType(): void
* Returns a list of random test dates used for assertion of All Saints' Day.
*
* @return array list of test dates for All Saints' Day
- * @throws \Exception
+ * @throws Exception
*/
public function AllSaintsDayDataProvider(): array
{
diff --git a/tests/France/ArmisticeDayTest.php b/tests/France/ArmisticeDayTest.php
index e6cc7c4b2..462c0e507 100644
--- a/tests/France/ArmisticeDayTest.php
+++ b/tests/France/ArmisticeDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(self::ESTABLISHMENT_YEAR),
- [self::LOCALE => 'Armistice']
+ [self::LOCALE => 'Armistice 1918']
);
}
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/France/AscensionDayTest.php b/tests/France/AscensionDayTest.php
index 9b232f7ed..c19e62280 100644
--- a/tests/France/AscensionDayTest.php
+++ b/tests/France/AscensionDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(),
- [self::LOCALE => 'L\'Assomption de Marie']
+ [self::LOCALE => 'Assomption']
);
}
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
@@ -68,7 +70,7 @@ public function testHolidayType(): void
* Returns a list of random test dates used for assertion of the day of the Assumption of Mary.
*
* @return array list of test dates for the day of the Assumption of Mary
- * @throws \Exception
+ * @throws Exception
*/
public function AssumptionOfMaryDataProvider(): array
{
diff --git a/tests/France/BasRhin/BasRhinBaseTestCase.php b/tests/France/BasRhin/BasRhinBaseTestCase.php
index 0a5d29c39..9d8d4b4d0 100644
--- a/tests/France/BasRhin/BasRhinBaseTestCase.php
+++ b/tests/France/BasRhin/BasRhinBaseTestCase.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OFFICIAL);
}
/**
* Tests if all observed holidays in Bas-Rhin (France) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -58,7 +59,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Bas-Rhin (France) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -67,7 +68,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Bas-Rhin (France) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -76,7 +77,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Bas-Rhin (France) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -86,7 +87,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1945);
}
diff --git a/tests/France/BasRhin/GoodFridayTest.php b/tests/France/BasRhin/GoodFridayTest.php
index 4d7a688f9..5b124a5b1 100644
--- a/tests/France/BasRhin/GoodFridayTest.php
+++ b/tests/France/BasRhin/GoodFridayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OFFICIAL);
}
/**
* Tests if all observed holidays in France are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -56,7 +57,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in France are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -65,7 +66,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in France are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -74,7 +75,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in France are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -84,7 +85,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1945);
}
diff --git a/tests/France/HautRhin/GoodFridayTest.php b/tests/France/HautRhin/GoodFridayTest.php
index 8b04e7b63..4a0035718 100644
--- a/tests/France/HautRhin/GoodFridayTest.php
+++ b/tests/France/HautRhin/GoodFridayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OFFICIAL);
}
/**
* Tests if all observed holidays in Haut-Rhin (France) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -58,7 +59,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Haut-Rhin (France) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -67,7 +68,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Haut-Rhin (France) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -76,7 +77,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Haut-Rhin (France) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -86,7 +87,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1945);
}
diff --git a/tests/France/HautRhin/stStephensDayTest.php b/tests/France/HautRhin/stStephensDayTest.php
index efaee6358..b56dffa4c 100644
--- a/tests/France/HautRhin/stStephensDayTest.php
+++ b/tests/France/HautRhin/stStephensDayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OFFICIAL);
}
/**
* Tests if all observed holidays in Moselle (France) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -58,7 +59,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Moselle (France) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -67,7 +68,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Moselle (France) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -76,7 +77,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Moselle (France) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -86,7 +87,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1945);
}
diff --git a/tests/France/Moselle/stStephensDayTest.php b/tests/France/Moselle/stStephensDayTest.php
index 52a0528ca..09591f444 100644
--- a/tests/France/Moselle/stStephensDayTest.php
+++ b/tests/France/Moselle/stStephensDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(self::ESTABLISHMENT_YEAR),
- [self::LOCALE => 'Fête de la Victoire']
+ [self::LOCALE => 'Victoire 1945']
);
}
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Germany/AscensionDayTest.php b/tests/Germany/AscensionDayTest.php
index 532166856..efe055a89 100644
--- a/tests/Germany/AscensionDayTest.php
+++ b/tests/Germany/AscensionDayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OFFICIAL);
}
/**
* Tests if all observed holidays in Baden-Württemberg (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -54,7 +55,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Baden-Württemberg (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -63,7 +64,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Baden-Württemberg (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -72,7 +73,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Baden-Württemberg (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -87,7 +88,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1990);
}
diff --git a/tests/Germany/BadenWurttemberg/CorpusChristiTest.php b/tests/Germany/BadenWurttemberg/CorpusChristiTest.php
index 72e4ba234..be245a028 100644
--- a/tests/Germany/BadenWurttemberg/CorpusChristiTest.php
+++ b/tests/Germany/BadenWurttemberg/CorpusChristiTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OFFICIAL);
}
/**
* Tests if all observed holidays in Bavaria (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -54,7 +55,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Bavaria (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -63,7 +64,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Bavaria (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -72,7 +73,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Bavaria (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -87,7 +88,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1990);
}
diff --git a/tests/Germany/Bavaria/CorpusChristiTest.php b/tests/Germany/Bavaria/CorpusChristiTest.php
index 656c9cc7e..9f919e04a 100644
--- a/tests/Germany/Bavaria/CorpusChristiTest.php
+++ b/tests/Germany/Bavaria/CorpusChristiTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OFFICIAL);
}
/**
* Tests if all observed holidays in Berlin (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -54,7 +55,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Berlin (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -63,7 +64,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Berlin (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -72,7 +73,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Berlin (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -82,7 +83,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1990);
}
diff --git a/tests/Germany/Berlin/GermanUnityDayTest.php b/tests/Germany/Berlin/GermanUnityDayTest.php
index 9e80f50d3..3bbd0daa3 100644
--- a/tests/Germany/Berlin/GermanUnityDayTest.php
+++ b/tests/Germany/Berlin/GermanUnityDayTest.php
@@ -1,4 +1,4 @@
-year >= 1990) {
@@ -56,7 +57,7 @@ public function testOfficialHolidays(): void
/**
* Tests if all observed holidays in Brandenburg (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -65,7 +66,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Brandenburg (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -74,7 +75,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Brandenburg (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -83,7 +84,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Brandenburg (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -93,7 +94,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear();
}
diff --git a/tests/Germany/Brandenburg/GermanUnityDayTest.php b/tests/Germany/Brandenburg/GermanUnityDayTest.php
index 3dbec6fa4..9bc4e62d6 100644
--- a/tests/Germany/Brandenburg/GermanUnityDayTest.php
+++ b/tests/Germany/Brandenburg/GermanUnityDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
$data[] = [$year, new DateTime("$year-10-31", new DateTimeZone(self::TIMEZONE))];
}
@@ -67,7 +69,7 @@ public function HolidayDataProvider(): array
/**
* Tests the holiday defined in this test before establishment.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayBeforeEstablishment()
{
@@ -80,7 +82,7 @@ public function testHolidayBeforeEstablishment()
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -94,7 +96,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Germany/Bremen/BremenBaseTestCase.php b/tests/Germany/Bremen/BremenBaseTestCase.php
index fac3179fa..c82cbdb08 100644
--- a/tests/Germany/Bremen/BremenBaseTestCase.php
+++ b/tests/Germany/Bremen/BremenBaseTestCase.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OFFICIAL);
}
/**
* Tests if all observed holidays in Bremen (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -54,7 +55,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Bremen (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -63,7 +64,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Bremen (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -72,7 +73,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Bremen (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -82,7 +83,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1990);
}
diff --git a/tests/Germany/Bremen/GermanUnityDayTest.php b/tests/Germany/Bremen/GermanUnityDayTest.php
index 48826be70..9d2758b62 100644
--- a/tests/Germany/Bremen/GermanUnityDayTest.php
+++ b/tests/Germany/Bremen/GermanUnityDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
$data[] = [$year, new DateTime("$year-10-31", new DateTimeZone(self::TIMEZONE))];
}
@@ -67,20 +69,20 @@ public function HolidayDataProvider(): array
/**
* Tests the holiday defined in this test before establishment.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayBeforeEstablishment()
{
$this->assertNotHoliday(
self::REGION,
self::HOLIDAY,
- $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 2)
);
}
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -94,7 +96,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Germany/ChristmasTest.php b/tests/Germany/ChristmasTest.php
index fe9b6f773..64182a0ad 100644
--- a/tests/Germany/ChristmasTest.php
+++ b/tests/Germany/ChristmasTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OFFICIAL);
}
/**
* Tests if all observed holidays in Germany are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -54,7 +55,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Germany are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -63,7 +64,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Germany are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -72,7 +73,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Germany are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -82,7 +83,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1990);
}
diff --git a/tests/Germany/GoodFridayTest.php b/tests/Germany/GoodFridayTest.php
index 13ddfaf2d..9c2dc7def 100644
--- a/tests/Germany/GoodFridayTest.php
+++ b/tests/Germany/GoodFridayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
$data[] = [$year, new DateTime("$year-10-31", new DateTimeZone(self::TIMEZONE))];
}
@@ -67,7 +69,7 @@ public function HolidayDataProvider(): array
/**
* Tests the holiday defined in this test before establishment.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayBeforeEstablishment()
{
@@ -80,7 +82,7 @@ public function testHolidayBeforeEstablishment()
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -94,7 +96,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Germany/Hamburg/GermanUnityDay.php b/tests/Germany/Hamburg/GermanUnityDay.php
index 35b039d00..cb6a41586 100644
--- a/tests/Germany/Hamburg/GermanUnityDay.php
+++ b/tests/Germany/Hamburg/GermanUnityDay.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OFFICIAL);
}
/**
* Tests if all observed holidays in Hamburg (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -54,7 +55,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Hamburg (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -63,7 +64,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Hamburg (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -72,7 +73,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Hamburg (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -82,7 +83,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1990);
}
diff --git a/tests/Germany/Hamburg/ReformationDay2017Test.php b/tests/Germany/Hamburg/ReformationDay2017Test.php
index c1df5becc..c75c04639 100644
--- a/tests/Germany/Hamburg/ReformationDay2017Test.php
+++ b/tests/Germany/Hamburg/ReformationDay2017Test.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OFFICIAL);
}
/**
* Tests if all observed holidays in Hesse (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -54,7 +55,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Hesse (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -63,7 +64,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Hesse (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -72,7 +73,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Hesse (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -82,7 +83,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1990);
}
diff --git a/tests/Germany/Hesse/ReformationDay2017Test.php b/tests/Germany/Hesse/ReformationDay2017Test.php
index 2c56cd7d2..c37254259 100644
--- a/tests/Germany/Hesse/ReformationDay2017Test.php
+++ b/tests/Germany/Hesse/ReformationDay2017Test.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OFFICIAL);
}
/**
* Tests if all observed holidays in Lower Saxony (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -54,7 +55,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Lower Saxony (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -63,7 +64,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Lower Saxony (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -72,7 +73,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Lower Saxony (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -82,7 +83,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1990);
}
diff --git a/tests/Germany/LowerSaxony/ReformationDay2017Test.php b/tests/Germany/LowerSaxony/ReformationDay2017Test.php
index 143e4f3fb..e14ef79ba 100644
--- a/tests/Germany/LowerSaxony/ReformationDay2017Test.php
+++ b/tests/Germany/LowerSaxony/ReformationDay2017Test.php
@@ -1,4 +1,4 @@
-generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
$data[] = [$year, new DateTime("$year-10-31", new DateTimeZone(self::TIMEZONE))];
}
@@ -67,20 +69,20 @@ public function HolidayDataProvider(): array
/**
* Tests the holiday defined in this test before establishment.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayBeforeEstablishment()
{
$this->assertNotHoliday(
self::REGION,
self::HOLIDAY,
- $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 2)
);
}
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -94,7 +96,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Germany/MecklenburgWesternPomerania/GermanUnityDayTest.php b/tests/Germany/MecklenburgWesternPomerania/GermanUnityDayTest.php
index 95d0c5c1c..793aecfc8 100644
--- a/tests/Germany/MecklenburgWesternPomerania/GermanUnityDayTest.php
+++ b/tests/Germany/MecklenburgWesternPomerania/GermanUnityDayTest.php
@@ -1,4 +1,4 @@
-year >= 1990) {
@@ -54,7 +55,7 @@ public function testOfficialHolidays(): void
/**
* Tests if all observed holidays in Mecklenburg-Western Pomerania (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -63,7 +64,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Mecklenburg-Western Pomerania (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -72,7 +73,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Mecklenburg-Western Pomerania (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -81,7 +82,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Mecklenburg-Western Pomerania (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -91,7 +92,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear();
}
diff --git a/tests/Germany/MecklenburgWesternPomerania/ReformationDayTest.php b/tests/Germany/MecklenburgWesternPomerania/ReformationDayTest.php
index 5c81764c6..5e8a7d3a8 100644
--- a/tests/Germany/MecklenburgWesternPomerania/ReformationDayTest.php
+++ b/tests/Germany/MecklenburgWesternPomerania/ReformationDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
$data[] = [$year, new DateTime("$year-10-31", new DateTimeZone(self::TIMEZONE))];
}
@@ -52,7 +54,7 @@ public function HolidayDataProvider(): array
/**
* Tests the holiday defined in this test before establishment.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayBeforeEstablishment()
{
@@ -65,7 +67,7 @@ public function testHolidayBeforeEstablishment()
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -79,7 +81,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Germany/NewYearsDayTest.php b/tests/Germany/NewYearsDayTest.php
index 5a0c6a8d6..8d6ba2530 100644
--- a/tests/Germany/NewYearsDayTest.php
+++ b/tests/Germany/NewYearsDayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OFFICIAL);
}
/**
* Tests if all observed holidays in North Rhine-Westphalia (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -54,7 +55,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in North Rhine-Westphalia (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -63,7 +64,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in North Rhine-Westphalia (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -72,7 +73,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in North Rhine-Westphalia (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -82,7 +83,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1990);
}
diff --git a/tests/Germany/NorthRhineWestphalia/ReformationDay2017Test.php b/tests/Germany/NorthRhineWestphalia/ReformationDay2017Test.php
index 4c9fffdc5..9bbdeed81 100644
--- a/tests/Germany/NorthRhineWestphalia/ReformationDay2017Test.php
+++ b/tests/Germany/NorthRhineWestphalia/ReformationDay2017Test.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OFFICIAL);
}
/**
* Tests if all observed holidays in Rhineland Palatinate (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -54,7 +55,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Rhineland Palatinate (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -63,7 +64,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Rhineland Palatinate (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -72,7 +73,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Rhineland Palatinate (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -82,7 +83,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1990);
}
diff --git a/tests/Germany/Saarland/AllSaintsDayTest.php b/tests/Germany/Saarland/AllSaintsDayTest.php
index dbf289179..415fd6389 100644
--- a/tests/Germany/Saarland/AllSaintsDayTest.php
+++ b/tests/Germany/Saarland/AllSaintsDayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OFFICIAL);
}
/**
* Tests if all observed holidays in Saarland (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -54,7 +55,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Saarland (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -63,7 +64,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Saarland (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -72,21 +73,21 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Saarland (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
$this->assertDefinedHolidays([
'corpusChristi',
'assumptionOfMary',
- 'allSaintsDay'
+ 'allSaintsDay',
], self::REGION, $this->year, Holiday::TYPE_OTHER);
}
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1990);
}
diff --git a/tests/Germany/Saxony/GermanUnityDayTest.php b/tests/Germany/Saxony/GermanUnityDayTest.php
index 9ba811cc5..bd29c3873 100644
--- a/tests/Germany/Saxony/GermanUnityDayTest.php
+++ b/tests/Germany/Saxony/GermanUnityDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
$data[] = [$year, new DateTime("$year-10-31", new DateTimeZone(self::TIMEZONE))];
}
@@ -67,7 +69,7 @@ public function HolidayDataProvider(): array
/**
* Tests the holiday defined in this test before establishment.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayBeforeEstablishment()
{
@@ -80,7 +82,7 @@ public function testHolidayBeforeEstablishment()
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -94,7 +96,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Germany/Saxony/RepentanceAndPrayerDayTest.php b/tests/Germany/Saxony/RepentanceAndPrayerDayTest.php
index cf33667d4..b71f94c95 100644
--- a/tests/Germany/Saxony/RepentanceAndPrayerDayTest.php
+++ b/tests/Germany/Saxony/RepentanceAndPrayerDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
$holiday = new DateTime("next wednesday $year-11-15", new DateTimeZone(self::TIMEZONE)); // Default date
$this->assertHoliday(self::REGION, self::HOLIDAY, $year, $holiday);
@@ -58,7 +60,7 @@ public function testHolidayOnAfterEstablishment()
/**
* Tests the holiday defined in this test before establishment.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayBeforeEstablishment()
{
@@ -71,7 +73,7 @@ public function testHolidayBeforeEstablishment()
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -85,7 +87,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Germany/Saxony/SaxonyBaseTestCase.php b/tests/Germany/Saxony/SaxonyBaseTestCase.php
index 7bf7266bd..bbddd0658 100644
--- a/tests/Germany/Saxony/SaxonyBaseTestCase.php
+++ b/tests/Germany/Saxony/SaxonyBaseTestCase.php
@@ -1,4 +1,4 @@
-year >= 1990) {
@@ -58,7 +59,7 @@ public function testOfficialHolidays(): void
/**
* Tests if all observed holidays in Saxony (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -67,7 +68,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Saxony (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -76,7 +77,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Saxony (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -85,7 +86,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Saxony (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -95,7 +96,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1990);
}
diff --git a/tests/Germany/SaxonyAnhalt/EpiphanyTest.php b/tests/Germany/SaxonyAnhalt/EpiphanyTest.php
index 84c004665..cc37034e9 100644
--- a/tests/Germany/SaxonyAnhalt/EpiphanyTest.php
+++ b/tests/Germany/SaxonyAnhalt/EpiphanyTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
$data[] = [$year, new DateTime("$year-10-31", new DateTimeZone(self::TIMEZONE))];
}
@@ -67,7 +69,7 @@ public function HolidayDataProvider(): array
/**
* Tests the holiday defined in this test before establishment.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayBeforeEstablishment()
{
@@ -80,7 +82,7 @@ public function testHolidayBeforeEstablishment()
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -94,7 +96,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Germany/SaxonyAnhalt/SaxonyAnhaltBaseTestCase.php b/tests/Germany/SaxonyAnhalt/SaxonyAnhaltBaseTestCase.php
index ccf42d107..a0d134c34 100644
--- a/tests/Germany/SaxonyAnhalt/SaxonyAnhaltBaseTestCase.php
+++ b/tests/Germany/SaxonyAnhalt/SaxonyAnhaltBaseTestCase.php
@@ -1,4 +1,4 @@
-year >= 1990) {
@@ -54,7 +55,7 @@ public function testOfficialHolidays(): void
/**
* Tests if all observed holidays in Saxony-Anhalt (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -63,7 +64,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Saxony-Anhalt (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -72,7 +73,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Saxony-Anhalt (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -81,7 +82,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Saxony-Anhalt (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -91,7 +92,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear();
}
diff --git a/tests/Germany/SchleswigHolstein/GermanUnityDayTest.php b/tests/Germany/SchleswigHolstein/GermanUnityDayTest.php
index 656b55fb0..6770c526a 100644
--- a/tests/Germany/SchleswigHolstein/GermanUnityDayTest.php
+++ b/tests/Germany/SchleswigHolstein/GermanUnityDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
$data[] = [$year, new DateTime("$year-10-31", new DateTimeZone(self::TIMEZONE))];
}
@@ -67,20 +69,20 @@ public function HolidayDataProvider(): array
/**
* Tests the holiday defined in this test before establishment.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayBeforeEstablishment()
{
$this->assertNotHoliday(
self::REGION,
self::HOLIDAY,
- $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 2)
);
}
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -94,7 +96,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Germany/SchleswigHolstein/SchleswigHolsteinBaseTestCase.php b/tests/Germany/SchleswigHolstein/SchleswigHolsteinBaseTestCase.php
index bd7e3c751..a810d1115 100644
--- a/tests/Germany/SchleswigHolstein/SchleswigHolsteinBaseTestCase.php
+++ b/tests/Germany/SchleswigHolstein/SchleswigHolsteinBaseTestCase.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OFFICIAL);
}
/**
* Tests if all observed holidays in Schleswig-Holstein (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -54,7 +55,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Schleswig-Holstein (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -63,7 +64,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Schleswig-Holstein (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -72,7 +73,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Schleswig-Holstein (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -82,7 +83,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1990);
}
diff --git a/tests/Germany/SecondChristmasDayTest.php b/tests/Germany/SecondChristmasDayTest.php
index 552f1168e..b435ffb31 100644
--- a/tests/Germany/SecondChristmasDayTest.php
+++ b/tests/Germany/SecondChristmasDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
$data[] = [$year, new DateTime("$year-10-31", new DateTimeZone(self::TIMEZONE))];
}
@@ -67,7 +69,7 @@ public function HolidayDataProvider(): array
/**
* Tests the holiday defined in this test before establishment.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayBeforeEstablishment()
{
@@ -80,7 +82,7 @@ public function testHolidayBeforeEstablishment()
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -94,7 +96,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Germany/Thuringia/ThuringiaBaseTestCase.php b/tests/Germany/Thuringia/ThuringiaBaseTestCase.php
index a892a877d..692851a6c 100644
--- a/tests/Germany/Thuringia/ThuringiaBaseTestCase.php
+++ b/tests/Germany/Thuringia/ThuringiaBaseTestCase.php
@@ -1,4 +1,4 @@
-year >= 1990) {
@@ -54,7 +55,7 @@ public function testOfficialHolidays(): void
/**
* Tests if all observed holidays in Thuringia (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -63,7 +64,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Thuringia (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -72,7 +73,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Thuringia (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -81,7 +82,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Thuringia (Germany) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -91,7 +92,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear();
}
diff --git a/tests/Greece/AnnunciationTest.php b/tests/Greece/AnnunciationTest.php
index 0aa080820..774e7047a 100644
--- a/tests/Greece/AnnunciationTest.php
+++ b/tests/Greece/AnnunciationTest.php
@@ -1,4 +1,4 @@
-year = $this->generateRandomYear(1985);
}
diff --git a/tests/Greece/IndepencenceDayTest.php b/tests/Greece/IndepencenceDayTest.php
index 71a7dced3..c6b866fe0 100644
--- a/tests/Greece/IndepencenceDayTest.php
+++ b/tests/Greece/IndepencenceDayTest.php
@@ -1,4 +1,4 @@
-year = $this->generateRandomYear(1955);
}
diff --git a/tests/Hungary/InternationalWorkersDayTest.php b/tests/Hungary/InternationalWorkersDayTest.php
index 8b582c175..171b6e328 100644
--- a/tests/Hungary/InternationalWorkersDayTest.php
+++ b/tests/Hungary/InternationalWorkersDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear();
- $date = new DateTime("$year-12-25", new DateTimeZone(self::TIMEZONE));
+ $year = $this->generateRandomYear();
+ $date = new DateTime("$year-12-25", new DateTimeZone(self::TIMEZONE));
$data[] = [$year, $date->format('Y-m-d')];
}
@@ -71,7 +73,7 @@ public function HolidayDataProvider(): array
/**
* Tests translated name of the holiday defined in this test.
*
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -91,7 +93,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Ireland/EasterMondayTest.php b/tests/Ireland/EasterMondayTest.php
index d2703af63..a98e21955 100644
--- a/tests/Ireland/EasterMondayTest.php
+++ b/tests/Ireland/EasterMondayTest.php
@@ -1,4 +1,4 @@
-year = $this->generateRandomYear(1974);
}
diff --git a/tests/Ireland/JuneHolidayTest.php b/tests/Ireland/JuneHolidayTest.php
index 1f78b8236..48f397feb 100644
--- a/tests/Ireland/JuneHolidayTest.php
+++ b/tests/Ireland/JuneHolidayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(self::ESTABLISHMENT_YEAR);
- $date = new DateTime("$year-1-1", new DateTimeZone(self::TIMEZONE));
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $date = new DateTime("$year-1-1", new DateTimeZone(self::TIMEZONE));
$data[] = [$year, $date->format('Y-m-d')];
}
@@ -75,7 +77,7 @@ public function HolidayDataProvider(): array
/**
* Tests the holiday defined in this test before establishment.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayBeforeEstablishment()
{
@@ -89,7 +91,7 @@ public function testHolidayBeforeEstablishment()
/**
* Tests the translated name of the holiday defined in this test.
*
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -109,7 +111,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Ireland/OctoberHolidayTest.php b/tests/Ireland/OctoberHolidayTest.php
index 83954a53f..ed156e591 100644
--- a/tests/Ireland/OctoberHolidayTest.php
+++ b/tests/Ireland/OctoberHolidayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(self::ESTABLISHMENT_YEAR);
- $date = new DateTime("$year-3-17", new DateTimeZone(self::TIMEZONE));
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $date = new DateTime("$year-3-17", new DateTimeZone(self::TIMEZONE));
$data[] = [$year, $date->format('Y-m-d')];
}
@@ -75,7 +77,7 @@ public function HolidayDataProvider(): array
/**
* Tests the holiday defined in this test before establishment.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayBeforeEstablishment()
{
@@ -89,7 +91,7 @@ public function testHolidayBeforeEstablishment()
/**
* Tests the translated name of the holiday defined in this test.
*
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -109,7 +111,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Ireland/StStephensDayTest.php b/tests/Ireland/StStephensDayTest.php
index 83b4ea9dc..00f849dcc 100644
--- a/tests/Ireland/StStephensDayTest.php
+++ b/tests/Ireland/StStephensDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear();
- $date = new DateTime("$year-12-26", new DateTimeZone(self::TIMEZONE));
+ $year = $this->generateRandomYear();
+ $date = new DateTime("$year-12-26", new DateTimeZone(self::TIMEZONE));
$data[] = [$year, $date->format('Y-m-d')];
}
@@ -71,7 +73,7 @@ public function HolidayDataProvider(): array
/**
* Tests translated name of the holiday defined in this test.
*
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -91,7 +93,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Ireland/pentecostMondayTest.php b/tests/Ireland/pentecostMondayTest.php
index 6aed88641..b2fc3c88a 100644
--- a/tests/Ireland/pentecostMondayTest.php
+++ b/tests/Ireland/pentecostMondayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(),
- [self::LOCALE => 'Lunedi` dell\'Angelo']
+ [self::LOCALE => "Lunedì dell'Angelo"]
);
}
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Italy/EasterTest.php b/tests/Italy/EasterTest.php
index 780d01a4d..7aa753b69 100644
--- a/tests/Italy/EasterTest.php
+++ b/tests/Italy/EasterTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OFFICIAL);
}
/**
* Tests if all observed holidays in Italy are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -57,7 +58,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Italy are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -66,7 +67,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Italy are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -75,7 +76,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Italy are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -85,7 +86,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1949);
}
diff --git a/tests/Italy/LiberationDayTest.php b/tests/Italy/LiberationDayTest.php
index e07dd8540..fb85309bd 100644
--- a/tests/Italy/LiberationDayTest.php
+++ b/tests/Italy/LiberationDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(self::ESTABLISHMENT_YEAR),
- [self::LOCALE => 'Festa della Republica']
+ [self::LOCALE => 'Festa della Repubblica']
);
}
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Italy/stStephensDayTest.php b/tests/Italy/stStephensDayTest.php
index fbbdfcca0..25e5e70ab 100644
--- a/tests/Italy/stStephensDayTest.php
+++ b/tests/Italy/stStephensDayTest.php
@@ -1,4 +1,4 @@
-
+ */
+
+namespace Yasumi\tests\Japan;
+
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class testing the Emperors Coronation day in Japan.
+ */
+class CoronationDayTest extends JapanBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'coronationDay';
+
+ /**
+ * The year in which the holiday was first established
+ */
+ public const ESTABLISHMENT_YEAR = 2019;
+
+ /**
+ *
+ *
+ *
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testEmperorsCoronationDay()
+ {
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 2019,
+ new DateTime('2019-5-1', new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+
+ /**
+ * @throws ReflectionException
+ */
+ public function testEmperorsBirthdayBefore2019()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ );
+ }
+
+ /**
+ * @throws ReflectionException
+ */
+ public function testEmperorsBirthdayAfter2020()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR + 1)
+ );
+ }
+
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ 2019,
+ [self::LOCALE => '即位の日']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ 2019,
+ Holiday::TYPE_OFFICIAL
+ );
+ }
+}
diff --git a/tests/Japan/CultureDayTest.php b/tests/Japan/CultureDayTest.php
index 3c976a07b..814b324a9 100644
--- a/tests/Japan/CultureDayTest.php
+++ b/tests/Japan/CultureDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(self::ESTABLISHMENT_YEAR, 1987);
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime("$year-4-29", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the Emperors Birthday after 1989 to 2018. The Emperors Birthday is on December 23rd and celebrated as such since
* 1989. Prior to the death of Emperor Hirohito in 1989, this holiday was celebrated on April 29. See also "Shōwa
* Day".
- * @throws \Exception
- * @throws \ReflectionException
+ * @throws Exception
+ * @throws ReflectionException
*/
public function testEmperorsBirthdayOnAfter1989()
{
- $year = 3012;
+ $year = $this->generateRandomYear(1989, 2018);
$this->assertHoliday(
self::REGION,
self::HOLIDAY,
@@ -50,11 +70,28 @@ public function testEmperorsBirthdayOnAfter1989()
);
}
+ /**
+ * Tests the Emperors Birthday after 2020. The Emperors Birthday is on February 23rd and celebrated as such since
+ * 2020.
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testEmperorsBirthdayOnAfter2020()
+ {
+ $year = $this->generateRandomYear(2020);
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime("$year-2-23", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
/**
* Tests the Emperors Birthday after 1989 substituted next working day (when the Emperors Birthday falls on a
* Sunday)
- * @throws \Exception
- * @throws \ReflectionException
+ * @throws Exception
+ * @throws ReflectionException
*/
public function testEmperorsBirthdayOnAfter1989SubstitutedNextWorkingDay()
{
@@ -71,7 +108,7 @@ public function testEmperorsBirthdayOnAfter1989SubstitutedNextWorkingDay()
* Tests the Emperors Birthday before 1989. The Emperors Birthday is on December 23rd and celebrated as such since
* 1989. Prior to the death of Emperor Hirohito in 1989, this holiday was celebrated on April 29. See also "Shōwa
* Day"/"Greenery Day"
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testEmperorsBirthdayBefore1989()
{
@@ -82,9 +119,23 @@ public function testEmperorsBirthdayBefore1989()
);
}
+ /**
+ * Tests the Emperors Birthday at 2019.
+ *
+ * @throws ReflectionException
+ */
+ public function testEmperorsBirthdayAt2019()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 2019
+ );
+ }
+
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -98,7 +149,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Japan/EnthronementProclamationCeremonyTest.php b/tests/Japan/EnthronementProclamationCeremonyTest.php
new file mode 100644
index 000000000..4b908beb6
--- /dev/null
+++ b/tests/Japan/EnthronementProclamationCeremonyTest.php
@@ -0,0 +1,106 @@
+
+ */
+
+namespace Yasumi\tests\Japan;
+
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class testing the Emperors Coronation day in Japan.
+ */
+class EnthronementProclamationCeremonyTest extends JapanBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'enthronementProclamationCeremony';
+
+ /**
+ * The year in which the holiday was first established
+ */
+ public const IMPLEMENT_YEAR = 2019;
+
+ /**
+ *
+ *
+ *
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testEmperorsCoronationDay()
+ {
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 2019,
+ new DateTime('2019-10-22', new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+
+ /**
+ * @throws ReflectionException
+ */
+ public function testEmperorsBirthdayBefore2019()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(1000, self::IMPLEMENT_YEAR - 1)
+ );
+ }
+
+ /**
+ * @throws ReflectionException
+ */
+ public function testEmperorsBirthdayAfter2020()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::IMPLEMENT_YEAR + 1)
+ );
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ 2019,
+ [self::LOCALE => '即位礼正殿の儀']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ 2019,
+ Holiday::TYPE_OFFICIAL
+ );
+ }
+}
diff --git a/tests/Japan/GreeneryDayTest.php b/tests/Japan/GreeneryDayTest.php
index d6b2e06b9..2042efe9e 100644
--- a/tests/Japan/GreeneryDayTest.php
+++ b/tests/Japan/GreeneryDayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OFFICIAL);
}
+ /**
+ * Tests if all official holidays in Japan At 2019 are defined by the provider class
+ * @throws ReflectionException
+ */
+ public function testOfficialHolidaysAt2019(): void
+ {
+ $this->assertDefinedHolidays([
+ 'newYearsDay',
+ 'comingOfAgeDay',
+ 'nationalFoundationDay',
+ 'vernalEquinoxDay',
+ 'showaDay',
+ 'constitutionMemorialDay',
+ 'greeneryDay',
+ 'childrensDay',
+ 'marineDay',
+ 'mountainDay',
+ 'respectfortheAgedDay',
+ 'autumnalEquinoxDay',
+ 'sportsDay',
+ 'cultureDay',
+ 'laborThanksgivingDay',
+ 'coronationDay',
+ 'enthronementProclamationCeremony',
+ ], self::REGION, 2019, Holiday::TYPE_OFFICIAL);
+ }
+
/**
* Tests if all observed holidays in Japan are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -62,7 +89,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Japan are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -71,7 +98,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Japan are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -80,7 +107,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Japan are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -90,8 +117,8 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->year = $this->generateRandomYear(2016, 2150);
+ $this->year = $this->generateRandomYear(2020, 2150);
}
}
diff --git a/tests/Japan/LabourThanksgivingDayTest.php b/tests/Japan/LabourThanksgivingDayTest.php
index 428c239de..929088bfd 100644
--- a/tests/Japan/LabourThanksgivingDayTest.php
+++ b/tests/Japan/LabourThanksgivingDayTest.php
@@ -1,4 +1,4 @@
-assertHoliday(
self::REGION,
- self::HOLIDAY,
+ self::HOLIDAY . '1',
$this->year,
- new DateTime("$this->year-9-22", new DateTimeZone(self::TIMEZONE))
+ new DateTime("$this->year-4-30", new DateTimeZone(self::TIMEZONE))
+ );
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY . '2',
+ $this->year,
+ new DateTime("$this->year-5-2", new DateTimeZone(self::TIMEZONE))
);
}
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
- $this->assertTranslatedHolidayName(self::REGION, self::HOLIDAY, $this->year, [self::LOCALE => '国民の休日']);
+ $this->assertTranslatedHolidayName(self::REGION, self::HOLIDAY . '1', $this->year, [self::LOCALE => '国民の休日']);
}
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
- $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->year, Holiday::TYPE_OFFICIAL);
+ $this->assertHolidayType(self::REGION, self::HOLIDAY . '1', $this->year, Holiday::TYPE_OFFICIAL);
}
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->year = 2015;
+ $this->year = 2019;
}
}
diff --git a/tests/Japan/RespectForTheAgedDayTest.php b/tests/Japan/RespectForTheAgedDayTest.php
index ba7070e1a..d9b6f8794 100644
--- a/tests/Japan/RespectForTheAgedDayTest.php
+++ b/tests/Japan/RespectForTheAgedDayTest.php
@@ -1,4 +1,4 @@
-assertHoliday(
@@ -51,10 +53,10 @@ public function testHealthAndSportsDayIn2020()
/**
* Tests Health And Sports Day after 2000. Health And Sports Day was established since 1996 on October 10th. After
* 2000 it was changed to be the second monday of October.
- * @throws \Exception
- * @throws \ReflectionException
+ * @throws Exception
+ * @throws ReflectionException
*/
- public function testHealthAndSportsDayOnAfter2000()
+ public function testSportsDayOnAfter2000()
{
$year = $this->generateRandomYear(2001);
$this->assertHoliday(
@@ -68,10 +70,10 @@ public function testHealthAndSportsDayOnAfter2000()
/**
* Tests Health And Sports Day between 1996 and 2000. Health And Sports Day was established since 1996 on October
* 10th. After 2000 it was changed to be the second monday of October.
- * @throws \Exception
- * @throws \ReflectionException
+ * @throws Exception
+ * @throws ReflectionException
*/
- public function testHealthAndSportsDayBetween1996And2000()
+ public function testSportsDayBetween1996And2000()
{
$year = 1997;
$this->assertHoliday(
@@ -85,10 +87,10 @@ public function testHealthAndSportsDayBetween1996And2000()
/**
* Tests Health And Sports Day between 1996 and 2000 substituted next working day (when Health And Sports Day falls
* on a Sunday)
- * @throws \Exception
- * @throws \ReflectionException
+ * @throws Exception
+ * @throws ReflectionException
*/
- public function testHealthAndSportsDayBetween1996And2000SubstitutedNextWorkingDay()
+ public function testSportsDayBetween1996And2000SubstitutedNextWorkingDay()
{
$year = 1999;
$this->assertHoliday(
@@ -102,9 +104,9 @@ public function testHealthAndSportsDayBetween1996And2000SubstitutedNextWorkingDa
/**
* Tests Health And Sports Day before. Health And Sports Day was established since 1996 on October 10th. After
* 2000 it was changed to be the second monday of October.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
- public function testHealthAndSportsDayBefore1996()
+ public function testSportsDayBefore1996()
{
$this->assertNotHoliday(
self::REGION,
@@ -115,21 +117,38 @@ public function testHealthAndSportsDayBefore1996()
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * 1996-2019:Health And Sports Day
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
$this->assertTranslatedHolidayName(
self::REGION,
self::HOLIDAY,
- $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR, 2019),
[self::LOCALE => '体育の日']
);
}
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * 2020 - :Sports Day
+ * @throws ReflectionException
+ */
+ public function testTranslationFrom2020(): void
+ {
+ $year = 2020;
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear($year),
+ [self::LOCALE => 'スポーツの日']
+ );
+ }
+
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Japan/VernalEquinoxDayTest.php b/tests/Japan/VernalEquinoxDayTest.php
index 003671230..b5f24bae0 100644
--- a/tests/Japan/VernalEquinoxDayTest.php
+++ b/tests/Japan/VernalEquinoxDayTest.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -66,7 +69,7 @@ public function testTranslation(): void
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Latvia/ChristmasEveDayTest.php b/tests/Latvia/ChristmasEveDayTest.php
index d1e347aff..a2aea141b 100644
--- a/tests/Latvia/ChristmasEveDayTest.php
+++ b/tests/Latvia/ChristmasEveDayTest.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -66,7 +69,7 @@ public function testTranslation(): void
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Latvia/EasterDayTest.php b/tests/Latvia/EasterDayTest.php
index 89b8be74e..e60e1b5dd 100644
--- a/tests/Latvia/EasterDayTest.php
+++ b/tests/Latvia/EasterDayTest.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -66,7 +69,7 @@ public function testTranslation(): void
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Latvia/LatviaBaseTestCase.php b/tests/Latvia/LatviaBaseTestCase.php
index 69b959567..982709c14 100644
--- a/tests/Latvia/LatviaBaseTestCase.php
+++ b/tests/Latvia/LatviaBaseTestCase.php
@@ -1,4 +1,4 @@
-generateRandomYear();
@@ -58,7 +59,7 @@ public function testOfficialHolidays(): void
/**
* Tests if all observed holidays in Latvia are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -67,7 +68,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Latvia are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -76,7 +77,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Latvia are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -85,7 +86,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Latvia are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
diff --git a/tests/Latvia/MidsummerEveDayTest.php b/tests/Latvia/MidsummerEveDayTest.php
index 9f06d01c0..08ae9772d 100644
--- a/tests/Latvia/MidsummerEveDayTest.php
+++ b/tests/Latvia/MidsummerEveDayTest.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -60,13 +63,13 @@ public function testTranslation(): void
self::REGION,
self::HOLIDAY,
$this->generateRandomYear(),
- [self::LOCALE => 'Līgo Diena', 'en_US' => 'Midsummer Eve']
+ [self::LOCALE => 'Līgo Diena', 'en' => 'Midsummer Eve']
);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Latvia/NewYearsDayTest.php b/tests/Latvia/NewYearsDayTest.php
index 89c175080..5ed364458 100644
--- a/tests/Latvia/NewYearsDayTest.php
+++ b/tests/Latvia/NewYearsDayTest.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -66,7 +69,7 @@ public function testTranslation(): void
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Latvia/NewYearsEveDayTest.php b/tests/Latvia/NewYearsEveDayTest.php
index 09f19955c..1d8f07337 100644
--- a/tests/Latvia/NewYearsEveDayTest.php
+++ b/tests/Latvia/NewYearsEveDayTest.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -60,13 +63,13 @@ public function testTranslation(): void
self::REGION,
self::HOLIDAY,
$this->generateRandomYear(),
- [self::LOCALE => 'Vecgada vakars', 'en_US' => 'New Year\'s Eve']
+ [self::LOCALE => 'Vecgada vakars', 'en' => 'New Year\'s Eve']
);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Latvia/ProclamationOfTheRepublicOfLatviaDayTest.php b/tests/Latvia/ProclamationOfTheRepublicOfLatviaDayTest.php
index e68cb1a22..da73f2125 100644
--- a/tests/Latvia/ProclamationOfTheRepublicOfLatviaDayTest.php
+++ b/tests/Latvia/ProclamationOfTheRepublicOfLatviaDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(Latvia::PROCLAMATION_OF_INDEPENDENCE_YEAR),
[
self::LOCALE => 'Latvijas Republikas proklamēšanas diena',
- 'en_US' => 'Proclamation Day of the Republic of Latvia'
+ 'en' => 'Proclamation Day of the Republic of Latvia',
]
);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Latvia/RestorationOfIndependenceDayTest.php b/tests/Latvia/RestorationOfIndependenceDayTest.php
index f9ee55aea..13c91b7fe 100644
--- a/tests/Latvia/RestorationOfIndependenceDayTest.php
+++ b/tests/Latvia/RestorationOfIndependenceDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(Latvia::RESTORATION_OF_INDEPENDENCE_YEAR),
[
self::LOCALE => 'Latvijas Republikas Neatkarības atjaunošanas diena',
- 'en_US' => 'Restoration of Independence day'
+ 'en' => 'Restoration of Independence day',
]
);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Latvia/SecondChristmasDayTest.php b/tests/Latvia/SecondChristmasDayTest.php
index 7eb0ffce9..429dfc98e 100644
--- a/tests/Latvia/SecondChristmasDayTest.php
+++ b/tests/Latvia/SecondChristmasDayTest.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -66,7 +69,7 @@ public function testTranslation(): void
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Latvia/StJohnsDayTest.php b/tests/Latvia/StJohnsDayTest.php
index 80dfc2b33..5d00d3940 100644
--- a/tests/Latvia/StJohnsDayTest.php
+++ b/tests/Latvia/StJohnsDayTest.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -66,7 +69,7 @@ public function testTranslation(): void
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Lithuania/AllSaintsDayTest.php b/tests/Lithuania/AllSaintsDayTest.php
index 50983d4ac..271b45a81 100644
--- a/tests/Lithuania/AllSaintsDayTest.php
+++ b/tests/Lithuania/AllSaintsDayTest.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -66,7 +69,7 @@ public function testTranslation(): void
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Lithuania/AssumptionOfMaryDayTest.php b/tests/Lithuania/AssumptionOfMaryDayTest.php
index 5a358fa91..bbe083681 100644
--- a/tests/Lithuania/AssumptionOfMaryDayTest.php
+++ b/tests/Lithuania/AssumptionOfMaryDayTest.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -66,7 +69,7 @@ public function testTranslation(): void
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Lithuania/ChristmasDayTest.php b/tests/Lithuania/ChristmasDayTest.php
index 798b03be3..7f99b30f8 100644
--- a/tests/Lithuania/ChristmasDayTest.php
+++ b/tests/Lithuania/ChristmasDayTest.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -66,7 +69,7 @@ public function testTranslation(): void
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Lithuania/ChristmasEveDayTest.php b/tests/Lithuania/ChristmasEveDayTest.php
index b1e25c710..ba5cdbd98 100644
--- a/tests/Lithuania/ChristmasEveDayTest.php
+++ b/tests/Lithuania/ChristmasEveDayTest.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -66,7 +69,7 @@ public function testTranslation(): void
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Lithuania/EasterDayTest.php b/tests/Lithuania/EasterDayTest.php
index 04fea788c..609977bf3 100644
--- a/tests/Lithuania/EasterDayTest.php
+++ b/tests/Lithuania/EasterDayTest.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -66,7 +69,7 @@ public function testTranslation(): void
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Lithuania/LithuaniaBaseTestCase.php b/tests/Lithuania/LithuaniaBaseTestCase.php
index 761dbc054..b958d9919 100644
--- a/tests/Lithuania/LithuaniaBaseTestCase.php
+++ b/tests/Lithuania/LithuaniaBaseTestCase.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -66,7 +69,7 @@ public function testTranslation(): void
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Lithuania/RestorationOfIndependenceOfLithuaniaDayTest.php b/tests/Lithuania/RestorationOfIndependenceOfLithuaniaDayTest.php
index fe901ab69..4004a48b5 100644
--- a/tests/Lithuania/RestorationOfIndependenceOfLithuaniaDayTest.php
+++ b/tests/Lithuania/RestorationOfIndependenceOfLithuaniaDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(Lithuania::RESTORATION_OF_INDEPENDENCE_YEAR),
- ['en_US' => 'Day of Restoration of Independence of Lithuania']
+ ['en' => 'Day of Restoration of Independence of Lithuania']
);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Lithuania/RestorationOfTheStateOfLithuaniaDayTest.php b/tests/Lithuania/RestorationOfTheStateOfLithuaniaDayTest.php
index 576d192d7..8eea1cd02 100644
--- a/tests/Lithuania/RestorationOfTheStateOfLithuaniaDayTest.php
+++ b/tests/Lithuania/RestorationOfTheStateOfLithuaniaDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(Lithuania::RESTORATION_OF_THE_STATE_YEAR),
- ['en_US' => 'Day of Restoration of the State of Lithuania']
+ ['en' => 'Day of Restoration of the State of Lithuania']
);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Lithuania/SecondChristmasDayTest.php b/tests/Lithuania/SecondChristmasDayTest.php
index e4922fd99..9caae05bf 100644
--- a/tests/Lithuania/SecondChristmasDayTest.php
+++ b/tests/Lithuania/SecondChristmasDayTest.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -66,7 +69,7 @@ public function testTranslation(): void
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Lithuania/StJohnsDayTest.php b/tests/Lithuania/StJohnsDayTest.php
index f93c97d54..531eb3d9a 100644
--- a/tests/Lithuania/StJohnsDayTest.php
+++ b/tests/Lithuania/StJohnsDayTest.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -66,7 +69,7 @@ public function testTranslation(): void
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Lithuania/StatehoodDayTest.php b/tests/Lithuania/StatehoodDayTest.php
index 0cb69ff74..22341ed7c 100644
--- a/tests/Lithuania/StatehoodDayTest.php
+++ b/tests/Lithuania/StatehoodDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(Lithuania::STATEHOOD_YEAR),
- ['en_US' => 'Statehood Day (Lithuania)']
+ ['en' => 'Statehood Day (Lithuania)']
);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Netherlands/AscensionDayTest.php b/tests/Netherlands/AscensionDayTest.php
index d737ba2be..9f7aaed84 100644
--- a/tests/Netherlands/AscensionDayTest.php
+++ b/tests/Netherlands/AscensionDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(),
- [self::LOCALE => 'Kerstmis']
+ [self::LOCALE => 'Eerste kerstdag']
);
}
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Netherlands/CommemorationDayTest.php b/tests/Netherlands/CommemorationDayTest.php
index 9050043ce..4c66e4cb3 100644
--- a/tests/Netherlands/CommemorationDayTest.php
+++ b/tests/Netherlands/CommemorationDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(),
- [self::LOCALE => 'Tweede Paasdag']
+ [self::LOCALE => 'Tweede paasdag']
);
}
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Netherlands/EasterTest.php b/tests/Netherlands/EasterTest.php
index 32c9d1a37..6c30b083d 100644
--- a/tests/Netherlands/EasterTest.php
+++ b/tests/Netherlands/EasterTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(),
- [self::LOCALE => 'Eerste Paasdag']
+ [self::LOCALE => 'Eerste paasdag']
);
}
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Netherlands/EpiphanyTest.php b/tests/Netherlands/EpiphanyTest.php
index cfdf9f4a9..445654039 100644
--- a/tests/Netherlands/EpiphanyTest.php
+++ b/tests/Netherlands/EpiphanyTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(self::ESTABLISHMENT_YEAR),
- Holiday::TYPE_OBSERVANCE
+ Holiday::TYPE_OFFICIAL
);
}
}
diff --git a/tests/Netherlands/MothersDayTest.php b/tests/Netherlands/MothersDayTest.php
index 27c521267..280d12386 100644
--- a/tests/Netherlands/MothersDayTest.php
+++ b/tests/Netherlands/MothersDayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OFFICIAL);
}
/**
* Tests if all observed holidays in Netherlands are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -54,18 +56,17 @@ public function testObservedHolidays(): void
'goodFriday',
'ashWednesday',
'commemorationDay',
- 'liberationDay',
'halloween',
'stNicholasDay',
'carnivalDay',
'secondCarnivalDay',
- 'thirdCarnivalDay'
+ 'thirdCarnivalDay',
], self::REGION, $this->year, Holiday::TYPE_OBSERVANCE);
}
/**
* Tests if all seasonal holidays in Netherlands are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -75,7 +76,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Netherlands are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -84,7 +85,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Netherlands are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -95,14 +96,14 @@ public function testOtherHolidays(): void
'fathersDay',
'mothersDay',
'epiphany',
- 'princesDay'
+ 'princesDay',
], self::REGION, $this->year, Holiday::TYPE_OTHER);
}
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(2014);
}
diff --git a/tests/Netherlands/NewYearsDayTest.php b/tests/Netherlands/NewYearsDayTest.php
index 08a40a1dd..5b0e7921f 100644
--- a/tests/Netherlands/NewYearsDayTest.php
+++ b/tests/Netherlands/NewYearsDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(),
- [self::LOCALE => 'Eerste Pinksterdag']
+ [self::LOCALE => 'Eerste pinksterdag']
);
}
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Netherlands/QueensDayTest.php b/tests/Netherlands/QueensDayTest.php
index 99ab5a78e..848daf7f2 100644
--- a/tests/Netherlands/QueensDayTest.php
+++ b/tests/Netherlands/QueensDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(),
- [self::LOCALE => 'Tweede Pinksterdag']
+ [self::LOCALE => 'Tweede pinksterdag']
);
}
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Netherlands/princesDayTest.php b/tests/Netherlands/princesDayTest.php
index ca696b1f0..f0a5d86f6 100644
--- a/tests/Netherlands/princesDayTest.php
+++ b/tests/Netherlands/princesDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(),
- [self::LOCALE => 'Tweede Kerstdag']
+ [self::LOCALE => 'Tweede kerstdag']
);
}
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Netherlands/stMartinsDayTest.php b/tests/Netherlands/stMartinsDayTest.php
index 8d83a33e8..a368c0b30 100644
--- a/tests/Netherlands/stMartinsDayTest.php
+++ b/tests/Netherlands/stMartinsDayTest.php
@@ -1,4 +1,4 @@
-generateRandomDatesWithModifier(4, 25, function ($year, \DateTime $date) {
+ return $this->generateRandomDatesWithModifier(4, 25, function ($year, DateTime $date) {
// in 2015 some policy was introduced to make sure this holiday was celebrated during the working week.
if ($year >= 2015 && $this->isWeekend($date)) {
$date->modify('next monday');
@@ -80,7 +82,7 @@ public function HolidayDataProvider(): array
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -94,7 +96,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/NewZealand/BoxingDayTest.php b/tests/NewZealand/BoxingDayTest.php
index bc901a052..233511bed 100644
--- a/tests/NewZealand/BoxingDayTest.php
+++ b/tests/NewZealand/BoxingDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
$expected = new DateTime(
(($year < 1910) ? 'second wednesday of october' : 'fourth monday of october') . " $year",
new DateTimeZone(self::TIMEZONE)
@@ -87,7 +89,7 @@ public function HolidayDataProvider(): array
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -101,7 +103,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/NewZealand/NewYearsDayTest.php b/tests/NewZealand/NewYearsDayTest.php
index b408bff8b..6608cf688 100644
--- a/tests/NewZealand/NewYearsDayTest.php
+++ b/tests/NewZealand/NewYearsDayTest.php
@@ -1,4 +1,4 @@
-year = $this->generateRandomYear(1987);
}
diff --git a/tests/NewZealand/QueensBirthdayTest.php b/tests/NewZealand/QueensBirthdayTest.php
index 48a8bd3a5..c5ce4236d 100644
--- a/tests/NewZealand/QueensBirthdayTest.php
+++ b/tests/NewZealand/QueensBirthdayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
$expected = new DateTime("first monday of june $year", new DateTimeZone(self::TIMEZONE));
- $data[] = [$year, $expected];
+ $data[] = [$year, $expected];
}
return $data;
@@ -77,7 +79,7 @@ public function HolidayDataProvider(): array
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -91,7 +93,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/NewZealand/WaitangiDayTest.php b/tests/NewZealand/WaitangiDayTest.php
index b922fb747..d2ca5b388 100644
--- a/tests/NewZealand/WaitangiDayTest.php
+++ b/tests/NewZealand/WaitangiDayTest.php
@@ -1,4 +1,4 @@
-generateRandomDatesWithModifier(2, 06, function ($year, \DateTime $date) {
+ return $this->generateRandomDatesWithModifier(2, 06, function ($year, DateTime $date) {
// in 2015 some policy was introduced to make sure this holiday was celebrated during the working week.
if ($year >= 2015 && $this->isWeekend($date)) {
$date->modify('next monday');
diff --git a/tests/Norway/AscensionDayTest.php b/tests/Norway/AscensionDayTest.php
index 4e0278c8e..31604890e 100644
--- a/tests/Norway/AscensionDayTest.php
+++ b/tests/Norway/AscensionDayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OFFICIAL);
}
/**
* Tests if all observed holidays in Norway are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -57,7 +58,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Norway are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -66,7 +67,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Norway are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -75,7 +76,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Norway are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -85,7 +86,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1836);
}
diff --git a/tests/Norway/PentecostMondayTest.php b/tests/Norway/PentecostMondayTest.php
index c9f3c8ac9..3a3046f1d 100644
--- a/tests/Norway/PentecostMondayTest.php
+++ b/tests/Norway/PentecostMondayTest.php
@@ -1,4 +1,4 @@
-assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OTHER);
+ $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL);
}
}
diff --git a/tests/Poland/EasterMondayTest.php b/tests/Poland/EasterMondayTest.php
index 7f87744df..7e6cbeb4a 100644
--- a/tests/Poland/EasterMondayTest.php
+++ b/tests/Poland/EasterMondayTest.php
@@ -1,4 +1,4 @@
-assertDefinedHolidays(['corpusChristi'], self::REGION, $this->year, Holiday::TYPE_OTHER);
+ $this->assertDefinedHolidays([], self::REGION, $this->year, Holiday::TYPE_OTHER);
}
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1918);
}
diff --git a/tests/Poland/SecondChristmasDayTest.php b/tests/Poland/SecondChristmasDayTest.php
index d28404870..bbd2e79a7 100644
--- a/tests/Poland/SecondChristmasDayTest.php
+++ b/tests/Poland/SecondChristmasDayTest.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
- $year = 2013;
+ $year = 2012;
$expected = new DateTime("$year-11-01", new DateTimeZone(self::TIMEZONE));
$this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
- * Test that the holiday did not happen in 2014 and 2015.
- * @throws \ReflectionException
+ * Test that the holiday did not happen in 2013-2015.
+ * @throws ReflectionException
*/
public function testNotHoliday()
{
- $year = $this->generateRandomYear(2014, 2015);
+ $year = $this->generateRandomYear(2013, 2015);
$this->assertNotHoliday(self::REGION, self::HOLIDAY, $year);
}
/**
* Tests translated name of Corpus Christi.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -83,7 +85,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
*
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Portugal/AssumptionOfMaryTest.php b/tests/Portugal/AssumptionOfMaryTest.php
index 63e338766..d8d9c0f65 100644
--- a/tests/Portugal/AssumptionOfMaryTest.php
+++ b/tests/Portugal/AssumptionOfMaryTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
$expected = new DateTime("$year-04-25", new DateTimeZone(self::TIMEZONE));
$this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* Tests that the holiday is not a holiday before the year of establishment
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testNotHolidayBeforeEstablishment()
{
@@ -56,7 +58,7 @@ public function testNotHolidayBeforeEstablishment()
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -66,7 +68,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Portugal/ChristmasTest.php b/tests/Portugal/ChristmasTest.php
index 50c91ca63..30e08f62d 100644
--- a/tests/Portugal/ChristmasTest.php
+++ b/tests/Portugal/ChristmasTest.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
- * Test that the holiday did not happen in 2014 and 2015.
- * @throws \ReflectionException
+ * Test that the holiday did not happen in 2013-2015.
+ * @throws ReflectionException
*/
public function testNotHoliday()
{
- $year = $this->generateRandomYear(2014, 2015);
+ $year = $this->generateRandomYear(2013, 2015);
$this->assertNotHoliday(self::REGION, self::HOLIDAY, $year);
}
/**
* Tests translated name of Corpus Christi.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -72,7 +74,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
*
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Portugal/EasterTest.php b/tests/Portugal/EasterTest.php
index d99945082..371cd633b 100644
--- a/tests/Portugal/EasterTest.php
+++ b/tests/Portugal/EasterTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(1000, self::ESTABLISHMENT_YEAR_BEFORE);
+ $year = $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR_BEFORE);
$expected = new DateTime("$year-06-10", new DateTimeZone(self::TIMEZONE));
$this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* Tests the holiday defined in this test after it was restored
+ * @throws ReflectionException
+ * @throws Exception
* @see Portugal::calculatePortugalDay()
- * @throws \ReflectionException
- * @throws \Exception
*/
public function testHolidayAfterRestoration()
{
- $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR_AFTER);
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR_AFTER);
$expected = new DateTime("$year-06-10", new DateTimeZone(self::TIMEZONE));
$this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* Tests that the holiday defined in this test does not exist during the period that it was abolished
+ * @throws ReflectionException
* @see Portugal::calculatePortugalDay()
*
- * @throws \ReflectionException
*/
public function testNotHolidayDuringAbolishment()
{
@@ -82,7 +84,7 @@ public function testNotHolidayDuringAbolishment()
/**
* Tests the translated name of the holiday defined in this test.
*
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -96,7 +98,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
*
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Portugal/PortugalTest.php b/tests/Portugal/PortugalTest.php
index 6d3192387..e247be2aa 100644
--- a/tests/Portugal/PortugalTest.php
+++ b/tests/Portugal/PortugalTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OFFICIAL);
}
/**
* Tests if all observed holidays in Portugal are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -57,7 +58,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Portugal are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -66,7 +67,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Portugal are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -75,13 +76,13 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in PortugalPortugal are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
$holidays = [];
- if ($this->year <= 2013 || $this->year >= 2016) {
+ if ($this->year <= 2012 || $this->year >= 2016) {
$holidays[] = 'corpusChristi';
}
@@ -91,7 +92,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1974);
}
diff --git a/tests/Portugal/PortugueseRepublicDayTest.php b/tests/Portugal/PortugueseRepublicDayTest.php
index fbde1d4e5..4eb574081 100644
--- a/tests/Portugal/PortugueseRepublicDayTest.php
+++ b/tests/Portugal/PortugueseRepublicDayTest.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
+
+ $year = $this->generateRandomYear(self::HOLIDAY_YEAR_RESTORED);
+
+ $expected = new DateTime("$year-10-05", new DateTimeZone(self::TIMEZONE));
+ $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
+ }
+
+ /**
+ * Test that the holiday did not happen in 2013-2015.
+ * @throws ReflectionException
+ */
+ public function testNotHolidayDuringAbolishment()
+ {
+ $year = $this->generateRandomYear(2013, 2015);
+ $this->assertNotHoliday(self::REGION, self::HOLIDAY, $year);
+ }
+
/**
* Tests the holiday defined in this test on or after establishment.
- * @throws \ReflectionException
- * @throws \Exception
- * @throws \ReflectionException
- * @throws \Exception
+ * @throws ReflectionException
+ * @throws Exception
+ * @throws ReflectionException
+ * @throws Exception
*/
public function testHolidayOnAfterEstablishment()
{
@@ -46,7 +83,7 @@ public function testHolidayOnAfterEstablishment()
$expected = new DateTime("$year-10-05", new DateTimeZone(self::TIMEZONE));
$this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
- $year = self::ESTABLISHMENT_YEAR;
+ $year = self::ESTABLISHMENT_YEAR;
$expected = new DateTime("$year-10-05", new DateTimeZone(self::TIMEZONE));
$this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
@@ -54,7 +91,7 @@ public function testHolidayOnAfterEstablishment()
/**
* Tests the holiday defined in this test before establishment.
*
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayBeforeEstablishment()
{
@@ -67,7 +104,7 @@ public function testHolidayBeforeEstablishment()
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -81,7 +118,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Portugal/RestorationOfIndependenceTest.php b/tests/Portugal/RestorationOfIndependenceTest.php
index 3ccad8eae..18fb4cd89 100644
--- a/tests/Portugal/RestorationOfIndependenceTest.php
+++ b/tests/Portugal/RestorationOfIndependenceTest.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
- $year = 1850;
+ $year = self::ESTABLISHMENT_YEAR;
$expected = new DateTime("$year-12-01", new DateTimeZone(self::TIMEZONE));
$this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* Test that the holiday if in effect in 2016 and later dates.
- * @throws \ReflectionException
- * @throws \Exception
- * @throws \ReflectionException
- * @throws \Exception
+ * @throws ReflectionException
+ * @throws Exception
+ * @throws ReflectionException
+ * @throws Exception
*/
public function testHolidayOnAfterRestoration()
{
@@ -82,19 +84,19 @@ public function testHolidayOnAfterRestoration()
}
/**
- * Test that the holiday did not happen in 2014 and 2015.
- * @throws \ReflectionException
+ * Test that the holiday did not happen in 2013-2015.
+ * @throws ReflectionException
*/
public function testNotHolidayDuringAbolishment()
{
- $year = $this->generateRandomYear(2014, 2015);
+ $year = $this->generateRandomYear(2013, 2015);
$this->assertNotHoliday(self::REGION, self::HOLIDAY, $year);
}
/**
* Tests the holiday defined in this test before establishment.
*
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayBeforeEstablishment()
{
@@ -108,7 +110,7 @@ public function testHolidayBeforeEstablishment()
/**
* Tests the translated name of the holiday defined in this test.
*
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -132,7 +134,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
*
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Romania/AssumptionOfMaryTest.php b/tests/Romania/AssumptionOfMaryTest.php
index 51e38dad5..b7776b76c 100644
--- a/tests/Romania/AssumptionOfMaryTest.php
+++ b/tests/Romania/AssumptionOfMaryTest.php
@@ -1,4 +1,4 @@
-year >= 2017) {
@@ -57,7 +58,7 @@ public function testOfficialHolidays(): void
/**
* Tests if all observed holidays in Romania are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -76,7 +77,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Romania are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -85,7 +86,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Romania are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -94,7 +95,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Romania are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -104,7 +105,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(2015, 2025);
}
diff --git a/tests/Romania/SecondChristmasDayTest.php b/tests/Romania/SecondChristmasDayTest.php
index c7dacb67f..a60fce4e5 100644
--- a/tests/Romania/SecondChristmasDayTest.php
+++ b/tests/Romania/SecondChristmasDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(Russia::DEFENCE_OF_THE_FATHERLAND_START_YEAR),
- ['en_US' => 'Defence of the Fatherland Day']
+ ['en' => 'Defence of the Fatherland Day']
);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Russia/InternationalWomensDayTest.php b/tests/Russia/InternationalWomensDayTest.php
index bd1a2983e..d5b896275 100644
--- a/tests/Russia/InternationalWomensDayTest.php
+++ b/tests/Russia/InternationalWomensDayTest.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -66,7 +69,7 @@ public function testTranslation(): void
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Russia/NewYearHolidaysDay2Test.php b/tests/Russia/NewYearHolidaysDay2Test.php
index 71a9580cf..e3ab7d697 100644
--- a/tests/Russia/NewYearHolidaysDay2Test.php
+++ b/tests/Russia/NewYearHolidaysDay2Test.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -66,7 +69,7 @@ public function testTranslation(): void
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Russia/NewYearHolidaysDay3Test.php b/tests/Russia/NewYearHolidaysDay3Test.php
index 7e0c11b35..52c19e6eb 100644
--- a/tests/Russia/NewYearHolidaysDay3Test.php
+++ b/tests/Russia/NewYearHolidaysDay3Test.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -66,7 +69,7 @@ public function testTranslation(): void
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Russia/NewYearHolidaysDay4Test.php b/tests/Russia/NewYearHolidaysDay4Test.php
index f47599133..98e993b25 100644
--- a/tests/Russia/NewYearHolidaysDay4Test.php
+++ b/tests/Russia/NewYearHolidaysDay4Test.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -65,7 +68,7 @@ public function testTranslation(): void
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Russia/NewYearHolidaysDay5Test.php b/tests/Russia/NewYearHolidaysDay5Test.php
index 1e40951e0..f123bc6a5 100644
--- a/tests/Russia/NewYearHolidaysDay5Test.php
+++ b/tests/Russia/NewYearHolidaysDay5Test.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -66,7 +69,7 @@ public function testTranslation(): void
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Russia/NewYearHolidaysDay6Test.php b/tests/Russia/NewYearHolidaysDay6Test.php
index c7f9b50e2..f7ef80f91 100644
--- a/tests/Russia/NewYearHolidaysDay6Test.php
+++ b/tests/Russia/NewYearHolidaysDay6Test.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -66,7 +69,7 @@ public function testTranslation(): void
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Russia/NewYearHolidaysDay8Test.php b/tests/Russia/NewYearHolidaysDay8Test.php
index 9c87f5ba7..7e0b51171 100644
--- a/tests/Russia/NewYearHolidaysDay8Test.php
+++ b/tests/Russia/NewYearHolidaysDay8Test.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -65,7 +68,7 @@ public function testTranslation(): void
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Russia/NewYearsDayTest.php b/tests/Russia/NewYearsDayTest.php
index 1128da96b..2a639b0b5 100644
--- a/tests/Russia/NewYearsDayTest.php
+++ b/tests/Russia/NewYearsDayTest.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -66,7 +69,7 @@ public function testTranslation(): void
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Russia/OrthodoxChristmasDayTest.php b/tests/Russia/OrthodoxChristmasDayTest.php
index 9b31c8fdd..90aa966dc 100644
--- a/tests/Russia/OrthodoxChristmasDayTest.php
+++ b/tests/Russia/OrthodoxChristmasDayTest.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -66,7 +69,7 @@ public function testTranslation(): void
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Russia/RussiaBaseTestCase.php b/tests/Russia/RussiaBaseTestCase.php
index 0b7d0c954..4b3769c47 100644
--- a/tests/Russia/RussiaBaseTestCase.php
+++ b/tests/Russia/RussiaBaseTestCase.php
@@ -1,4 +1,4 @@
-generateRandomYear(Russia::RUSSIA_DAY_START_YEAR),
- ['en_US' => 'Russia Day']
+ ['en' => 'Russia Day']
);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Russia/RussiaTest.php b/tests/Russia/RussiaTest.php
index 3ad00eed8..925536d93 100644
--- a/tests/Russia/RussiaTest.php
+++ b/tests/Russia/RussiaTest.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -66,7 +69,7 @@ public function testTranslation(): void
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Russia/UnityDayTest.php b/tests/Russia/UnityDayTest.php
index fddd335bc..fa07dfd90 100644
--- a/tests/Russia/UnityDayTest.php
+++ b/tests/Russia/UnityDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(Russia::UNITY_DAY_START_YEAR),
- ['en_US' => 'Unity Day']
+ ['en' => 'Unity Day']
);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Russia/VictoryDayTest.php b/tests/Russia/VictoryDayTest.php
index e2cbd3173..fa43a4fd1 100644
--- a/tests/Russia/VictoryDayTest.php
+++ b/tests/Russia/VictoryDayTest.php
@@ -1,4 +1,4 @@
-assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -66,7 +69,7 @@ public function testTranslation(): void
/**
* {@inheritdoc}
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Slovakia/AllSaintsDayTest.php b/tests/Slovakia/AllSaintsDayTest.php
index 2431e02a4..8e06550ec 100644
--- a/tests/Slovakia/AllSaintsDayTest.php
+++ b/tests/Slovakia/AllSaintsDayTest.php
@@ -1,4 +1,4 @@
-
+ * @author Jan Langer
*/
-class NewYearsDayTest extends SlovakiaBaseTestCase implements YasumiTestCaseInterface
+class SlovakIndependeceDayTest extends SlovakiaBaseTestCase implements YasumiTestCaseInterface
{
/**
* The name of the holiday to be tested
*/
- public const HOLIDAY = 'newYearsDay';
+ public const HOLIDAY = 'slovakIndependenceDay';
/**
@@ -38,10 +41,10 @@ class NewYearsDayTest extends SlovakiaBaseTestCase implements YasumiTestCaseInte
*
* @dataProvider HolidayDataProvider
*
- * @param int $year the year for which the holiday defined in this test needs to be tested
+ * @param int $year the year for which the holiday defined in this test needs to be tested
* @param DateTime $expected the expected date
*
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHoliday($year, $expected)
{
@@ -53,7 +56,7 @@ public function testHoliday($year, $expected)
* Returns a list of random test dates used for assertion of the holiday defined in this test
*
* @return array list of test dates for the holiday defined in this test
- * @throws \Exception
+ * @throws Exception
*/
public function HolidayDataProvider(): array
{
@@ -63,7 +66,7 @@ public function HolidayDataProvider(): array
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -78,7 +81,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Slovakia/SlovakNationalUprisingDayTest.php b/tests/Slovakia/SlovakNationalUprisingDayTest.php
index 5b21fa1b1..858ac5fd6 100644
--- a/tests/Slovakia/SlovakNationalUprisingDayTest.php
+++ b/tests/Slovakia/SlovakNationalUprisingDayTest.php
@@ -1,4 +1,4 @@
-assertDefinedHolidays([
- 'newYearsDay',
+ 'slovakIndependenceDay',
'slovakConstitutionDay',
'slovakNationalUprisingDay',
'saintsCyrilAndMethodiusDay',
@@ -49,7 +50,7 @@ public function testOfficialHolidays(): void
/**
* Tests if all bank holidays in Slovakia are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -70,7 +71,7 @@ public function testBankHolidays(): void
/**
* Tests if all observed holidays in Slovakia are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -80,7 +81,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Slovakia are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -90,7 +91,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all other holidays in Slovakia are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -101,7 +102,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
// NOTE: 1993 is the year Slovakia was founded as an independent state
$this->year = $this->generateRandomYear(1993, 2100);
diff --git a/tests/Slovakia/StruggleForFreedomAndDemocracyDayTest.php b/tests/Slovakia/StruggleForFreedomAndDemocracyDayTest.php
index 1bf3aa96b..54f55a56f 100644
--- a/tests/Slovakia/StruggleForFreedomAndDemocracyDayTest.php
+++ b/tests/Slovakia/StruggleForFreedomAndDemocracyDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(self::ESTABLISHMENT_YEAR);
- $date = new DateTime("$year-12-25", new DateTimeZone(self::TIMEZONE));
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $date = new DateTime("$year-12-25", new DateTimeZone(self::TIMEZONE));
$data[] = [$year, $date->format('Y-m-d')];
}
@@ -81,7 +83,7 @@ public function HolidayDataProvider(): array
/**
* Tests the holiday defined in this test before establishment.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayBeforeEstablishment()
{
@@ -94,7 +96,7 @@ public function testHolidayBeforeEstablishment()
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -108,7 +110,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/SouthAfrica/FamilyDayTest.php b/tests/SouthAfrica/FamilyDayTest.php
index 8ef2c2e19..10d3408cf 100644
--- a/tests/SouthAfrica/FamilyDayTest.php
+++ b/tests/SouthAfrica/FamilyDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(self::ESTABLISHMENT_YEAR);
- $date = new DateTime("$year-4-27", new DateTimeZone(self::TIMEZONE));
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $date = new DateTime("$year-4-27", new DateTimeZone(self::TIMEZONE));
$data[] = [$year, $date->format('Y-m-d')];
}
@@ -81,7 +83,7 @@ public function HolidayDataProvider(): array
/**
* Tests the holiday defined in this test before establishment.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayBeforeEstablishment()
{
@@ -94,7 +96,7 @@ public function testHolidayBeforeEstablishment()
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -108,7 +110,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/SouthAfrica/GoodFridayTest.php b/tests/SouthAfrica/GoodFridayTest.php
index 7b7e45be9..47f462576 100644
--- a/tests/SouthAfrica/GoodFridayTest.php
+++ b/tests/SouthAfrica/GoodFridayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(self::ESTABLISHMENT_YEAR);
- $date = new DateTime("$year-9-24", new DateTimeZone(self::TIMEZONE));
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $date = new DateTime("$year-9-24", new DateTimeZone(self::TIMEZONE));
$data[] = [$year, $date->format('Y-m-d')];
}
@@ -81,7 +83,7 @@ public function HolidayDataProvider(): array
/**
* Tests the holiday defined in this test before establishment.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayBeforeEstablishment()
{
@@ -94,7 +96,7 @@ public function testHolidayBeforeEstablishment()
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -108,7 +110,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/SouthAfrica/HumanRightsDayTest.php b/tests/SouthAfrica/HumanRightsDayTest.php
index cc9fb0e5b..f2320d4b5 100644
--- a/tests/SouthAfrica/HumanRightsDayTest.php
+++ b/tests/SouthAfrica/HumanRightsDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(self::ESTABLISHMENT_YEAR);
- $date = new DateTime("$year-3-21", new DateTimeZone(self::TIMEZONE));
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $date = new DateTime("$year-3-21", new DateTimeZone(self::TIMEZONE));
$data[] = [$year, $date->format('Y-m-d')];
}
@@ -81,7 +83,7 @@ public function HolidayDataProvider(): array
/**
* Tests the holiday defined in this test before establishment.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayBeforeEstablishment()
{
@@ -94,7 +96,7 @@ public function testHolidayBeforeEstablishment()
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -108,7 +110,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/SouthAfrica/MunicipalElections2016DayTest.php b/tests/SouthAfrica/MunicipalElections2016DayTest.php
index 8276e9d3a..d20c3181a 100644
--- a/tests/SouthAfrica/MunicipalElections2016DayTest.php
+++ b/tests/SouthAfrica/MunicipalElections2016DayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(self::ESTABLISHMENT_YEAR);
- $date = new DateTime("$year-8-9", new DateTimeZone(self::TIMEZONE));
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $date = new DateTime("$year-8-9", new DateTimeZone(self::TIMEZONE));
$data[] = [$year, $date->format('Y-m-d')];
}
@@ -81,7 +83,7 @@ public function HolidayDataProvider(): array
/**
* Tests the holiday defined in this test before establishment.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayBeforeEstablishment()
{
@@ -94,7 +96,7 @@ public function testHolidayBeforeEstablishment()
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -108,7 +110,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/SouthAfrica/NewYearsDayTest.php b/tests/SouthAfrica/NewYearsDayTest.php
index 89877de56..533368247 100644
--- a/tests/SouthAfrica/NewYearsDayTest.php
+++ b/tests/SouthAfrica/NewYearsDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(self::ESTABLISHMENT_YEAR);
- $date = new DateTime("$year-1-1", new DateTimeZone(self::TIMEZONE));
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $date = new DateTime("$year-1-1", new DateTimeZone(self::TIMEZONE));
$data[] = [$year, $date->format('Y-m-d')];
}
@@ -81,7 +83,7 @@ public function HolidayDataProvider(): array
/**
* Tests the holiday defined in this test before establishment.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayBeforeEstablishment()
{
@@ -94,7 +96,7 @@ public function testHolidayBeforeEstablishment()
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -108,7 +110,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/SouthAfrica/ReconciliationDayTest.php b/tests/SouthAfrica/ReconciliationDayTest.php
index d7cf225e5..d3c24c855 100644
--- a/tests/SouthAfrica/ReconciliationDayTest.php
+++ b/tests/SouthAfrica/ReconciliationDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(self::ESTABLISHMENT_YEAR);
- $date = new DateTime("$year-12-16", new DateTimeZone(self::TIMEZONE));
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $date = new DateTime("$year-12-16", new DateTimeZone(self::TIMEZONE));
$data[] = [$year, $date->format('Y-m-d')];
}
@@ -81,7 +83,7 @@ public function HolidayDataProvider(): array
/**
* Tests the holiday defined in this test before establishment.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayBeforeEstablishment()
{
@@ -94,7 +96,7 @@ public function testHolidayBeforeEstablishment()
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -108,7 +110,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/SouthAfrica/SecondChristmasDayTest.php b/tests/SouthAfrica/SecondChristmasDayTest.php
index 5c73614bb..ab6815767 100644
--- a/tests/SouthAfrica/SecondChristmasDayTest.php
+++ b/tests/SouthAfrica/SecondChristmasDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(self::ESTABLISHMENT_YEAR);
- $date = new DateTime("$year-12-26", new DateTimeZone(self::TIMEZONE));
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $date = new DateTime("$year-12-26", new DateTimeZone(self::TIMEZONE));
$data[] = [$year, $date->format('Y-m-d')];
}
@@ -81,7 +83,7 @@ public function HolidayDataProvider(): array
/**
* Tests the holiday defined in this test before establishment.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayBeforeEstablishment()
{
@@ -94,7 +96,7 @@ public function testHolidayBeforeEstablishment()
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -108,7 +110,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/SouthAfrica/SouthAfricaBaseTestCase.php b/tests/SouthAfrica/SouthAfricaBaseTestCase.php
index f7a322161..9000a6b9b 100644
--- a/tests/SouthAfrica/SouthAfricaBaseTestCase.php
+++ b/tests/SouthAfrica/SouthAfricaBaseTestCase.php
@@ -1,4 +1,4 @@
-year === 2016) {
+ if (2016 === $this->year) {
$officialHolidays[] = '2016MunicipalElectionsDay';
$officialHolidays[] = 'substituteDayOfGoodwill';
}
@@ -59,7 +60,7 @@ public function testOfficialHolidays(): void
/**
* Tests if all bank holidays in South Africa are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -68,7 +69,7 @@ public function testBankHolidays(): void
/**
* Tests if all observed holidays in South Africa are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -77,7 +78,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in South Africa are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -86,7 +87,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all other holidays in South Africa are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -96,7 +97,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1994);
}
diff --git a/tests/SouthAfrica/SubstituteDayOfGoodwillTest.php b/tests/SouthAfrica/SubstituteDayOfGoodwillTest.php
index 4aa10f7e2..40dadeb46 100644
--- a/tests/SouthAfrica/SubstituteDayOfGoodwillTest.php
+++ b/tests/SouthAfrica/SubstituteDayOfGoodwillTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(self::ESTABLISHMENT_YEAR);
- $date = new DateTime("$year-5-1", new DateTimeZone(self::TIMEZONE));
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $date = new DateTime("$year-5-1", new DateTimeZone(self::TIMEZONE));
$data[] = [$year, $date->format('Y-m-d')];
}
@@ -81,7 +83,7 @@ public function HolidayDataProvider(): array
/**
* Tests the holiday defined in this test before establishment.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayBeforeEstablishment()
{
@@ -94,7 +96,7 @@ public function testHolidayBeforeEstablishment()
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -108,7 +110,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/SouthAfrica/YouthDayTest.php b/tests/SouthAfrica/YouthDayTest.php
index d586f1d97..42ac762e7 100644
--- a/tests/SouthAfrica/YouthDayTest.php
+++ b/tests/SouthAfrica/YouthDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(self::ESTABLISHMENT_YEAR);
- $date = new DateTime("$year-6-16", new DateTimeZone(self::TIMEZONE));
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $date = new DateTime("$year-6-16", new DateTimeZone(self::TIMEZONE));
$data[] = [$year, $date->format('Y-m-d')];
}
@@ -81,7 +83,7 @@ public function HolidayDataProvider(): array
/**
* Tests the holiday defined in this test before establishment.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayBeforeEstablishment()
{
@@ -94,7 +96,7 @@ public function testHolidayBeforeEstablishment()
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -108,7 +110,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/SouthKorea/ArborDayTest.php b/tests/SouthKorea/ArborDayTest.php
new file mode 100644
index 000000000..ccce9260c
--- /dev/null
+++ b/tests/SouthKorea/ArborDayTest.php
@@ -0,0 +1,136 @@
+
+ */
+
+namespace Yasumi\tests\SouthKorea;
+
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing day after Arbor Day in South Korea.
+ */
+class ArborDayTest extends SouthKoreaBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ private const HOLIDAY = 'arborDay';
+
+ /**
+ * The year in which the holiday was first established
+ */
+ private const ESTABLISHMENT_YEAR = 1949;
+
+ /**
+ * The year in which the holiday was removed
+ */
+ public const REMOVED_YEAR = 2005;
+
+ /**
+ * The year in which the holiday was not celebrated
+ */
+ public const YEAR_NOT_CELEBRATED = 1960;
+
+ /**
+ * Tests the holiday defined in this test.
+ *
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testHoliday()
+ {
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR, self::REMOVED_YEAR);
+ if (self::YEAR_NOT_CELEBRATED === $year) {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year
+ );
+ } else {
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime("$year-4-5", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+ }
+
+ /**
+ * Tests the holiday defined in this test after removal.
+ *
+ * @throws ReflectionException
+ */
+ public function testHolidayAfterRemoval()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::REMOVED_YEAR + 1)
+ );
+ }
+
+ /**
+ * Tests the holiday defined in this test before establishment.
+ *
+ * @throws ReflectionException
+ */
+ public function testHolidayBeforeEstablishment()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ );
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ *
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR, self::REMOVED_YEAR);
+ if (self::YEAR_NOT_CELEBRATED !== $year) {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ [self::LOCALE => '식목일']
+ );
+ }
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ *
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR, self::REMOVED_YEAR);
+ if (self::YEAR_NOT_CELEBRATED !== $year) {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ Holiday::TYPE_OFFICIAL
+ );
+ }
+ }
+}
diff --git a/tests/SouthKorea/ArmedForcesDayTest.php b/tests/SouthKorea/ArmedForcesDayTest.php
new file mode 100644
index 000000000..8e6f48ce7
--- /dev/null
+++ b/tests/SouthKorea/ArmedForcesDayTest.php
@@ -0,0 +1,112 @@
+
+ */
+
+namespace Yasumi\tests\SouthKorea;
+
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing day after Armed Forces Day in South Korea.
+ */
+class ArmedForcesDayTest extends SouthKoreaBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'armedForcesDay';
+
+ /**
+ * The year in which the holiday was first established
+ */
+ public const ESTABLISHMENT_YEAR = 1956;
+
+ /**
+ * The year in which the holiday was removed
+ */
+ public const REMOVED_YEAR = 1990;
+
+ /**
+ * Tests the holiday defined in this test.
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testHoliday()
+ {
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR, self::REMOVED_YEAR);
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime("$year-10-1", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday defined in this test after removal.
+ * @throws ReflectionException
+ */
+ public function testHolidayAfterRemoval()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::REMOVED_YEAR + 1)
+ );
+ }
+
+ /**
+ * Tests the holiday defined in this test before establishment.
+ * @throws ReflectionException
+ */
+ public function testHolidayBeforeEstablishment()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ );
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR, self::REMOVED_YEAR),
+ [self::LOCALE => '국군의 날']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR, self::REMOVED_YEAR),
+ Holiday::TYPE_OFFICIAL
+ );
+ }
+}
diff --git a/tests/SouthKorea/BuddhasBirthdayTest.php b/tests/SouthKorea/BuddhasBirthdayTest.php
new file mode 100644
index 000000000..67d84551b
--- /dev/null
+++ b/tests/SouthKorea/BuddhasBirthdayTest.php
@@ -0,0 +1,103 @@
+
+ */
+
+namespace Yasumi\tests\SouthKorea;
+
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\Provider\SouthKorea;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing Buddha's Birthday in South Korea.
+ */
+class BuddhasBirthdayTest extends SouthKoreaBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'buddhasBirthday';
+
+ /**
+ * The year in which the holiday was first established
+ */
+ public const ESTABLISHMENT_YEAR = 1975;
+
+ /**
+ * Tests the holiday defined in this test.
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testHoliday()
+ {
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR, 2050);
+ if (isset(SouthKorea::LUNAR_HOLIDAY[self::HOLIDAY][$year])) {
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime(SouthKorea::LUNAR_HOLIDAY[self::HOLIDAY][$year], new DateTimeZone(self::TIMEZONE))
+ );
+ }
+ }
+
+ /**
+ * Tests the holiday defined in this test before establishment.
+ * @throws ReflectionException
+ */
+ public function testHolidayBeforeEstablishment()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ );
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR, 2050);
+ if (isset(SouthKorea::LUNAR_HOLIDAY[self::HOLIDAY][$year])) {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ [self::LOCALE => '부처님오신날']
+ );
+ }
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR, 2050);
+ if (isset(SouthKorea::LUNAR_HOLIDAY[self::HOLIDAY][$year])) {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ Holiday::TYPE_OFFICIAL
+ );
+ }
+ }
+}
diff --git a/tests/SouthKorea/ChildrensDayTest.php b/tests/SouthKorea/ChildrensDayTest.php
new file mode 100644
index 000000000..e49e1877e
--- /dev/null
+++ b/tests/SouthKorea/ChildrensDayTest.php
@@ -0,0 +1,143 @@
+
+ */
+
+namespace Yasumi\tests\SouthKorea;
+
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing Children's Day in South Korea.
+ */
+class ChildrensDayTest extends SouthKoreaBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'childrensDay';
+
+ /**
+ * The year in which the holiday was first established
+ */
+ public const ESTABLISHMENT_YEAR = 1970;
+
+ /**
+ * Tests the holiday defined in this test.
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testMainHoliday()
+ {
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime("$year-5-5", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the substitute holiday defined in this test (conflict with Buddha's Birthday).
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testSubstituteHolidayByBuddhasBirthday()
+ {
+ foreach ([2025, 2044] as $year) {
+ $this->assertHoliday(
+ self::REGION,
+ 'substituteHoliday:childrensDay',
+ $year,
+ new DateTime("$year-5-6", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+ }
+
+ /**
+ * Tests the substitute holiday defined in this test (conflict with Saturday).
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testSubstituteHolidayBySaturday()
+ {
+ $year = 2029;
+ $this->assertHoliday(
+ self::REGION,
+ 'substituteHoliday:childrensDay',
+ $year,
+ new DateTime("$year-5-7", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the substitute holiday defined in this test (conflict with Sunday).
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testSubstituteHolidayBySunday()
+ {
+ $year = 2019;
+ $this->assertHoliday(
+ self::REGION,
+ 'substituteHoliday:childrensDay',
+ $year,
+ new DateTime("$year-5-6", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday defined in this test before establishment.
+ * @throws ReflectionException
+ */
+ public function testHolidayBeforeEstablishment()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ );
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ [self::LOCALE => '어린이날']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ Holiday::TYPE_OFFICIAL
+ );
+ }
+}
diff --git a/tests/SouthKorea/ChristmasDayTest.php b/tests/SouthKorea/ChristmasDayTest.php
new file mode 100644
index 000000000..8e596fb3e
--- /dev/null
+++ b/tests/SouthKorea/ChristmasDayTest.php
@@ -0,0 +1,94 @@
+
+ */
+
+namespace Yasumi\tests\SouthKorea;
+
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing Christmas Day in South Korea.
+ */
+class ChristmasDayTest extends SouthKoreaBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'christmasDay';
+
+ /**
+ * The year in which the holiday was first established
+ */
+ public const ESTABLISHMENT_YEAR = 1949;
+
+ /**
+ * Tests the holiday defined in this test.
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testHoliday()
+ {
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime("$year-12-25", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday defined in this test before establishment.
+ * @throws ReflectionException
+ */
+ public function testHolidayBeforeEstablishment()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ );
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ [self::LOCALE => '기독탄신일']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ Holiday::TYPE_OFFICIAL
+ );
+ }
+}
diff --git a/tests/SouthKorea/ChuseokTest.php b/tests/SouthKorea/ChuseokTest.php
new file mode 100644
index 000000000..1bbb1b744
--- /dev/null
+++ b/tests/SouthKorea/ChuseokTest.php
@@ -0,0 +1,209 @@
+
+ */
+
+namespace Yasumi\tests\SouthKorea;
+
+use DateInterval;
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\Provider\SouthKorea;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing Chuseok in South Korea.
+ */
+class ChuseokTest extends SouthKoreaBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'chuseok';
+
+ /**
+ * The year in which the holiday was first established
+ */
+ public const ESTABLISHMENT_YEAR = 1949;
+
+ /**
+ * Tests the holiday defined in this test.
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testHoliday()
+ {
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR, 2050);
+ if (isset(SouthKorea::LUNAR_HOLIDAY[self::HOLIDAY][$year])) {
+ $date = new DateTime(SouthKorea::LUNAR_HOLIDAY[self::HOLIDAY][$year], new DateTimeZone(self::TIMEZONE));
+
+ // Chuseok
+ $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $date);
+
+ // Day after Chuseok
+ if ($year >= 1986) {
+ $this->assertHoliday(
+ self::REGION,
+ 'dayAfterChuseok',
+ $year,
+ (clone $date)->add(new DateInterval('P1D'))
+ );
+ }
+
+ // Day before Chuseok
+ if ($year >= 1989) {
+ $this->assertHoliday(
+ self::REGION,
+ 'dayBeforeChuseok',
+ $year,
+ (clone $date)->sub(new DateInterval('P1D'))
+ );
+ }
+ }
+ }
+
+ /**
+ * Tests the substitute holiday defined in this test (conflict with Gaecheonjeol).
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testSubstituteHolidayByGaecheonjeol()
+ {
+ $this->assertHoliday(
+ self::REGION,
+ 'substituteHoliday:dayBeforeChuseok',
+ 2017,
+ new DateTime('2017-10-6', new DateTimeZone(self::TIMEZONE))
+ );
+ $this->assertHoliday(
+ self::REGION,
+ 'substituteHoliday:chuseok',
+ 2028,
+ new DateTime('2028-10-5', new DateTimeZone(self::TIMEZONE))
+ );
+ $this->assertHoliday(
+ self::REGION,
+ 'substituteHoliday:dayAfterChuseok',
+ 2039,
+ new DateTime('2039-10-5', new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the substitute holiday defined in this test (conflict with Sunday).
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testSubstituteHolidayBySunday()
+ {
+ $this->assertHoliday(
+ self::REGION,
+ 'substituteHoliday:dayBeforeChuseok',
+ 2014,
+ new DateTime('2014-9-10', new DateTimeZone(self::TIMEZONE))
+ );
+ $this->assertHoliday(
+ self::REGION,
+ 'substituteHoliday:chuseok',
+ 2039,
+ new DateTime('2039-10-4', new DateTimeZone(self::TIMEZONE))
+ );
+ $this->assertHoliday(
+ self::REGION,
+ 'substituteHoliday:dayAfterChuseok',
+ 2022,
+ new DateTime('2022-9-12', new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+
+ /**
+ * Tests the holiday defined in this test before establishment.
+ * @throws ReflectionException
+ */
+ public function testHolidayBeforeEstablishment()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ );
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR, 2050);
+ if (isset(SouthKorea::LUNAR_HOLIDAY[self::HOLIDAY][$year])) {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ [self::LOCALE => '추석']
+ );
+ if ($year >= 1986) {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ 'dayAfterChuseok',
+ $year,
+ [self::LOCALE => '추석 연휴']
+ );
+ }
+ if ($year >= 1989) {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ 'dayBeforeChuseok',
+ $year,
+ [self::LOCALE => '추석 연휴']
+ );
+ }
+ }
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR, 2050);
+ if (isset(SouthKorea::LUNAR_HOLIDAY[self::HOLIDAY][$year])) {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ Holiday::TYPE_OFFICIAL
+ );
+ if ($year >= 1986) {
+ $this->assertHolidayType(
+ self::REGION,
+ 'dayAfterChuseok',
+ $year,
+ Holiday::TYPE_OFFICIAL
+ );
+ }
+ if ($year >= 1989) {
+ $this->assertHolidayType(
+ self::REGION,
+ 'dayBeforeChuseok',
+ $year,
+ Holiday::TYPE_OFFICIAL
+ );
+ }
+ }
+ }
+}
diff --git a/tests/SouthKorea/ConstitutionDayTest.php b/tests/SouthKorea/ConstitutionDayTest.php
new file mode 100644
index 000000000..a0b45af47
--- /dev/null
+++ b/tests/SouthKorea/ConstitutionDayTest.php
@@ -0,0 +1,112 @@
+
+ */
+
+namespace Yasumi\tests\SouthKorea;
+
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing day after Constitution Day in South Korea.
+ */
+class ConstitutionDayTest extends SouthKoreaBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'constitutionDay';
+
+ /**
+ * The year in which the holiday was first established
+ */
+ public const ESTABLISHMENT_YEAR = 1949;
+
+ /**
+ * The year in which the holiday was removed
+ */
+ public const REMOVED_YEAR = 2007;
+
+ /**
+ * Tests the holiday defined in this test.
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testHoliday()
+ {
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR, self::REMOVED_YEAR);
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime("$year-7-17", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday defined in this test after removal.
+ * @throws ReflectionException
+ */
+ public function testHolidayAfterRemoval()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::REMOVED_YEAR + 1)
+ );
+ }
+
+ /**
+ * Tests the holiday defined in this test before establishment.
+ * @throws ReflectionException
+ */
+ public function testHolidayBeforeEstablishment()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ );
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR, self::REMOVED_YEAR),
+ [self::LOCALE => '제헌절']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR, self::REMOVED_YEAR),
+ Holiday::TYPE_OFFICIAL
+ );
+ }
+}
diff --git a/tests/SouthKorea/GaecheonjeolTest.php b/tests/SouthKorea/GaecheonjeolTest.php
new file mode 100644
index 000000000..95ebe719c
--- /dev/null
+++ b/tests/SouthKorea/GaecheonjeolTest.php
@@ -0,0 +1,94 @@
+
+ */
+
+namespace Yasumi\tests\SouthKorea;
+
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing Gaecheonjeol (National Foundation Day) in South Korea.
+ */
+class GaecheonjeolTest extends SouthKoreaBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'nationalFoundationDay';
+
+ /**
+ * The year in which the holiday was first established
+ */
+ public const ESTABLISHMENT_YEAR = 1949;
+
+ /**
+ * Tests the holiday defined in this test.
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testHoliday()
+ {
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime("$year-10-3", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday defined in this test before establishment.
+ * @throws ReflectionException
+ */
+ public function testHolidayBeforeEstablishment()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ );
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ [self::LOCALE => '개천절']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ Holiday::TYPE_OFFICIAL
+ );
+ }
+}
diff --git a/tests/SouthKorea/HangulDayTest.php b/tests/SouthKorea/HangulDayTest.php
new file mode 100644
index 000000000..e18a14206
--- /dev/null
+++ b/tests/SouthKorea/HangulDayTest.php
@@ -0,0 +1,108 @@
+
+ */
+
+namespace Yasumi\tests\SouthKorea;
+
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing Hangul Day in South Korea.
+ */
+class HangulDayTest extends SouthKoreaBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'hangulDay';
+
+ /**
+ * The year in which the holiday was first established
+ */
+ public const ESTABLISHMENT_YEAR = 1949;
+
+ /**
+ * Tests the holiday defined in this test.
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testHoliday()
+ {
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
+ if ($year > 1990 && $year <= 2012) {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year
+ );
+ } else {
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime("$year-10-9", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+ }
+
+ /**
+ * Tests the holiday defined in this test before establishment.
+ * @throws ReflectionException
+ */
+ public function testHolidayBeforeEstablishment()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ );
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
+ if ($year <= 1990 || $year > 2012) {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ [self::LOCALE => '한글날']
+ );
+ }
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
+ if ($year <= 1990 || $year > 2012) {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ Holiday::TYPE_OFFICIAL
+ );
+ }
+ }
+}
diff --git a/tests/SouthKorea/IndependenceMovementDayTest.php b/tests/SouthKorea/IndependenceMovementDayTest.php
new file mode 100644
index 000000000..2b119df0d
--- /dev/null
+++ b/tests/SouthKorea/IndependenceMovementDayTest.php
@@ -0,0 +1,94 @@
+
+ */
+
+namespace Yasumi\tests\SouthKorea;
+
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing Independence Movement Day in South Korea.
+ */
+class IndependenceMovementDayTest extends SouthKoreaBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'independenceMovementDay';
+
+ /**
+ * The year in which the holiday was first established
+ */
+ public const ESTABLISHMENT_YEAR = 1949;
+
+ /**
+ * Tests the holiday defined in this test.
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testHoliday()
+ {
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime("$year-3-1", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday defined in this test before establishment.
+ * @throws ReflectionException
+ */
+ public function testHolidayBeforeEstablishment()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ );
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ [self::LOCALE => '삼일절']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ Holiday::TYPE_OFFICIAL
+ );
+ }
+}
diff --git a/tests/SouthKorea/LiberationDayTest.php b/tests/SouthKorea/LiberationDayTest.php
new file mode 100644
index 000000000..711151f3b
--- /dev/null
+++ b/tests/SouthKorea/LiberationDayTest.php
@@ -0,0 +1,94 @@
+
+ */
+
+namespace Yasumi\tests\SouthKorea;
+
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing Independence Movement Day in South Korea.
+ */
+class LiberationDayTest extends SouthKoreaBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'liberationDay';
+
+ /**
+ * The year in which the holiday was first established
+ */
+ public const ESTABLISHMENT_YEAR = 1949;
+
+ /**
+ * Tests the holiday defined in this test.
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testHoliday()
+ {
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime("$year-8-15", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday defined in this test before establishment.
+ * @throws ReflectionException
+ */
+ public function testHolidayBeforeEstablishment()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ );
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ [self::LOCALE => '광복절']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ Holiday::TYPE_OFFICIAL
+ );
+ }
+}
diff --git a/tests/SouthKorea/MemorialDayTest.php b/tests/SouthKorea/MemorialDayTest.php
new file mode 100644
index 000000000..61fa8dd46
--- /dev/null
+++ b/tests/SouthKorea/MemorialDayTest.php
@@ -0,0 +1,94 @@
+
+ */
+
+namespace Yasumi\tests\SouthKorea;
+
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing Memorial Day in South Korea.
+ */
+class MemorialDayTest extends SouthKoreaBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'memorialDay';
+
+ /**
+ * The year in which the holiday was first established
+ */
+ public const ESTABLISHMENT_YEAR = 1966;
+
+ /**
+ * Tests the holiday defined in this test.
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testHoliday()
+ {
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime("$year-6-6", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday defined in this test before establishment.
+ * @throws ReflectionException
+ */
+ public function testHolidayBeforeEstablishment()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ );
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ [self::LOCALE => '현충일']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ Holiday::TYPE_OFFICIAL
+ );
+ }
+}
diff --git a/tests/SouthKorea/NewYearsDayTest.php b/tests/SouthKorea/NewYearsDayTest.php
new file mode 100644
index 000000000..b53da96ca
--- /dev/null
+++ b/tests/SouthKorea/NewYearsDayTest.php
@@ -0,0 +1,155 @@
+
+ */
+
+namespace Yasumi\tests\SouthKorea;
+
+use DateInterval;
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing New Year's Day in South Korea.
+ */
+class NewYearsDayTest extends SouthKoreaBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'newYearsDay';
+
+ /**
+ * The year in which the holiday was first established
+ */
+ public const ESTABLISHMENT_YEAR = 1950;
+
+ /**
+ * Tests the holiday defined in this test.
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testHoliday()
+ {
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $date = new DateTime("$year-1-1", new DateTimeZone(self::TIMEZONE));
+
+ // New Year's Day
+ $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $date);
+
+ // Day after New Year's Day
+ if ($year <= 1998) {
+ $this->assertHoliday(
+ self::REGION,
+ 'dayAfterNewYearsDay',
+ $year,
+ (clone $date)->add(new DateInterval('P1D'))
+ );
+ }
+
+ // Two days later New Year's Day
+ if ($year <= 1990) {
+ $this->assertHoliday(
+ self::REGION,
+ 'twoDaysLaterNewYearsDay',
+ $year,
+ (clone $date)->add(new DateInterval('P2D'))
+ );
+ }
+ }
+
+ /**
+ * Tests the holiday defined in this test after removal.
+ * @throws ReflectionException
+ */
+ public function testHolidayAfterRemoval()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ 'dayAfterNewYearsDay',
+ $this->generateRandomYear(1999)
+ );
+ $this->assertNotHoliday(
+ self::REGION,
+ 'twoDaysLaterNewYearsDay',
+ $this->generateRandomYear(1991)
+ );
+ }
+
+ /**
+ * Tests the holiday defined in this test before establishment.
+ * @throws ReflectionException
+ */
+ public function testHolidayBeforeEstablishment()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ );
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ [self::LOCALE => '새해']
+ );
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ 'dayAfterNewYearsDay',
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR, 1998),
+ [self::LOCALE => '새해 연휴']
+ );
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ 'twoDaysLaterNewYearsDay',
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR, 1990),
+ [self::LOCALE => '새해 연휴']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ Holiday::TYPE_OFFICIAL
+ );
+ $this->assertHolidayType(
+ self::REGION,
+ 'dayAfterNewYearsDay',
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR, 1998),
+ Holiday::TYPE_OFFICIAL
+ );
+ $this->assertHolidayType(
+ self::REGION,
+ 'twoDaysLaterNewYearsDay',
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR, 1990),
+ Holiday::TYPE_OFFICIAL
+ );
+ }
+}
diff --git a/tests/SouthKorea/SeollalTest.php b/tests/SouthKorea/SeollalTest.php
new file mode 100644
index 000000000..5c5d556dd
--- /dev/null
+++ b/tests/SouthKorea/SeollalTest.php
@@ -0,0 +1,175 @@
+
+ */
+
+namespace Yasumi\tests\SouthKorea;
+
+use DateInterval;
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\Provider\SouthKorea;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing Seollal (Korean New Year's Day) in South Korea.
+ */
+class SeollalTest extends SouthKoreaBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'seollal';
+
+ /**
+ * The year in which the holiday was first established
+ */
+ public const ESTABLISHMENT_YEAR = 1985;
+
+ /**
+ * Tests the holiday defined in this test.
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testHoliday()
+ {
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR, 2050);
+ if (isset(SouthKorea::LUNAR_HOLIDAY[self::HOLIDAY][$year])) {
+ $date = new DateTime(SouthKorea::LUNAR_HOLIDAY[self::HOLIDAY][$year], new DateTimeZone(self::TIMEZONE));
+
+ // Seollal
+ $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $date);
+
+ if ($year >= 1990) {
+ // Day before Seollal
+ $this->assertHoliday(
+ self::REGION,
+ 'dayBeforeSeollal',
+ $year,
+ (clone $date)->sub(new DateInterval('P1D'))
+ );
+
+ // Day after Seollal
+ $this->assertHoliday(
+ self::REGION,
+ 'dayAfterSeollal',
+ $year,
+ (clone $date)->add(new DateInterval('P1D'))
+ );
+ }
+ }
+ }
+
+ /**
+ * Tests the substitute holiday defined in this test (conflict with Sunday).
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testSubstituteHolidayBySunday()
+ {
+ $this->assertHoliday(
+ self::REGION,
+ 'substituteHoliday:dayBeforeSeollal',
+ 2016,
+ new DateTime('2016-2-10', new DateTimeZone(self::TIMEZONE))
+ );
+ $this->assertHoliday(
+ self::REGION,
+ 'substituteHoliday:seollal',
+ 2034,
+ new DateTime('2034-2-21', new DateTimeZone(self::TIMEZONE))
+ );
+ $this->assertHoliday(
+ self::REGION,
+ 'substituteHoliday:dayAfterSeollal',
+ 2024,
+ new DateTime('2024-2-12', new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday defined in this test before establishment.
+ * @throws ReflectionException
+ */
+ public function testHolidayBeforeEstablishment()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ );
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR, 2050);
+ if (isset(SouthKorea::LUNAR_HOLIDAY[self::HOLIDAY][$year])) {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ [self::LOCALE => '설날']
+ );
+ if ($year >= 1990) {
+ $this->assertHolidayType(
+ self::REGION,
+ 'dayBeforeSeollal',
+ $year,
+ Holiday::TYPE_OFFICIAL
+ );
+ $this->assertHolidayType(
+ self::REGION,
+ 'dayAfterSeollal',
+ $year,
+ Holiday::TYPE_OFFICIAL
+ );
+ }
+ }
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR, 2050);
+ if (isset(SouthKorea::LUNAR_HOLIDAY[self::HOLIDAY][$year])) {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ Holiday::TYPE_OFFICIAL
+ );
+ if ($year >= 1990) {
+ $this->assertHolidayType(
+ self::REGION,
+ 'dayBeforeSeollal',
+ $year,
+ Holiday::TYPE_OFFICIAL
+ );
+ $this->assertHolidayType(
+ self::REGION,
+ 'dayAfterSeollal',
+ $year,
+ Holiday::TYPE_OFFICIAL
+ );
+ }
+ }
+ }
+}
diff --git a/tests/SouthKorea/SouthKoreaBaseTestCase.php b/tests/SouthKorea/SouthKoreaBaseTestCase.php
new file mode 100644
index 000000000..95aadfa97
--- /dev/null
+++ b/tests/SouthKorea/SouthKoreaBaseTestCase.php
@@ -0,0 +1,40 @@
+
+ */
+
+namespace Yasumi\tests\SouthKorea;
+
+use PHPUnit\Framework\TestCase;
+use Yasumi\tests\YasumiBase;
+
+/**
+ * Base class for test cases of the South Korea holiday provider.
+ */
+abstract class SouthKoreaBaseTestCase extends TestCase
+{
+ use YasumiBase;
+
+ /**
+ * Name of the region (e.g. country / state) to be tested
+ */
+ public const REGION = 'SouthKorea';
+
+ /**
+ * Timezone in which this provider has holidays defined
+ */
+ public const TIMEZONE = 'Asia/Seoul';
+
+ /**
+ * Locale that is considered common for this provider
+ */
+ public const LOCALE = 'ko_KR';
+}
diff --git a/tests/SouthKorea/SouthKoreaTest.php b/tests/SouthKorea/SouthKoreaTest.php
new file mode 100644
index 000000000..b177e8b89
--- /dev/null
+++ b/tests/SouthKorea/SouthKoreaTest.php
@@ -0,0 +1,135 @@
+
+ */
+
+namespace Yasumi\tests\SouthKorea;
+
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\Provider\SouthKorea;
+
+/**
+ * Class for testing holidays in South Korea.
+ */
+class SouthKoreaTest extends SouthKoreaBaseTestCase
+{
+ /**
+ * @var int year random year number used for all tests in this Test Case
+ */
+ protected $year;
+
+ /**
+ * Tests if all official holidays in South Korea are defined by the provider class
+ * @throws ReflectionException
+ */
+ public function testOfficialHolidays(): void
+ {
+ $officialHolidays = [];
+ if ($this->year >= 1949) {
+ $officialHolidays[] = 'independenceMovementDay';
+ $officialHolidays[] = 'liberationDay';
+ $officialHolidays[] = 'nationalFoundationDay';
+ $officialHolidays[] = 'christmasDay';
+ if ($this->year !== ArborDayTest::YEAR_NOT_CELEBRATED && $this->year < ArborDayTest::REMOVED_YEAR + 1) {
+ $officialHolidays[] = 'arborDay';
+ }
+ if ($this->year <= 1990 || $this->year > 2012) {
+ $officialHolidays[] = 'hangulDay';
+ }
+ if ($this->year < 2008) {
+ $officialHolidays[] = 'constitutionDay';
+ }
+ }
+ if ($this->year >= 1950) {
+ $officialHolidays[] = 'newYearsDay';
+ if ($this->year <= 1990) {
+ $officialHolidays[] = 'twoDaysLaterNewYearsDay';
+ }
+ if ($this->year <= 1998) {
+ $officialHolidays[] = 'dayAfterNewYearsDay';
+ }
+ }
+ if ($this->year >= 1956 && $this->year <= 1990) {
+ $officialHolidays[] = 'armedForcesDay';
+ }
+ if ($this->year >= 1966) {
+ $officialHolidays[] = 'memorialDay';
+ }
+
+ // specific cases (Seollal, Buddha's Birthday and Chuseok)
+ if ($this->year >= 1949 && isset(SouthKorea::LUNAR_HOLIDAY['chuseok'][$this->year])) {
+ $officialHolidays[] = 'chuseok';
+ if ($this->year >= 1986) {
+ $officialHolidays[] = 'dayAfterChuseok';
+ }
+ if ($this->year >= 1989) {
+ $officialHolidays[] = 'dayBeforeChuseok';
+ }
+ }
+ if ($this->year >= 1975 && isset(SouthKorea::LUNAR_HOLIDAY['buddhasBirthday'][$this->year])) {
+ $officialHolidays[] = 'buddhasBirthday';
+ }
+ if ($this->year >= 1985 && isset(SouthKorea::LUNAR_HOLIDAY['seollal'][$this->year])) {
+ $officialHolidays[] = 'seollal';
+ if ($this->year > 1989) {
+ $officialHolidays[] = 'dayBeforeSeollal';
+ $officialHolidays[] = 'dayAfterSeollal';
+ }
+ }
+
+ $this->assertDefinedHolidays($officialHolidays, self::REGION, $this->year, Holiday::TYPE_OFFICIAL);
+ }
+
+ /**
+ * Tests if all observed holidays in South Korea are defined by the provider class
+ * @throws ReflectionException
+ */
+ public function testObservedHolidays(): void
+ {
+ $this->assertDefinedHolidays([], self::REGION, $this->year, Holiday::TYPE_OBSERVANCE);
+ }
+
+ /**
+ * Tests if all seasonal holidays in South Korea are defined by the provider class
+ * @throws ReflectionException
+ */
+ public function testSeasonalHolidays(): void
+ {
+ $this->assertDefinedHolidays([], self::REGION, $this->year, Holiday::TYPE_SEASON);
+ }
+
+ /**
+ * Tests if all bank holidays in South Korea are defined by the provider class
+ * @throws ReflectionException
+ */
+ public function testBankHolidays(): void
+ {
+ $this->assertDefinedHolidays([], self::REGION, $this->year, Holiday::TYPE_BANK);
+ }
+
+ /**
+ * Tests if all other holidays in South Korea are defined by the provider class
+ * @throws ReflectionException
+ */
+ public function testOtherHolidays(): void
+ {
+ $this->assertDefinedHolidays([], self::REGION, $this->year, Holiday::TYPE_OTHER);
+ }
+
+ /**
+ * Initial setup of this Test Case
+ */
+ protected function setUp(): void
+ {
+ $this->year = $this->generateRandomYear(1949, 2050);
+ }
+}
diff --git a/tests/Spain/AllSaintsDayTest.php b/tests/Spain/AllSaintsDayTest.php
index fe5d1de6c..54b0293a6 100644
--- a/tests/Spain/AllSaintsDayTest.php
+++ b/tests/Spain/AllSaintsDayTest.php
@@ -1,4 +1,4 @@
-year = $this->generateRandomYear(1981);
}
diff --git a/tests/Spain/Aragon/AragonBaseTestCase.php b/tests/Spain/Aragon/AragonBaseTestCase.php
index 8c4de7cdb..1b0f684b4 100644
--- a/tests/Spain/Aragon/AragonBaseTestCase.php
+++ b/tests/Spain/Aragon/AragonBaseTestCase.php
@@ -1,4 +1,4 @@
-year = $this->generateRandomYear(1981);
}
diff --git a/tests/Spain/Aragon/StGeorgesDayTest.php b/tests/Spain/Aragon/StGeorgesDayTest.php
index 922ee21dd..ccd266284 100644
--- a/tests/Spain/Aragon/StGeorgesDayTest.php
+++ b/tests/Spain/Aragon/StGeorgesDayTest.php
@@ -1,4 +1,4 @@
-year = $this->generateRandomYear(1984);
}
diff --git a/tests/Spain/BalearicIslands/BalearicIslandsBaseTestCase.php b/tests/Spain/BalearicIslands/BalearicIslandsBaseTestCase.php
index 33b009fcc..1e6fe0339 100644
--- a/tests/Spain/BalearicIslands/BalearicIslandsBaseTestCase.php
+++ b/tests/Spain/BalearicIslands/BalearicIslandsBaseTestCase.php
@@ -1,4 +1,4 @@
-year = $this->generateRandomYear(1981);
}
diff --git a/tests/Spain/BasqueCountry/BasqueCountryBaseTestCase.php b/tests/Spain/BasqueCountry/BasqueCountryBaseTestCase.php
index bb07cae22..b6f1f9099 100644
--- a/tests/Spain/BasqueCountry/BasqueCountryBaseTestCase.php
+++ b/tests/Spain/BasqueCountry/BasqueCountryBaseTestCase.php
@@ -1,4 +1,4 @@
-year = $this->generateRandomYear(2011, 2013);
}
diff --git a/tests/Spain/CanaryIslands/CanaryIslandsBaseTestCase.php b/tests/Spain/CanaryIslands/CanaryIslandsBaseTestCase.php
index 2848b58f8..5372b33df 100644
--- a/tests/Spain/CanaryIslands/CanaryIslandsBaseTestCase.php
+++ b/tests/Spain/CanaryIslands/CanaryIslandsBaseTestCase.php
@@ -1,4 +1,4 @@
-year = $this->generateRandomYear(1984);
}
diff --git a/tests/Spain/Cantabria/CantabriaBaseTestCase.php b/tests/Spain/Cantabria/CantabriaBaseTestCase.php
index 5fa512d10..e42f2255b 100644
--- a/tests/Spain/Cantabria/CantabriaBaseTestCase.php
+++ b/tests/Spain/Cantabria/CantabriaBaseTestCase.php
@@ -1,4 +1,4 @@
-year = $this->generateRandomYear(1981);
}
diff --git a/tests/Spain/CastileAndLeon/CastileAndLeonBaseTestCase.php b/tests/Spain/CastileAndLeon/CastileAndLeonBaseTestCase.php
index 019c69360..bac8f0583 100644
--- a/tests/Spain/CastileAndLeon/CastileAndLeonBaseTestCase.php
+++ b/tests/Spain/CastileAndLeon/CastileAndLeonBaseTestCase.php
@@ -1,4 +1,4 @@
-year = $this->generateRandomYear(1981);
}
diff --git a/tests/Spain/CastillaLaMancha/CastillaLaManchaBaseTestCase.php b/tests/Spain/CastillaLaMancha/CastillaLaManchaBaseTestCase.php
index 146bca8e0..30d9657e5 100644
--- a/tests/Spain/CastillaLaMancha/CastillaLaManchaBaseTestCase.php
+++ b/tests/Spain/CastillaLaMancha/CastillaLaManchaBaseTestCase.php
@@ -1,4 +1,4 @@
-year = $this->generateRandomYear(1984);
}
diff --git a/tests/Spain/Catalonia/CataloniaBaseTestCase.php b/tests/Spain/Catalonia/CataloniaBaseTestCase.php
index ef816dc2a..fbf24dbc9 100644
--- a/tests/Spain/Catalonia/CataloniaBaseTestCase.php
+++ b/tests/Spain/Catalonia/CataloniaBaseTestCase.php
@@ -1,4 +1,4 @@
-year = $this->generateRandomYear(1981);
}
diff --git a/tests/Spain/Catalonia/nationalCataloniaDayTest.php b/tests/Spain/Catalonia/nationalCataloniaDayTest.php
index b6385f183..a04a09da2 100644
--- a/tests/Spain/Catalonia/nationalCataloniaDayTest.php
+++ b/tests/Spain/Catalonia/nationalCataloniaDayTest.php
@@ -1,4 +1,4 @@
-year = $this->generateRandomYear(1981);
}
diff --git a/tests/Spain/Ceuta/ceutaDayTest.php b/tests/Spain/Ceuta/ceutaDayTest.php
index fcae69cc9..074524b90 100644
--- a/tests/Spain/Ceuta/ceutaDayTest.php
+++ b/tests/Spain/Ceuta/ceutaDayTest.php
@@ -1,4 +1,4 @@
-year = $this->generateRandomYear(1981);
}
diff --git a/tests/Spain/CommunityOfMadrid/DosdeMayoUprisingDayTest.php b/tests/Spain/CommunityOfMadrid/DosdeMayoUprisingDayTest.php
index bf0b92edd..c0e083e97 100644
--- a/tests/Spain/CommunityOfMadrid/DosdeMayoUprisingDayTest.php
+++ b/tests/Spain/CommunityOfMadrid/DosdeMayoUprisingDayTest.php
@@ -1,4 +1,4 @@
-year = $this->generateRandomYear(1984);
}
diff --git a/tests/Spain/Galicia/GaliciaBaseTestCase.php b/tests/Spain/Galicia/GaliciaBaseTestCase.php
index a30ca3164..2672db84e 100644
--- a/tests/Spain/Galicia/GaliciaBaseTestCase.php
+++ b/tests/Spain/Galicia/GaliciaBaseTestCase.php
@@ -1,4 +1,4 @@
-year = $this->generateRandomYear(2000);
}
diff --git a/tests/Spain/Galicia/GalicianLiteratureDayTest.php b/tests/Spain/Galicia/GalicianLiteratureDayTest.php
index b1779c075..d7eeb1025 100644
--- a/tests/Spain/Galicia/GalicianLiteratureDayTest.php
+++ b/tests/Spain/Galicia/GalicianLiteratureDayTest.php
@@ -1,4 +1,4 @@
-year = $this->generateRandomYear(1983);
}
diff --git a/tests/Spain/MaundyThursdayTest.php b/tests/Spain/MaundyThursdayTest.php
index ab72b930a..fbb9724a3 100644
--- a/tests/Spain/MaundyThursdayTest.php
+++ b/tests/Spain/MaundyThursdayTest.php
@@ -1,4 +1,4 @@
-year = $this->generateRandomYear(1981);
}
diff --git a/tests/Spain/NationalDayTest.php b/tests/Spain/NationalDayTest.php
index dcf03f8a0..7d0e79659 100644
--- a/tests/Spain/NationalDayTest.php
+++ b/tests/Spain/NationalDayTest.php
@@ -1,4 +1,4 @@
-year = $this->generateRandomYear(1981);
}
diff --git a/tests/Spain/NewYearsDayTest.php b/tests/Spain/NewYearsDayTest.php
index 4475813e8..ce5eb802b 100644
--- a/tests/Spain/NewYearsDayTest.php
+++ b/tests/Spain/NewYearsDayTest.php
@@ -1,4 +1,4 @@
-year = $this->generateRandomYear(1981);
}
diff --git a/tests/Spain/SpainBaseTestCase.php b/tests/Spain/SpainBaseTestCase.php
index 99363d9ce..9ead6b6df 100644
--- a/tests/Spain/SpainBaseTestCase.php
+++ b/tests/Spain/SpainBaseTestCase.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OFFICIAL);
}
/**
* Tests if all observed holidays in Spain are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -55,7 +56,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Spain are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -64,7 +65,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Spain are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -73,7 +74,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Spain are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -83,7 +84,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(2000);
}
diff --git a/tests/Spain/ValencianCommunity/ValencianCommunityBaseTestCase.php b/tests/Spain/ValencianCommunity/ValencianCommunityBaseTestCase.php
index 36c9a5ad0..e0d53df52 100644
--- a/tests/Spain/ValencianCommunity/ValencianCommunityBaseTestCase.php
+++ b/tests/Spain/ValencianCommunity/ValencianCommunityBaseTestCase.php
@@ -1,4 +1,4 @@
-year = $this->generateRandomYear(1981);
}
diff --git a/tests/Spain/ValentinesDayTest.php b/tests/Spain/ValentinesDayTest.php
index 64f3f128a..010f9f3ff 100644
--- a/tests/Spain/ValentinesDayTest.php
+++ b/tests/Spain/ValentinesDayTest.php
@@ -1,4 +1,4 @@
-format('l') === 'Saturday') {
+ if ('Saturday' === $date->format('l')) {
$data[] = [$year, $date];
break;
}
@@ -72,7 +74,7 @@ public function HolidayDataProvider(): array
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -86,7 +88,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Sweden/AllSaintsEveTest.php b/tests/Sweden/AllSaintsEveTest.php
new file mode 100644
index 000000000..da1ac438c
--- /dev/null
+++ b/tests/Sweden/AllSaintsEveTest.php
@@ -0,0 +1,97 @@
+
+ */
+
+namespace Yasumi\tests\Sweden;
+
+use DateInterval;
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing All Saints' Eve in Sweden.
+ */
+class AllSaintsEveTest extends SwedenBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday to be tested
+ */
+ public const HOLIDAY = 'allSaintsEve';
+
+ /**
+ * Tests the holiday defined in this test.
+ *
+ * @dataProvider HolidayDataProvider
+ *
+ * @param int $year the year for which the holiday defined in this test needs to be tested
+ * @param DateTime $expected the expected date
+ *
+ * @throws ReflectionException
+ */
+ public function testHoliday($year, $expected)
+ {
+ $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
+ }
+
+ /**
+ * Returns a list of random test dates used for assertion of the holiday defined in this test
+ *
+ * @return array list of test dates for the holiday defined in this test
+ * @throws Exception
+ */
+ public function HolidayDataProvider(): array
+ {
+ $data = [];
+
+ for ($y = 0; $y < 50; $y++) {
+ $year = $this->generateRandomYear();
+ $date = new DateTime("$year-10-30", new DateTimeZone(self::TIMEZONE));
+
+ // Check between 30 October and 5th of November the day that is a Friday
+ for ($d = 0; $d <= 7; ++$d) {
+ if ('Friday' === $date->format('l')) {
+ $data[] = [$year, $date];
+ break;
+ }
+ $date->add(new DateInterval('P1D'));
+ }
+ }
+
+ return $data;
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(),
+ [self::LOCALE => 'alla helgons afton']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OBSERVANCE);
+ }
+}
diff --git a/tests/Sweden/AscensionDayTest.php b/tests/Sweden/AscensionDayTest.php
index 983b419e9..bd06533d3 100644
--- a/tests/Sweden/AscensionDayTest.php
+++ b/tests/Sweden/AscensionDayTest.php
@@ -1,4 +1,4 @@
-assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL);
+ $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OBSERVANCE);
}
}
diff --git a/tests/Sweden/EasterMondayTest.php b/tests/Sweden/EasterMondayTest.php
index 92c9d53ea..be7159045 100644
--- a/tests/Sweden/EasterMondayTest.php
+++ b/tests/Sweden/EasterMondayTest.php
@@ -1,4 +1,4 @@
-
+ */
+
+namespace Yasumi\tests\Sweden;
+
+use DateTime;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class containing tests for Epiphany Eve in Sweden.
+ */
+class EpiphanyEveTest extends SwedenBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday to be tested
+ */
+ public const HOLIDAY = 'epiphanyEve';
+
+ /**
+ * Tests the holiday defined in this test.
+ *
+ * @dataProvider HolidayDataProvider
+ *
+ * @param int $year the year for which the holiday defined in this test needs to be tested
+ * @param DateTime $expected the expected date
+ *
+ * @throws ReflectionException
+ */
+ public function testHoliday($year, $expected)
+ {
+ $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
+ }
+
+ /**
+ * Returns a list of random test dates used for assertion of the holiday defined in this test.
+ *
+ * @return array list of test dates for the day of the holiday defined in this test
+ * @throws Exception
+ */
+ public function HolidayDataProvider(): array
+ {
+ return $this->generateRandomDates(1, 5, self::TIMEZONE);
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(),
+ [self::LOCALE => 'trettondagsafton']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OBSERVANCE);
+ }
+}
diff --git a/tests/Sweden/EpiphanyTest.php b/tests/Sweden/EpiphanyTest.php
index 1547e9fee..c66bdfb05 100644
--- a/tests/Sweden/EpiphanyTest.php
+++ b/tests/Sweden/EpiphanyTest.php
@@ -1,4 +1,4 @@
-
+ */
+
+namespace Yasumi\tests\Sweden;
+
+use DateTime;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing New Year's Eve in Sweden.
+ */
+class NewYearsEveTest extends SwedenBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday to be tested
+ */
+ public const HOLIDAY = 'newYearsEve';
+
+ /**
+ * Tests the holiday defined in this test.
+ *
+ * @dataProvider HolidayDataProvider
+ *
+ * @param int $year the year for which the holiday defined in this test needs to be tested
+ * @param DateTime $expected the expected date
+ *
+ * @throws ReflectionException
+ */
+ public function testHoliday($year, $expected)
+ {
+ $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
+ }
+
+ /**
+ * Returns a list of random test dates used for assertion of the holiday defined in this test
+ *
+ * @return array list of test dates for the holiday defined in this test
+ * @throws Exception
+ */
+ public function HolidayDataProvider(): array
+ {
+ return $this->generateRandomDates(12, 31, self::TIMEZONE);
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(),
+ [self::LOCALE => 'nyårsafton']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OBSERVANCE);
+ }
+}
diff --git a/tests/Sweden/PentecostTest.php b/tests/Sweden/PentecostTest.php
index 57c62dbca..755e27a36 100644
--- a/tests/Sweden/PentecostTest.php
+++ b/tests/Sweden/PentecostTest.php
@@ -1,4 +1,4 @@
-generateRandomYear();
$holidays = Yasumi::create(self::REGION, $year);
- $holiday = $holidays->getHoliday(self::HOLIDAY);
+ $holiday = $holidays->getHoliday(self::HOLIDAY);
// Some basic assertions
$this->assertInstanceOf('Yasumi\Provider\\' . \str_replace('/', '\\', self::REGION), $holidays);
@@ -52,7 +53,7 @@ public function testHoliday()
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -66,7 +67,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Sweden/StJohnsEveTest.php b/tests/Sweden/StJohnsEveTest.php
new file mode 100644
index 000000000..9279cdec7
--- /dev/null
+++ b/tests/Sweden/StJohnsEveTest.php
@@ -0,0 +1,76 @@
+
+ */
+
+namespace Yasumi\tests\Sweden;
+
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+use Yasumi\Yasumi;
+
+/**
+ * Class for testing St. John's Eve / Midsummer's Eve in Sweden.
+ */
+class StJohnsEveTest extends SwedenBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday to be tested
+ */
+ public const HOLIDAY = 'stJohnsEve';
+
+ /**
+ * Tests the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHoliday()
+ {
+ $year = $this->generateRandomYear();
+
+ $holidays = Yasumi::create(self::REGION, $year);
+ $holiday = $holidays->getHoliday(self::HOLIDAY);
+
+ // Some basic assertions
+ $this->assertInstanceOf('Yasumi\Provider\\' . \str_replace('/', '\\', self::REGION), $holidays);
+ $this->assertInstanceOf(Holiday::class, $holiday);
+ $this->assertNotNull($holiday);
+
+ // Holiday specific assertions
+ $this->assertEquals('Friday', $holiday->format('l'));
+ $this->assertGreaterThanOrEqual(19, $holiday->format('j'));
+ $this->assertLessThanOrEqual(25, $holiday->format('j'));
+
+ unset($holiday, $holidays);
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(),
+ [self::LOCALE => 'midsommarafton']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OBSERVANCE);
+ }
+}
diff --git a/tests/Sweden/SwedenBaseTestCase.php b/tests/Sweden/SwedenBaseTestCase.php
index d62a92b62..d5b84f586 100644
--- a/tests/Sweden/SwedenBaseTestCase.php
+++ b/tests/Sweden/SwedenBaseTestCase.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OFFICIAL);
}
/**
* Tests if all observed holidays in Sweden are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
- $this->assertDefinedHolidays([], self::REGION, $this->year, Holiday::TYPE_OBSERVANCE);
+ $this->assertDefinedHolidays([
+ 'epiphanyEve',
+ 'walpurgisEve',
+ 'stJohnsEve',
+ 'allSaintsEve',
+ 'christmasEve',
+ 'newYearsEve',
+ ], self::REGION, $this->year, Holiday::TYPE_OBSERVANCE);
}
/**
* Tests if all seasonal holidays in Sweden are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -68,7 +75,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Sweden are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -77,7 +84,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Sweden are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -87,7 +94,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1916);
}
diff --git a/tests/Sweden/WalpurgisEveTest.php b/tests/Sweden/WalpurgisEveTest.php
new file mode 100644
index 000000000..69226149b
--- /dev/null
+++ b/tests/Sweden/WalpurgisEveTest.php
@@ -0,0 +1,79 @@
+
+ */
+
+namespace Yasumi\tests\Sweden;
+
+use DateTime;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class containing tests for Walpurgis Night in Sweden.
+ */
+class WalpurgisEveTest extends SwedenBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday to be tested
+ */
+ public const HOLIDAY = 'walpurgisEve';
+
+ /**
+ * Tests the holiday defined in this test.
+ *
+ * @dataProvider HolidayDataProvider
+ *
+ * @param int $year the year for which the holiday defined in this test needs to be tested
+ * @param DateTime $expected the expected date
+ *
+ * @throws ReflectionException
+ */
+ public function testHoliday($year, $expected)
+ {
+ $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
+ }
+
+ /**
+ * Returns a list of random test dates used for assertion of the holiday defined in this test.
+ *
+ * @return array list of test dates for the day of the holiday defined in this test
+ * @throws Exception
+ */
+ public function HolidayDataProvider(): array
+ {
+ return $this->generateRandomDates(4, 30, self::TIMEZONE);
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(),
+ [self::LOCALE => 'valborgsmässoafton']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OBSERVANCE);
+ }
+}
diff --git a/tests/Switzerland/Aargau/AargauBaseTestCase.php b/tests/Switzerland/Aargau/AargauBaseTestCase.php
index 3e6fdbf2e..fd4c1dd41 100644
--- a/tests/Switzerland/Aargau/AargauBaseTestCase.php
+++ b/tests/Switzerland/Aargau/AargauBaseTestCase.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OTHER);
}
/**
* Tests if all observed holidays in Aargau (Switzerland) are defined by the provider class
*
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -71,7 +72,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Aargau (Switzerland) are defined by the provider class
*
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -81,7 +82,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Aargau (Switzerland) are defined by the provider class
*
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -91,7 +92,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Aargau (Switzerland) are defined by the provider class
*
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -101,7 +102,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1945);
}
diff --git a/tests/Switzerland/Aargau/AscensionDayTest.php b/tests/Switzerland/Aargau/AscensionDayTest.php
index 68f596701..d56d49b4c 100644
--- a/tests/Switzerland/Aargau/AscensionDayTest.php
+++ b/tests/Switzerland/Aargau/AscensionDayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OTHER);
}
/**
* Tests if all observed holidays in Appenzell Ausserrhoden (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -70,7 +71,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Appenzell Ausserrhoden (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -79,7 +80,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Appenzell Ausserrhoden (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -88,7 +89,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Appenzell Ausserrhoden (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -98,7 +99,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1945);
}
diff --git a/tests/Switzerland/AppenzellAusserrhoden/AscensionDayTest.php b/tests/Switzerland/AppenzellAusserrhoden/AscensionDayTest.php
index b4d50a241..5697a3c43 100644
--- a/tests/Switzerland/AppenzellAusserrhoden/AscensionDayTest.php
+++ b/tests/Switzerland/AppenzellAusserrhoden/AscensionDayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OTHER);
}
/**
* Tests if all observed holidays in Appenzell Innerrhoden (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -74,7 +75,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Appenzell Innerrhoden (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -83,7 +84,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Appenzell Innerrhoden (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -92,7 +93,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Appenzell Innerrhoden (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -102,7 +103,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1945);
}
diff --git a/tests/Switzerland/AppenzellInnerrhoden/AscensionDayTest.php b/tests/Switzerland/AppenzellInnerrhoden/AscensionDayTest.php
index 599e704e5..6b14c6adc 100644
--- a/tests/Switzerland/AppenzellInnerrhoden/AscensionDayTest.php
+++ b/tests/Switzerland/AppenzellInnerrhoden/AscensionDayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OTHER);
}
/**
* Tests if all observed holidays in BaselLandschaft (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -71,7 +72,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in BaselLandschaft (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -80,7 +81,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in BaselLandschaft (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -89,7 +90,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in BaselLandschaft (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -99,7 +100,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1945);
}
diff --git a/tests/Switzerland/BaselLandschaft/ChristmasDayTest.php b/tests/Switzerland/BaselLandschaft/ChristmasDayTest.php
index 8fca557d6..24604fdca 100644
--- a/tests/Switzerland/BaselLandschaft/ChristmasDayTest.php
+++ b/tests/Switzerland/BaselLandschaft/ChristmasDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear();
- $date = new DateTime("$year-5-1", new DateTimeZone(self::TIMEZONE));
+ $year = $this->generateRandomYear();
+ $date = new DateTime("$year-5-1", new DateTimeZone(self::TIMEZONE));
$data[] = [$year, $date->format('Y-m-d')];
}
@@ -65,7 +67,7 @@ public function HolidayDataProvider(): array
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -79,7 +81,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Switzerland/BaselStadt/AscensionDayTest.php b/tests/Switzerland/BaselStadt/AscensionDayTest.php
index 26ba32905..64440e5b3 100644
--- a/tests/Switzerland/BaselStadt/AscensionDayTest.php
+++ b/tests/Switzerland/BaselStadt/AscensionDayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OTHER);
}
/**
* Tests if all observed holidays in Basel Stadt (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -71,7 +72,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Basel Stadt (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -80,7 +81,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Basel Stadt (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -89,7 +90,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Basel Stadt (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -99,7 +100,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1945);
}
diff --git a/tests/Switzerland/BaselStadt/ChristmasDayTest.php b/tests/Switzerland/BaselStadt/ChristmasDayTest.php
index e0c89c661..1b000b644 100644
--- a/tests/Switzerland/BaselStadt/ChristmasDayTest.php
+++ b/tests/Switzerland/BaselStadt/ChristmasDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear();
- $date = new DateTime("$year-5-1", new DateTimeZone(self::TIMEZONE));
+ $year = $this->generateRandomYear();
+ $date = new DateTime("$year-5-1", new DateTimeZone(self::TIMEZONE));
$data[] = [$year, $date->format('Y-m-d')];
}
@@ -65,7 +67,7 @@ public function HolidayDataProvider(): array
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -79,7 +81,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Switzerland/Bern/AscensionDayTest.php b/tests/Switzerland/Bern/AscensionDayTest.php
index b9008a546..b54cd8c6a 100644
--- a/tests/Switzerland/Bern/AscensionDayTest.php
+++ b/tests/Switzerland/Bern/AscensionDayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OTHER);
}
/**
* Tests if all observed holidays in Bern (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -71,7 +72,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Bern (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -80,7 +81,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Bern (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -89,7 +90,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Bern (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -99,7 +100,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1945);
}
diff --git a/tests/Switzerland/Bern/ChristmasDayTest.php b/tests/Switzerland/Bern/ChristmasDayTest.php
index d95cbea52..0ffda6983 100644
--- a/tests/Switzerland/Bern/ChristmasDayTest.php
+++ b/tests/Switzerland/Bern/ChristmasDayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OTHER);
}
/**
* Tests if all observed holidays in Fribourg (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -69,7 +70,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Fribourg (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -78,7 +79,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Fribourg (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -87,7 +88,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Fribourg (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -97,7 +98,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1945);
}
diff --git a/tests/Switzerland/Fribourg/GoodFridayTest.php b/tests/Switzerland/Fribourg/GoodFridayTest.php
index 3a7455cd8..505719550 100644
--- a/tests/Switzerland/Fribourg/GoodFridayTest.php
+++ b/tests/Switzerland/Fribourg/GoodFridayTest.php
@@ -1,4 +1,4 @@
-year = $this->generateRandomYear(1945);
}
diff --git a/tests/Switzerland/Geneva/GoodFridayTest.php b/tests/Switzerland/Geneva/GoodFridayTest.php
index 15fa98fd2..27f76dc44 100644
--- a/tests/Switzerland/Geneva/GoodFridayTest.php
+++ b/tests/Switzerland/Geneva/GoodFridayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OTHER);
}
/**
* Tests if all observed holidays in Glarus (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -73,7 +74,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Glarus (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -82,7 +83,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Glarus (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -91,7 +92,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Glarus (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -101,7 +102,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1945);
}
diff --git a/tests/Switzerland/Glarus/GoodFridayTest.php b/tests/Switzerland/Glarus/GoodFridayTest.php
index 587fe53e3..f6a27eeb3 100644
--- a/tests/Switzerland/Glarus/GoodFridayTest.php
+++ b/tests/Switzerland/Glarus/GoodFridayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OTHER);
}
/**
* Tests if all observed holidays in Grisons (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -70,7 +71,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Grisons (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -79,7 +80,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Grisons (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -88,7 +89,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Grisons (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -98,7 +99,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1945);
}
diff --git a/tests/Switzerland/Grisons/NewYearsDayTest.php b/tests/Switzerland/Grisons/NewYearsDayTest.php
index bc4079d29..c88a8a7f0 100644
--- a/tests/Switzerland/Grisons/NewYearsDayTest.php
+++ b/tests/Switzerland/Grisons/NewYearsDayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OTHER);
}
/**
* Tests if all observed holidays in Jura (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -75,7 +76,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Jura (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -84,7 +85,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Jura (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -93,7 +94,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Jura (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -103,7 +104,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1975);
}
diff --git a/tests/Switzerland/Jura/NewYearsDayTest.php b/tests/Switzerland/Jura/NewYearsDayTest.php
index 017e2a4b2..3962eee59 100644
--- a/tests/Switzerland/Jura/NewYearsDayTest.php
+++ b/tests/Switzerland/Jura/NewYearsDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear();
- $date = new DateTime("$year-5-1", new DateTimeZone(self::TIMEZONE));
+ $year = $this->generateRandomYear();
+ $date = new DateTime("$year-5-1", new DateTimeZone(self::TIMEZONE));
$data[] = [$year, $date->format('Y-m-d')];
}
@@ -65,7 +67,7 @@ public function HolidayDataProvider(): array
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -79,7 +81,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Switzerland/Lucerne/AllSaintsDayTest.php b/tests/Switzerland/Lucerne/AllSaintsDayTest.php
index 4e1d37d98..73a175807 100644
--- a/tests/Switzerland/Lucerne/AllSaintsDayTest.php
+++ b/tests/Switzerland/Lucerne/AllSaintsDayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OTHER);
}
/**
* Tests if all observed holidays in Lucerne (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -75,7 +76,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Lucerne (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -84,7 +85,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Lucerne (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -93,7 +94,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Lucerne (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -103,7 +104,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1945);
}
diff --git a/tests/Switzerland/Lucerne/NewYearsDayTest.php b/tests/Switzerland/Lucerne/NewYearsDayTest.php
index eee351c8f..7a4b5c979 100644
--- a/tests/Switzerland/Lucerne/NewYearsDayTest.php
+++ b/tests/Switzerland/Lucerne/NewYearsDayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OTHER);
}
/**
* Tests if all observed holidays in Neuchatel (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -73,7 +74,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Neuchatel (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -82,7 +83,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Neuchatel (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -91,7 +92,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Neuchatel (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -101,7 +102,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1945);
}
diff --git a/tests/Switzerland/Neuchatel/NewYearsDayTest.php b/tests/Switzerland/Neuchatel/NewYearsDayTest.php
index efd18d79b..b10a229da 100644
--- a/tests/Switzerland/Neuchatel/NewYearsDayTest.php
+++ b/tests/Switzerland/Neuchatel/NewYearsDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear();
- $date = new DateTime("$year-5-1", new DateTimeZone(self::TIMEZONE));
+ $year = $this->generateRandomYear();
+ $date = new DateTime("$year-5-1", new DateTimeZone(self::TIMEZONE));
$data[] = [$year, $date->format('Y-m-d')];
}
@@ -65,7 +67,7 @@ public function HolidayDataProvider(): array
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -79,7 +81,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Switzerland/Nidwalden/AllSaintsDayTest.php b/tests/Switzerland/Nidwalden/AllSaintsDayTest.php
index fb2fb6643..0c63e4e59 100644
--- a/tests/Switzerland/Nidwalden/AllSaintsDayTest.php
+++ b/tests/Switzerland/Nidwalden/AllSaintsDayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OTHER);
}
/**
* Tests if all observed holidays in Nidwalden (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -75,7 +76,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Nidwalden (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -84,7 +85,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Nidwalden (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -93,7 +94,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Nidwalden (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -103,7 +104,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1945);
}
diff --git a/tests/Switzerland/Nidwalden/PentecostMondayTest.php b/tests/Switzerland/Nidwalden/PentecostMondayTest.php
index bd2510749..ec55aef57 100644
--- a/tests/Switzerland/Nidwalden/PentecostMondayTest.php
+++ b/tests/Switzerland/Nidwalden/PentecostMondayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OTHER);
}
/**
* Tests if all observed holidays in Obwalden (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -76,7 +77,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Obwalden (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -85,7 +86,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Obwalden (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -94,7 +95,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Obwalden (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -104,7 +105,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1945);
}
diff --git a/tests/Switzerland/Obwalden/PentecostMondayTest.php b/tests/Switzerland/Obwalden/PentecostMondayTest.php
index 3ad5c99b1..d710a7aeb 100644
--- a/tests/Switzerland/Obwalden/PentecostMondayTest.php
+++ b/tests/Switzerland/Obwalden/PentecostMondayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OTHER);
}
/**
* Tests if all observed holidays in Schaffhausen (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -72,7 +73,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Schaffhausen (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -81,7 +82,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Schaffhausen (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -90,7 +91,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Schaffhausen (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -100,7 +101,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1945);
}
diff --git a/tests/Switzerland/Schaffhausen/StStephensDayTest.php b/tests/Switzerland/Schaffhausen/StStephensDayTest.php
index 92154dd17..a3e2f2f40 100644
--- a/tests/Switzerland/Schaffhausen/StStephensDayTest.php
+++ b/tests/Switzerland/Schaffhausen/StStephensDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear();
- $date = new DateTime("$year-5-1", new DateTimeZone(self::TIMEZONE));
+ $year = $this->generateRandomYear();
+ $date = new DateTime("$year-5-1", new DateTimeZone(self::TIMEZONE));
$data[] = [$year, $date->format('Y-m-d')];
}
@@ -65,7 +67,7 @@ public function HolidayDataProvider(): array
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -79,7 +81,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Switzerland/Schwyz/AllSaintsDayTest.php b/tests/Switzerland/Schwyz/AllSaintsDayTest.php
index 7a138abf2..e62182f4e 100644
--- a/tests/Switzerland/Schwyz/AllSaintsDayTest.php
+++ b/tests/Switzerland/Schwyz/AllSaintsDayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OTHER);
}
/**
* Tests if all observed holidays in Schwyz (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -76,7 +77,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Schwyz (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -85,7 +86,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Schwyz (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -94,7 +95,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Schwyz (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -104,7 +105,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1945);
}
diff --git a/tests/Switzerland/Schwyz/StJosephDayTest.php b/tests/Switzerland/Schwyz/StJosephDayTest.php
index fa70f9eec..fdc98b49d 100644
--- a/tests/Switzerland/Schwyz/StJosephDayTest.php
+++ b/tests/Switzerland/Schwyz/StJosephDayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OTHER);
}
/**
* Tests if all observed holidays in Solothurn (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -69,7 +70,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Solothurn (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -78,7 +79,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Solothurn (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -87,7 +88,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Solothurn (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -97,7 +98,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1945);
}
diff --git a/tests/Switzerland/StGallen/AllSaintsDayTest.php b/tests/Switzerland/StGallen/AllSaintsDayTest.php
index c304112f4..5a72db48a 100644
--- a/tests/Switzerland/StGallen/AllSaintsDayTest.php
+++ b/tests/Switzerland/StGallen/AllSaintsDayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OTHER);
}
/**
* Tests if all observed holidays in St. Gallen (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -71,7 +72,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in St. Gallen (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -80,7 +81,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in St. Gallen (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -89,7 +90,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in St. Gallen (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -99,7 +100,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1945);
}
diff --git a/tests/Switzerland/StGallen/StStephensDayTest.php b/tests/Switzerland/StGallen/StStephensDayTest.php
index 8471ab718..a708e135e 100644
--- a/tests/Switzerland/StGallen/StStephensDayTest.php
+++ b/tests/Switzerland/StGallen/StStephensDayTest.php
@@ -1,4 +1,4 @@
-year = $this->generateRandomYear(1945);
}
diff --git a/tests/Switzerland/Thurgau/AscensionDayTest.php b/tests/Switzerland/Thurgau/AscensionDayTest.php
index 94e86652e..5684c6ace 100644
--- a/tests/Switzerland/Thurgau/AscensionDayTest.php
+++ b/tests/Switzerland/Thurgau/AscensionDayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OTHER);
}
/**
* Tests if all observed holidays in Thurgau (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -72,7 +73,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Thurgau (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -81,7 +82,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Thurgau (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -90,7 +91,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Thurgau (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -100,7 +101,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1945);
}
diff --git a/tests/Switzerland/Thurgau/WorkersDayTest.php b/tests/Switzerland/Thurgau/WorkersDayTest.php
index fb9203023..9b7c71fad 100644
--- a/tests/Switzerland/Thurgau/WorkersDayTest.php
+++ b/tests/Switzerland/Thurgau/WorkersDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear();
- $date = new DateTime("$year-5-1", new DateTimeZone(self::TIMEZONE));
+ $year = $this->generateRandomYear();
+ $date = new DateTime("$year-5-1", new DateTimeZone(self::TIMEZONE));
$data[] = [$year, $date->format('Y-m-d')];
}
@@ -65,7 +67,7 @@ public function HolidayDataProvider(): array
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -79,7 +81,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Switzerland/Ticino/AllSaintsDayTest.php b/tests/Switzerland/Ticino/AllSaintsDayTest.php
index 4fcb01d7d..d8ac06566 100644
--- a/tests/Switzerland/Ticino/AllSaintsDayTest.php
+++ b/tests/Switzerland/Ticino/AllSaintsDayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OTHER);
}
/**
* Tests if all observed holidays in Ticino (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -77,7 +78,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Ticino (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -86,7 +87,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Ticino (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -95,7 +96,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Ticino (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -105,7 +106,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1945);
}
diff --git a/tests/Switzerland/Ticino/WorkersDayTest.php b/tests/Switzerland/Ticino/WorkersDayTest.php
index ad7b04c10..71101fdaa 100644
--- a/tests/Switzerland/Ticino/WorkersDayTest.php
+++ b/tests/Switzerland/Ticino/WorkersDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear();
- $date = new DateTime("$year-5-1", new DateTimeZone(self::TIMEZONE));
+ $year = $this->generateRandomYear();
+ $date = new DateTime("$year-5-1", new DateTimeZone(self::TIMEZONE));
$data[] = [$year, $date->format('Y-m-d')];
}
@@ -65,7 +67,7 @@ public function HolidayDataProvider(): array
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -79,7 +81,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Switzerland/Uri/AllSaintsDayTest.php b/tests/Switzerland/Uri/AllSaintsDayTest.php
index 1220e627a..5daabb77c 100644
--- a/tests/Switzerland/Uri/AllSaintsDayTest.php
+++ b/tests/Switzerland/Uri/AllSaintsDayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OTHER);
}
/**
* Tests if all observed holidays in Uri (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -76,7 +77,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Uri (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -85,7 +86,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Uri (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -94,7 +95,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Uri (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -104,7 +105,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1945);
}
diff --git a/tests/Switzerland/Valais/AllSaintsDayTest.php b/tests/Switzerland/Valais/AllSaintsDayTest.php
index c6e869f56..959110522 100644
--- a/tests/Switzerland/Valais/AllSaintsDayTest.php
+++ b/tests/Switzerland/Valais/AllSaintsDayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OTHER);
}
/**
* Tests if all observed holidays in Valais (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -71,7 +72,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Valais (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -80,7 +81,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Valais (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -89,7 +90,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Valais (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -99,7 +100,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1945);
}
diff --git a/tests/Switzerland/Vaud/AscensionDayTest.php b/tests/Switzerland/Vaud/AscensionDayTest.php
index fac6c7579..cd1c86ac2 100644
--- a/tests/Switzerland/Vaud/AscensionDayTest.php
+++ b/tests/Switzerland/Vaud/AscensionDayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OTHER);
}
/**
* Tests if all observed holidays in Vaud (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -71,7 +72,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Vaud (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -80,7 +81,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Vaud (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -89,7 +90,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Vaud (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -99,7 +100,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1945);
}
diff --git a/tests/Switzerland/Zug/AllSaintsDayTest.php b/tests/Switzerland/Zug/AllSaintsDayTest.php
index 7a0e23ccc..c1c954f2f 100644
--- a/tests/Switzerland/Zug/AllSaintsDayTest.php
+++ b/tests/Switzerland/Zug/AllSaintsDayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OTHER);
}
/**
* Tests if all observed holidays in Zug (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -75,7 +76,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Zug (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -84,7 +85,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Zug (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -93,7 +94,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Zug (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -103,7 +104,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1945);
}
diff --git a/tests/Switzerland/Zurich/AscensionDayTest.php b/tests/Switzerland/Zurich/AscensionDayTest.php
index 2f7de222b..7bee91426 100644
--- a/tests/Switzerland/Zurich/AscensionDayTest.php
+++ b/tests/Switzerland/Zurich/AscensionDayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear();
- $date = new DateTime("$year-5-1", new DateTimeZone(self::TIMEZONE));
+ $year = $this->generateRandomYear();
+ $date = new DateTime("$year-5-1", new DateTimeZone(self::TIMEZONE));
$data[] = [$year, $date->format('Y-m-d')];
}
@@ -65,7 +67,7 @@ public function HolidayDataProvider(): array
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -79,7 +81,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/Switzerland/Zurich/ZurichBaseTestCase.php b/tests/Switzerland/Zurich/ZurichBaseTestCase.php
index 4293533bf..7a97d7ab9 100644
--- a/tests/Switzerland/Zurich/ZurichBaseTestCase.php
+++ b/tests/Switzerland/Zurich/ZurichBaseTestCase.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OTHER);
}
/**
* Tests if all observed holidays in Zurich (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -72,7 +73,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in Zurich (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -81,7 +82,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in Zurich (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -90,7 +91,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in Zurich (Switzerland) are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -100,7 +101,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1945);
}
diff --git a/tests/USA/ChristmasDayTest.php b/tests/USA/ChristmasDayTest.php
index b2bb5156e..b74a875f6 100644
--- a/tests/USA/ChristmasDayTest.php
+++ b/tests/USA/ChristmasDayTest.php
@@ -1,4 +1,4 @@
-assertHoliday(
self::REGION,
@@ -78,7 +80,7 @@ public function testNewYearsDaySubstitutedFriday()
/**
* Tests translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -92,7 +94,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/USA/ThanksgivingDayTest.php b/tests/USA/ThanksgivingDayTest.php
index 20a0b34fd..6c3d30f7a 100644
--- a/tests/USA/ThanksgivingDayTest.php
+++ b/tests/USA/ThanksgivingDayTest.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_OFFICIAL);
}
/**
* Tests if all observed holidays in the USA are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testObservedHolidays(): void
{
@@ -55,7 +56,7 @@ public function testObservedHolidays(): void
/**
* Tests if all seasonal holidays in the USA are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testSeasonalHolidays(): void
{
@@ -64,7 +65,7 @@ public function testSeasonalHolidays(): void
/**
* Tests if all bank holidays in the USA are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testBankHolidays(): void
{
@@ -73,7 +74,7 @@ public function testBankHolidays(): void
/**
* Tests if all other holidays in the USA are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -83,7 +84,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1986);
}
diff --git a/tests/USA/VeteransDayTest.php b/tests/USA/VeteransDayTest.php
index 0f8dcac34..e5a3564e9 100644
--- a/tests/USA/VeteransDayTest.php
+++ b/tests/USA/VeteransDayTest.php
@@ -1,4 +1,4 @@
-assertHoliday(
+ self::REGION,
+ 'substituteHoliday:veteransDay',
+ $year,
+ new DateTime("$year-11-12", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests Veterans Day on or after 1919 when substituted on Friday (when Veterans Day falls on Saturday)
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testVeteransDayOnAfter1919SubstitutedFriday()
+ {
+ $year = 2017;
+ $this->assertHoliday(
+ self::REGION,
+ 'substituteHoliday:veteransDay',
+ $year,
+ new DateTime("$year-11-10", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
/**
* Tests Veterans Day before 1919. Veterans Day was established in 1919 on November 11.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testVeteransDayBefore1919()
{
@@ -64,33 +98,33 @@ public function testVeteransDayBefore1919()
/**
* Tests name of Veterans Day before 1954. Veterans Day was named 'Armistice Day' before 1954.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testVeteransDayNameBefore1954()
{
$year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR, 1953);
$holidays = Yasumi::create(self::REGION, $year);
- $holiday = $holidays->getHoliday(self::HOLIDAY);
+ $holiday = $holidays->getHoliday(self::HOLIDAY);
$this->assertEquals('Armistice Day', $holiday->getName());
}
/**
* Tests name of Veterans Day after 1954. Veterans Day was named 'Armistice Day' before 1954.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testVeteransDayNameAfter1954()
{
$year = $this->generateRandomYear(1954);
$holidays = Yasumi::create(self::REGION, $year);
- $holiday = $holidays->getHoliday(self::HOLIDAY);
+ $holiday = $holidays->getHoliday(self::HOLIDAY);
$this->assertEquals('Veterans Day', $holiday->getName());
}
/**
* Tests translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -104,7 +138,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/USA/WashingtonsBirthdayTest.php b/tests/USA/WashingtonsBirthdayTest.php
index 5ce977125..95cff15b0 100644
--- a/tests/USA/WashingtonsBirthdayTest.php
+++ b/tests/USA/WashingtonsBirthdayTest.php
@@ -1,4 +1,4 @@
-year = $this->generateRandomYear(2015, 2025);
}
diff --git a/tests/Ukraine/VictoryDayTest.php b/tests/Ukraine/VictoryDayTest.php
index d08286646..b0f84fcd6 100644
--- a/tests/Ukraine/VictoryDayTest.php
+++ b/tests/Ukraine/VictoryDayTest.php
@@ -1,4 +1,4 @@
-
+ */
+
+namespace Yasumi\tests\UnitedKingdom\England;
+
+use DateInterval;
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing Boxing Day in England.
+ */
+class BoxingDayTest extends EnglandBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'secondChristmasDay';
+
+ /**
+ * Tests the holiday defined in this test.
+ *
+ * @dataProvider HolidayDataProvider
+ *
+ * @param int $year the year for which the holiday defined in this test needs to be tested
+ * @param string $expected the expected date
+ *
+ * @throws ReflectionException
+ * @throws Exception
+ */
+ public function testHoliday($year, $expected)
+ {
+ $date = new DateTime($expected, new DateTimeZone(self::TIMEZONE));
+ $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $date);
+
+ if (\in_array((int)$date->format('w'), [0, 6], true)) {
+ $date->add(new DateInterval('P2D'));
+ $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date);
+ $this->assertHolidayType(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, Holiday::TYPE_BANK);
+ }
+ }
+
+ /**
+ * Returns a list of test dates
+ *
+ * @return array list of test dates for the holiday defined in this test
+ * @throws Exception
+ */
+ public function HolidayDataProvider(): array
+ {
+ $data = [];
+
+ for ($y = 0; $y < self::TEST_ITERATIONS; $y++) {
+ $year = $this->generateRandomYear();
+ $date = new DateTime("$year-12-26", new DateTimeZone(self::TIMEZONE));
+
+ $data[] = [$year, $date->format('Y-m-d')];
+ }
+
+ return $data;
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(),
+ [self::LOCALE => 'Boxing Day']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_BANK);
+ }
+}
diff --git a/tests/UnitedKingdom/England/ChristmasDayTest.php b/tests/UnitedKingdom/England/ChristmasDayTest.php
new file mode 100644
index 000000000..c416252e1
--- /dev/null
+++ b/tests/UnitedKingdom/England/ChristmasDayTest.php
@@ -0,0 +1,98 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\England;
+
+use DateInterval;
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing Christmas Day in England.
+ */
+class ChristmasDayTest extends EnglandBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'christmasDay';
+
+ /**
+ * Tests the holiday defined in this test.
+ *
+ * @dataProvider HolidayDataProvider
+ *
+ * @param int $year the year for which the holiday defined in this test needs to be tested
+ * @param string $expected the expected date
+ *
+ * @throws ReflectionException
+ * @throws Exception
+ */
+ public function testHoliday($year, $expected)
+ {
+ $date = new DateTime($expected, new DateTimeZone(self::TIMEZONE));
+ $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $date);
+
+ if (\in_array((int)$date->format('w'), [0, 6], true)) {
+ $date->add(new DateInterval('P2D'));
+ $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date);
+ $this->assertHolidayType(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, Holiday::TYPE_BANK);
+ }
+ }
+
+ /**
+ * Returns a list of test dates
+ *
+ * @return array list of test dates for the holiday defined in this test
+ * @throws Exception
+ */
+ public function HolidayDataProvider(): array
+ {
+ $data = [];
+
+ for ($y = 0; $y < self::TEST_ITERATIONS; $y++) {
+ $year = $this->generateRandomYear();
+ $date = new DateTime("$year-12-25", new DateTimeZone(self::TIMEZONE));
+
+ $data[] = [$year, $date->format('Y-m-d')];
+ }
+
+ return $data;
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(),
+ [self::LOCALE => 'Christmas Day']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL);
+ }
+}
diff --git a/tests/UnitedKingdom/England/EasterMondayTest.php b/tests/UnitedKingdom/England/EasterMondayTest.php
new file mode 100644
index 000000000..4c0570255
--- /dev/null
+++ b/tests/UnitedKingdom/England/EasterMondayTest.php
@@ -0,0 +1,97 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\England;
+
+use DateInterval;
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing Easter Monday in England.
+ */
+class EasterMondayTest extends EnglandBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'easterMonday';
+
+ /**
+ * Tests Easter Monday
+ *
+ * @dataProvider HolidayDataProvider
+ *
+ * @param int $year the year for which the holiday defined in this test needs to be tested
+ * @param string $expected the expected date
+ *
+ * @throws ReflectionException
+ * @throws Exception
+ */
+ public function testHoliday($year, $expected)
+ {
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime($expected, new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Returns a list of test dates
+ *
+ * @return array list of test dates for the holiday defined in this test
+ * @throws Exception
+ */
+ public function HolidayDataProvider(): array
+ {
+ $data = [];
+
+ for ($y = 0; $y < 50; $y++) {
+ $year = $this->generateRandomYear();
+ $date = $this->calculateEaster($year, self::TIMEZONE);
+ $date->add(new DateInterval('P1D'));
+
+ $data[] = [$year, $date->format('Y-m-d')];
+ }
+
+ return $data;
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(),
+ [self::LOCALE => 'Easter Monday']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_BANK);
+ }
+}
diff --git a/tests/UnitedKingdom/England/EnglandBaseTestCase.php b/tests/UnitedKingdom/England/EnglandBaseTestCase.php
new file mode 100644
index 000000000..bb600ae66
--- /dev/null
+++ b/tests/UnitedKingdom/England/EnglandBaseTestCase.php
@@ -0,0 +1,44 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\England;
+
+use Yasumi\tests\UnitedKingdom\UnitedKingdomBaseTestCase;
+use Yasumi\tests\YasumiBase;
+
+/**
+ * Base class for test cases of the England holiday provider.
+ */
+abstract class EnglandBaseTestCase extends UnitedKingdomBaseTestCase
+{
+ use YasumiBase;
+
+ /**
+ * Name of the region (e.g. country / state) to be tested
+ */
+ public const REGION = 'UnitedKingdom\England';
+
+ /**
+ * Timezone in which this provider has holidays defined
+ */
+ public const TIMEZONE = 'Europe/London';
+
+ /**
+ * Locale that is considered common for this provider
+ */
+ public const LOCALE = 'en_GB';
+
+ /**
+ * Number of iterations to be used for the various unit tests of this provider
+ */
+ public const TEST_ITERATIONS = 50;
+}
diff --git a/tests/UnitedKingdom/England/EnglandTest.php b/tests/UnitedKingdom/England/EnglandTest.php
new file mode 100644
index 000000000..35366f83e
--- /dev/null
+++ b/tests/UnitedKingdom/England/EnglandTest.php
@@ -0,0 +1,89 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\England;
+
+use ReflectionException;
+use Yasumi\Holiday;
+
+/**
+ * Class for testing holidays in England.
+ */
+class EnglandTest extends EnglandBaseTestCase
+{
+ /**
+ * @var int year random year number used for all tests in this Test Case
+ */
+ protected $year;
+
+ /**
+ * Tests if all official holidays in England are defined by the provider class
+ * @throws ReflectionException
+ */
+ public function testOfficialHolidays(): void
+ {
+ $this->assertDefinedHolidays([
+ 'goodFriday',
+ 'christmasDay',
+ ], self::REGION, $this->year, Holiday::TYPE_OFFICIAL);
+ }
+
+ /**
+ * Tests if all observed holidays in England are defined by the provider class
+ * @throws ReflectionException
+ */
+ public function testObservedHolidays(): void
+ {
+ $this->assertDefinedHolidays([], self::REGION, $this->year, Holiday::TYPE_OBSERVANCE);
+ }
+
+ /**
+ * Tests if all seasonal holidays in England are defined by the provider class
+ * @throws ReflectionException
+ */
+ public function testSeasonalHolidays(): void
+ {
+ $this->assertDefinedHolidays([], self::REGION, $this->year, Holiday::TYPE_SEASON);
+ }
+
+ /**
+ * Tests if all bank holidays in England are defined by the provider class
+ * @throws ReflectionException
+ */
+ public function testBankHolidays(): void
+ {
+ $this->assertDefinedHolidays([
+ 'newYearsDay',
+ 'easterMonday',
+ 'mayDayBankHoliday',
+ 'springBankHoliday',
+ 'secondChristmasDay',
+ ], self::REGION, $this->year, Holiday::TYPE_BANK);
+ }
+
+ /**
+ * Tests if all other holidays in England are defined by the provider class
+ * @throws ReflectionException
+ */
+ public function testOtherHolidays(): void
+ {
+ $this->assertDefinedHolidays([], self::REGION, $this->year, Holiday::TYPE_OTHER);
+ }
+
+ /**
+ * Initial setup of this Test Case
+ */
+ protected function setUp(): void
+ {
+ $this->year = $this->generateRandomYear(1978);
+ }
+}
diff --git a/tests/UnitedKingdom/England/GoodFridayTest.php b/tests/UnitedKingdom/England/GoodFridayTest.php
new file mode 100644
index 000000000..ca21008bf
--- /dev/null
+++ b/tests/UnitedKingdom/England/GoodFridayTest.php
@@ -0,0 +1,70 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\England;
+
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class containing tests for Good Friday in England.
+ */
+class GoodFridayTest extends EnglandBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday to be tested
+ */
+ public const HOLIDAY = 'goodFriday';
+
+ /**
+ * Tests the holiday defined in this test.
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testHoliday()
+ {
+ $year = 1866;
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime("$year-3-30", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(),
+ [self::LOCALE => 'Good Friday']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL);
+ }
+}
diff --git a/tests/UnitedKingdom/England/MayDayBankHolidayTest.php b/tests/UnitedKingdom/England/MayDayBankHolidayTest.php
new file mode 100644
index 000000000..3ced29d35
--- /dev/null
+++ b/tests/UnitedKingdom/England/MayDayBankHolidayTest.php
@@ -0,0 +1,117 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\England;
+
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing the May Day Bank Holiday in England.
+ */
+class MayDayBankHolidayTest extends EnglandBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'mayDayBankHoliday';
+
+ /**
+ * The year in which the holiday was first established
+ */
+ public const ESTABLISHMENT_YEAR = 1978;
+
+ /**
+ * Tests the holiday defined in this test.
+ *
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testHoliday()
+ {
+ $year = 2101;
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime("$year-5-2", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday exception in 1995 and 2020.
+ *
+ * @throws ReflectionException
+ * @throws Exception
+ */
+ public function testHolidayExceptions()
+ {
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 1995,
+ new DateTime('1995-5-8', new DateTimeZone(self::TIMEZONE))
+ );
+
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 2020,
+ new DateTime('2020-5-8', new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday defined in this test before establishment.
+ * @throws ReflectionException
+ */
+ public function testHolidayBeforeEstablishment()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ );
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ [self::LOCALE => 'May Day Bank Holiday']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ Holiday::TYPE_BANK
+ );
+ }
+}
diff --git a/tests/UnitedKingdom/England/NewYearsDayTest.php b/tests/UnitedKingdom/England/NewYearsDayTest.php
new file mode 100644
index 000000000..6149c5162
--- /dev/null
+++ b/tests/UnitedKingdom/England/NewYearsDayTest.php
@@ -0,0 +1,128 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\England;
+
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing New Years Day in England.
+ */
+class NewYearsDayTest extends EnglandBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The year in which the holiday was first established
+ */
+ public const ESTABLISHMENT_YEAR = 1871;
+
+ /**
+ * The year in which the holiday was adjusted
+ */
+ public const ADJUSTMENT_YEAR = 1974;
+
+ /**
+ * The name of the holiday to be tested
+ */
+ public const HOLIDAY = 'newYearsDay';
+
+ /**
+ * Tests the holiday defined in this test on or after establishment.
+ *
+ * @dataProvider HolidayDataProvider
+ *
+ * @param int $year the year for which the holiday defined in this test needs to be tested
+ * @param string $expected the expected date
+ *
+ * @throws ReflectionException
+ * @throws Exception
+ */
+ public function testHolidayOnAfterEstablishment($year, $expected)
+ {
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime($expected, new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday defined in this test before establishment.
+ * @throws ReflectionException
+ */
+ public function testHolidayBeforeEstablishment()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ );
+ }
+
+ /**
+ * Tests that the holiday defined in this test is of the type 'observance' before the year it was changed.
+ * @throws ReflectionException
+ */
+ public function testHolidayIsObservedTypeBeforeChange()
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR, self::ADJUSTMENT_YEAR - 1),
+ Holiday::TYPE_OBSERVANCE
+ );
+ }
+
+ /**
+ * Returns a list of random test dates used for assertion of the holiday defined in this test
+ *
+ * @return array list of test dates for the holiday defined in this test
+ * @throws Exception
+ */
+ public function HolidayDataProvider(): array
+ {
+ return $this->generateRandomDatesWithHolidayMovedToMonday(01, 01, self::TIMEZONE, 10, self::ESTABLISHMENT_YEAR);
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ [self::LOCALE => 'New Year\'s Day']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ADJUSTMENT_YEAR + 1),
+ Holiday::TYPE_BANK
+ );
+ }
+}
diff --git a/tests/UnitedKingdom/England/SpringBankHolidayTest.php b/tests/UnitedKingdom/England/SpringBankHolidayTest.php
new file mode 100644
index 000000000..560b3fe6a
--- /dev/null
+++ b/tests/UnitedKingdom/England/SpringBankHolidayTest.php
@@ -0,0 +1,117 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\England;
+
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing the Spring Bank Holiday in England.
+ */
+class SpringBankHolidayTest extends EnglandBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'springBankHoliday';
+
+ /**
+ * The year in which the holiday was first established
+ */
+ public const ESTABLISHMENT_YEAR = 1965;
+
+ /**
+ * Tests the holiday defined in this test.
+ *
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testHoliday()
+ {
+ $year = 1988;
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime("$year-5-30", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday exceptions in 2002 and 2012.
+ *
+ * @throws ReflectionException
+ * @throws Exception
+ */
+ public function testHolidayException()
+ {
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 2002,
+ new DateTime('2002-6-4', new DateTimeZone(self::TIMEZONE))
+ );
+
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 2012,
+ new DateTime('2012-6-4', new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday defined in this test before establishment.
+ * @throws ReflectionException
+ */
+ public function testHolidayBeforeEstablishment()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ );
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ [self::LOCALE => 'Spring Bank Holiday']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ Holiday::TYPE_BANK
+ );
+ }
+}
diff --git a/tests/UnitedKingdom/England/SummerBankHolidayTest.php b/tests/UnitedKingdom/England/SummerBankHolidayTest.php
new file mode 100644
index 000000000..888deb764
--- /dev/null
+++ b/tests/UnitedKingdom/England/SummerBankHolidayTest.php
@@ -0,0 +1,173 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\England;
+
+use DateTime;
+use DateTimeZone;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing the Summer Bank Holiday England.
+ */
+class SummerBankHolidayTest extends EnglandBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'summerBankHoliday';
+
+ /**
+ * The year in which the holiday was first established
+ */
+ public const ESTABLISHMENT_YEAR = 1871;
+
+ /**
+ * The year in which the holiday was renamed from August Bank Holiday to Summer Bank Holiday.
+ */
+ public const RENAME_YEAR = 1965;
+
+ /**
+ * Tests the holiday defined in this test.
+ * @throws \Exception
+ * @throws \ReflectionException
+ */
+ public function testHoliday()
+ {
+ $year = $this->generateRandomYear(1970);
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime("last monday of august $year", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday exception in 2020.
+ *
+ * @throws \Exception
+ * @throws \ReflectionException
+ */
+ public function testHolidayBefore1965()
+ {
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR, 1964);
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime("first monday of august $year", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday during trial period in 1965-1970.
+ *
+ * @throws \ReflectionException
+ * @throws \Exception
+ */
+ public function testHolidayTrialPeriod()
+ {
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 1965,
+ new DateTime('1965-8-30', new DateTimeZone(self::TIMEZONE))
+ );
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 1966,
+ new DateTime('1966-8-29', new DateTimeZone(self::TIMEZONE))
+ );
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 1967,
+ new DateTime('1967-8-28', new DateTimeZone(self::TIMEZONE))
+ );
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 1968,
+ new DateTime('1968-9-2', new DateTimeZone(self::TIMEZONE))
+ );
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 1969,
+ new DateTime('1969-9-1', new DateTimeZone(self::TIMEZONE))
+ );
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 1970,
+ new DateTime('1970-8-31', new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday defined in this test before establishment.
+ * @throws \ReflectionException
+ */
+ public function testHolidayBeforeEstablishment()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ );
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws \ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::RENAME_YEAR),
+ [self::LOCALE => 'Summer Bank Holiday']
+ );
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws \ReflectionException
+ */
+ public function testTranslationBeforeRename(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR, self::RENAME_YEAR - 1),
+ [self::LOCALE => 'August Bank Holiday']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws \ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ Holiday::TYPE_BANK
+ );
+ }
+}
diff --git a/tests/UnitedKingdom/GoodFridayTest.php b/tests/UnitedKingdom/GoodFridayTest.php
index 4f573581a..2221ffd76 100644
--- a/tests/UnitedKingdom/GoodFridayTest.php
+++ b/tests/UnitedKingdom/GoodFridayTest.php
@@ -1,4 +1,4 @@
-assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 1995,
+ new DateTime('1995-5-8', new DateTimeZone(self::TIMEZONE))
+ );
+
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 2020,
+ new DateTime('2020-5-8', new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
/**
* Tests the holiday defined in this test before establishment.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayBeforeEstablishment()
{
@@ -63,7 +87,7 @@ public function testHolidayBeforeEstablishment()
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -77,7 +101,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/UnitedKingdom/NewYearsDayTest.php b/tests/UnitedKingdom/NewYearsDayTest.php
index 725172893..a44cc17bf 100644
--- a/tests/UnitedKingdom/NewYearsDayTest.php
+++ b/tests/UnitedKingdom/NewYearsDayTest.php
@@ -1,4 +1,4 @@
-assertHolidayType(
self::REGION,
self::HOLIDAY,
- $this->generateRandomYear(self::ADJUSTMENT_YEAR),
+ $this->generateRandomYear(self::ADJUSTMENT_YEAR + 1),
Holiday::TYPE_BANK
);
}
diff --git a/tests/UnitedKingdom/NorthernIreland/BattleOfTheBoyneTest.php b/tests/UnitedKingdom/NorthernIreland/BattleOfTheBoyneTest.php
new file mode 100644
index 000000000..766d6bd15
--- /dev/null
+++ b/tests/UnitedKingdom/NorthernIreland/BattleOfTheBoyneTest.php
@@ -0,0 +1,119 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\NorthernIreland;
+
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing Batthe of the Boyne in Northern Ireland.
+ */
+class BattleOfTheBoyneTest extends NorthernIrelandBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday to be tested
+ */
+ public const HOLIDAY = 'battleOfTheBoyne';
+
+ /**
+ * The year in which the holiday was first established
+ */
+ public const ESTABLISHMENT_YEAR = 1926;
+
+ /**
+ * Tests the holiday defined in this test.
+ *
+ * @dataProvider HolidayDataProvider
+ *
+ * @param int $year the year for which the holiday defined in this test needs to be tested
+ * @param \DateTime $expected the expected date
+ *
+ * @throws ReflectionException
+ * @throws Exception
+ */
+ public function testHoliday($year, $expected)
+ {
+ $date = new DateTime($expected, new DateTimeZone(self::TIMEZONE));
+ $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $date);
+
+ if (\in_array((int)$date->format('w'), [0, 6], true)) {
+ $date->modify('next monday');
+ $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date);
+ }
+ }
+
+ /**
+ * Tests the holiday defined in this test before establishment.
+ * @throws ReflectionException
+ */
+ public function testHolidayBeforeEstablishment()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ );
+ }
+
+ /**
+ * Returns a list of random test dates used for assertion of the holiday defined in this test
+ *
+ * @return array list of test dates for the holiday defined in this test
+ * @throws Exception
+ */
+ public function HolidayDataProvider(): array
+ {
+ $data = [];
+
+ for ($y = 0; $y < self::TEST_ITERATIONS; $y++) {
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $date = new DateTime("$year-7-12", new DateTimeZone(self::TIMEZONE));
+ $data[] = [$year, $date->format('Y-m-d')];
+ }
+
+ return $data;
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ *
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ [self::LOCALE => 'Battle of the Boyne']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ Holiday::TYPE_BANK
+ );
+ }
+}
diff --git a/tests/UnitedKingdom/NorthernIreland/BoxingDayTest.php b/tests/UnitedKingdom/NorthernIreland/BoxingDayTest.php
new file mode 100644
index 000000000..42b4101ce
--- /dev/null
+++ b/tests/UnitedKingdom/NorthernIreland/BoxingDayTest.php
@@ -0,0 +1,98 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\NorthernIreland;
+
+use DateInterval;
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing Boxing Day in Northern Ireland.
+ */
+class BoxingDayTest extends NorthernIrelandBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'secondChristmasDay';
+
+ /**
+ * Tests the holiday defined in this test.
+ *
+ * @dataProvider HolidayDataProvider
+ *
+ * @param int $year the year for which the holiday defined in this test needs to be tested
+ * @param string $expected the expected date
+ *
+ * @throws ReflectionException
+ * @throws Exception
+ */
+ public function testHoliday($year, $expected)
+ {
+ $date = new DateTime($expected, new DateTimeZone(self::TIMEZONE));
+ $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $date);
+
+ if (\in_array((int)$date->format('w'), [0, 6], true)) {
+ $date->add(new DateInterval('P2D'));
+ $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date);
+ $this->assertHolidayType(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, Holiday::TYPE_BANK);
+ }
+ }
+
+ /**
+ * Returns a list of test dates
+ *
+ * @return array list of test dates for the holiday defined in this test
+ * @throws Exception
+ */
+ public function HolidayDataProvider(): array
+ {
+ $data = [];
+
+ for ($y = 0; $y < self::TEST_ITERATIONS; $y++) {
+ $year = $this->generateRandomYear();
+ $date = new DateTime("$year-12-26", new DateTimeZone(self::TIMEZONE));
+
+ $data[] = [$year, $date->format('Y-m-d')];
+ }
+
+ return $data;
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(),
+ [self::LOCALE => 'Boxing Day']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_BANK);
+ }
+}
diff --git a/tests/UnitedKingdom/NorthernIreland/ChristmasDayTest.php b/tests/UnitedKingdom/NorthernIreland/ChristmasDayTest.php
new file mode 100644
index 000000000..d5d393f71
--- /dev/null
+++ b/tests/UnitedKingdom/NorthernIreland/ChristmasDayTest.php
@@ -0,0 +1,98 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\NorthernIreland;
+
+use DateInterval;
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing Christmas Day in Northern Ireland.
+ */
+class ChristmasDayTest extends NorthernIrelandBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'christmasDay';
+
+ /**
+ * Tests the holiday defined in this test.
+ *
+ * @dataProvider HolidayDataProvider
+ *
+ * @param int $year the year for which the holiday defined in this test needs to be tested
+ * @param string $expected the expected date
+ *
+ * @throws ReflectionException
+ * @throws Exception
+ */
+ public function testHoliday($year, $expected)
+ {
+ $date = new DateTime($expected, new DateTimeZone(self::TIMEZONE));
+ $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $date);
+
+ if (\in_array((int)$date->format('w'), [0, 6], true)) {
+ $date->add(new DateInterval('P2D'));
+ $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date);
+ $this->assertHolidayType(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, Holiday::TYPE_BANK);
+ }
+ }
+
+ /**
+ * Returns a list of test dates
+ *
+ * @return array list of test dates for the holiday defined in this test
+ * @throws Exception
+ */
+ public function HolidayDataProvider(): array
+ {
+ $data = [];
+
+ for ($y = 0; $y < self::TEST_ITERATIONS; $y++) {
+ $year = $this->generateRandomYear();
+ $date = new DateTime("$year-12-25", new DateTimeZone(self::TIMEZONE));
+
+ $data[] = [$year, $date->format('Y-m-d')];
+ }
+
+ return $data;
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(),
+ [self::LOCALE => 'Christmas Day']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL);
+ }
+}
diff --git a/tests/UnitedKingdom/NorthernIreland/EasterMondayTest.php b/tests/UnitedKingdom/NorthernIreland/EasterMondayTest.php
new file mode 100644
index 000000000..39c215e4f
--- /dev/null
+++ b/tests/UnitedKingdom/NorthernIreland/EasterMondayTest.php
@@ -0,0 +1,97 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\NorthernIreland;
+
+use DateInterval;
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing Easter Monday in Northern Ireland.
+ */
+class EasterMondayTest extends NorthernIrelandBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'easterMonday';
+
+ /**
+ * Tests Easter Monday
+ *
+ * @dataProvider HolidayDataProvider
+ *
+ * @param int $year the year for which the holiday defined in this test needs to be tested
+ * @param string $expected the expected date
+ *
+ * @throws ReflectionException
+ * @throws Exception
+ */
+ public function testHoliday($year, $expected)
+ {
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime($expected, new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Returns a list of test dates
+ *
+ * @return array list of test dates for the holiday defined in this test
+ * @throws Exception
+ */
+ public function HolidayDataProvider(): array
+ {
+ $data = [];
+
+ for ($y = 0; $y < 50; $y++) {
+ $year = $this->generateRandomYear();
+ $date = $this->calculateEaster($year, self::TIMEZONE);
+ $date->add(new DateInterval('P1D'));
+
+ $data[] = [$year, $date->format('Y-m-d')];
+ }
+
+ return $data;
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(),
+ [self::LOCALE => 'Easter Monday']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_BANK);
+ }
+}
diff --git a/tests/UnitedKingdom/NorthernIreland/GoodFridayTest.php b/tests/UnitedKingdom/NorthernIreland/GoodFridayTest.php
new file mode 100644
index 000000000..9c9722fd6
--- /dev/null
+++ b/tests/UnitedKingdom/NorthernIreland/GoodFridayTest.php
@@ -0,0 +1,70 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\NorthernIreland;
+
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class containing tests for Good Friday in Northern Ireland.
+ */
+class GoodFridayTest extends NorthernIrelandBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday to be tested
+ */
+ public const HOLIDAY = 'goodFriday';
+
+ /**
+ * Tests the holiday defined in this test.
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testHoliday()
+ {
+ $year = 1866;
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime("$year-3-30", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(),
+ [self::LOCALE => 'Good Friday']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL);
+ }
+}
diff --git a/tests/UnitedKingdom/NorthernIreland/MayDayBankHolidayTest.php b/tests/UnitedKingdom/NorthernIreland/MayDayBankHolidayTest.php
new file mode 100644
index 000000000..08b38cc73
--- /dev/null
+++ b/tests/UnitedKingdom/NorthernIreland/MayDayBankHolidayTest.php
@@ -0,0 +1,116 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\NorthernIreland;
+
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing the May Day Bank Holiday in Northern Ireland.
+ */
+class MayDayBankHolidayTest extends NorthernIrelandBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'mayDayBankHoliday';
+
+ /**
+ * The year in which the holiday was first established
+ */
+ public const ESTABLISHMENT_YEAR = 1978;
+
+ /**
+ * Tests the holiday defined in this test.
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testHoliday()
+ {
+ $year = 2101;
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime("$year-5-2", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday exception in 1995 and 2020.
+ *
+ * @throws ReflectionException
+ * @throws Exception
+ */
+ public function testHolidayExceptions()
+ {
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 1995,
+ new DateTime('1995-5-8', new DateTimeZone(self::TIMEZONE))
+ );
+
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 2020,
+ new DateTime('2020-5-8', new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday defined in this test before establishment.
+ * @throws ReflectionException
+ */
+ public function testHolidayBeforeEstablishment()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ );
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ [self::LOCALE => 'May Day Bank Holiday']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ Holiday::TYPE_BANK
+ );
+ }
+}
diff --git a/tests/UnitedKingdom/NorthernIreland/NewYearsDayTest.php b/tests/UnitedKingdom/NorthernIreland/NewYearsDayTest.php
new file mode 100644
index 000000000..b46bd36dc
--- /dev/null
+++ b/tests/UnitedKingdom/NorthernIreland/NewYearsDayTest.php
@@ -0,0 +1,128 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\NorthernIreland;
+
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing New Years Day in Northern Ireland.
+ */
+class NewYearsDayTest extends NorthernIrelandBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The year in which the holiday was first established
+ */
+ public const ESTABLISHMENT_YEAR = 1871;
+
+ /**
+ * The year in which the holiday was adjusted
+ */
+ public const ADJUSTMENT_YEAR = 1974;
+
+ /**
+ * The name of the holiday to be tested
+ */
+ public const HOLIDAY = 'newYearsDay';
+
+ /**
+ * Tests the holiday defined in this test on or after establishment.
+ *
+ * @dataProvider HolidayDataProvider
+ *
+ * @param int $year the year for which the holiday defined in this test needs to be tested
+ * @param string $expected the expected date
+ *
+ * @throws ReflectionException
+ * @throws Exception
+ */
+ public function testHolidayOnAfterEstablishment($year, $expected)
+ {
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime($expected, new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday defined in this test before establishment.
+ * @throws ReflectionException
+ */
+ public function testHolidayBeforeEstablishment()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ );
+ }
+
+ /**
+ * Tests that the holiday defined in this test is of the type 'observance' before the year it was changed.
+ * @throws ReflectionException
+ */
+ public function testHolidayIsObservedTypeBeforeChange()
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR, self::ADJUSTMENT_YEAR - 1),
+ Holiday::TYPE_OBSERVANCE
+ );
+ }
+
+ /**
+ * Returns a list of random test dates used for assertion of the holiday defined in this test
+ *
+ * @return array list of test dates for the holiday defined in this test
+ * @throws Exception
+ */
+ public function HolidayDataProvider(): array
+ {
+ return $this->generateRandomDatesWithHolidayMovedToMonday(01, 01, self::TIMEZONE, 10, self::ESTABLISHMENT_YEAR);
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ [self::LOCALE => 'New Year\'s Day']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ADJUSTMENT_YEAR + 1),
+ Holiday::TYPE_BANK
+ );
+ }
+}
diff --git a/tests/UnitedKingdom/NorthernIreland/NorthernIrelandBaseTestCase.php b/tests/UnitedKingdom/NorthernIreland/NorthernIrelandBaseTestCase.php
new file mode 100644
index 000000000..01d690060
--- /dev/null
+++ b/tests/UnitedKingdom/NorthernIreland/NorthernIrelandBaseTestCase.php
@@ -0,0 +1,44 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\NorthernIreland;
+
+use Yasumi\tests\UnitedKingdom\UnitedKingdomBaseTestCase;
+use Yasumi\tests\YasumiBase;
+
+/**
+ * Base class for test cases of the Northern Ireland holiday provider.
+ */
+abstract class NorthernIrelandBaseTestCase extends UnitedKingdomBaseTestCase
+{
+ use YasumiBase;
+
+ /**
+ * Name of the region (e.g. country / state) to be tested
+ */
+ public const REGION = 'UnitedKingdom\NorthernIreland';
+
+ /**
+ * Timezone in which this provider has holidays defined
+ */
+ public const TIMEZONE = 'Europe/Belfast';
+
+ /**
+ * Locale that is considered common for this provider
+ */
+ public const LOCALE = 'en_GB';
+
+ /**
+ * Number of iterations to be used for the various unit tests of this provider
+ */
+ public const TEST_ITERATIONS = 50;
+}
diff --git a/tests/UnitedKingdom/NorthernIreland/NorthernIrelandTest.php b/tests/UnitedKingdom/NorthernIreland/NorthernIrelandTest.php
new file mode 100644
index 000000000..fb84414c1
--- /dev/null
+++ b/tests/UnitedKingdom/NorthernIreland/NorthernIrelandTest.php
@@ -0,0 +1,90 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\NorthernIreland;
+
+use ReflectionException;
+use Yasumi\Holiday;
+
+/**
+ * Class for testing holidays in Northern Ireland.
+ */
+class NorthernIrelandTest extends NorthernIrelandBaseTestCase
+{
+ /**
+ * @var int year random year number used for all tests in this Test Case
+ */
+ protected $year;
+
+ /**
+ * Tests if all official holidays in Northern Ireland are defined by the provider class
+ * @throws ReflectionException
+ */
+ public function testOfficialHolidays(): void
+ {
+ $this->assertDefinedHolidays([
+ 'goodFriday',
+ 'christmasDay',
+ ], self::REGION, $this->year, Holiday::TYPE_OFFICIAL);
+ }
+
+ /**
+ * Tests if all observed holidays in Northern Ireland are defined by the provider class
+ * @throws ReflectionException
+ */
+ public function testObservedHolidays(): void
+ {
+ $this->assertDefinedHolidays([], self::REGION, $this->year, Holiday::TYPE_OBSERVANCE);
+ }
+
+ /**
+ * Tests if all seasonal holidays in Northern Ireland are defined by the provider class
+ * @throws ReflectionException
+ */
+ public function testSeasonalHolidays(): void
+ {
+ $this->assertDefinedHolidays([], self::REGION, $this->year, Holiday::TYPE_SEASON);
+ }
+
+ /**
+ * Tests if all bank holidays in Northern Ireland are defined by the provider class
+ * @throws ReflectionException
+ */
+ public function testBankHolidays(): void
+ {
+ $this->assertDefinedHolidays([
+ 'newYearsDay',
+ 'easterMonday',
+ 'mayDayBankHoliday',
+ 'springBankHoliday',
+ 'battleOfTheBoyne',
+ 'secondChristmasDay',
+ ], self::REGION, $this->year, Holiday::TYPE_BANK);
+ }
+
+ /**
+ * Tests if all other holidays in Northern Ireland are defined by the provider class
+ * @throws ReflectionException
+ */
+ public function testOtherHolidays(): void
+ {
+ $this->assertDefinedHolidays([], self::REGION, $this->year, Holiday::TYPE_OTHER);
+ }
+
+ /**
+ * Initial setup of this Test Case
+ */
+ protected function setUp(): void
+ {
+ $this->year = $this->generateRandomYear(1978);
+ }
+}
diff --git a/tests/UnitedKingdom/NorthernIreland/SpringBankHolidayTest.php b/tests/UnitedKingdom/NorthernIreland/SpringBankHolidayTest.php
new file mode 100644
index 000000000..73aa13ef1
--- /dev/null
+++ b/tests/UnitedKingdom/NorthernIreland/SpringBankHolidayTest.php
@@ -0,0 +1,93 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\NorthernIreland;
+
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing the Spring Bank Holiday in Northern Ireland.
+ */
+class SpringBankHolidayTest extends NorthernIrelandBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'springBankHoliday';
+
+ /**
+ * The year in which the holiday was first established
+ */
+ public const ESTABLISHMENT_YEAR = 1965;
+
+ /**
+ * Tests the holiday defined in this test.
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testHoliday()
+ {
+ $year = 1988;
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime("$year-5-30", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday defined in this test before establishment.
+ * @throws ReflectionException
+ */
+ public function testHolidayBeforeEstablishment()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ );
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ [self::LOCALE => 'Spring Bank Holiday']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ Holiday::TYPE_BANK
+ );
+ }
+}
diff --git a/tests/UnitedKingdom/NorthernIreland/StPatricksDayTest.php b/tests/UnitedKingdom/NorthernIreland/StPatricksDayTest.php
new file mode 100644
index 000000000..835014044
--- /dev/null
+++ b/tests/UnitedKingdom/NorthernIreland/StPatricksDayTest.php
@@ -0,0 +1,119 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\NorthernIreland;
+
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing St. Patrick's Day in Northern Ireland.
+ */
+class StPatricksDayTest extends NorthernIrelandBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday to be tested
+ */
+ public const HOLIDAY = 'stPatricksDay';
+
+ /**
+ * The year in which the holiday was first established
+ */
+ public const ESTABLISHMENT_YEAR = 1971;
+
+ /**
+ * Tests the holiday defined in this test.
+ *
+ * @dataProvider HolidayDataProvider
+ *
+ * @param int $year the year for which the holiday defined in this test needs to be tested
+ * @param \DateTime $expected the expected date
+ *
+ * @throws ReflectionException
+ * @throws Exception
+ */
+ public function testHoliday($year, $expected)
+ {
+ $date = new DateTime($expected, new DateTimeZone(self::TIMEZONE));
+ $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $date);
+
+ if (\in_array((int)$date->format('w'), [0, 6], true)) {
+ $date->modify('next monday');
+ $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date);
+ }
+ }
+
+ /**
+ * Tests the holiday defined in this test before establishment.
+ * @throws ReflectionException
+ */
+ public function testHolidayBeforeEstablishment()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ );
+ }
+
+ /**
+ * Returns a list of random test dates used for assertion of the holiday defined in this test
+ *
+ * @return array list of test dates for the holiday defined in this test
+ * @throws Exception
+ */
+ public function HolidayDataProvider(): array
+ {
+ $data = [];
+
+ for ($y = 0; $y < self::TEST_ITERATIONS; $y++) {
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $date = new DateTime("$year-3-17", new DateTimeZone(self::TIMEZONE));
+ $data[] = [$year, $date->format('Y-m-d')];
+ }
+
+ return $data;
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ *
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ [self::LOCALE => 'St. Patrick\'s Day']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ Holiday::TYPE_BANK
+ );
+ }
+}
diff --git a/tests/UnitedKingdom/NorthernIreland/SummerBankHolidayTest.php b/tests/UnitedKingdom/NorthernIreland/SummerBankHolidayTest.php
new file mode 100644
index 000000000..eb5d93073
--- /dev/null
+++ b/tests/UnitedKingdom/NorthernIreland/SummerBankHolidayTest.php
@@ -0,0 +1,174 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\NorthernIreland;
+
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing the Summer Bank Holiday in Northern Ireland.
+ */
+class SummerBankHolidayTest extends NorthernIrelandBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'summerBankHoliday';
+
+ /**
+ * The year in which the holiday was first established
+ */
+ public const ESTABLISHMENT_YEAR = 1871;
+
+ /**
+ * The year in which the holiday was renamed from August Bank Holiday to Summer Bank Holiday.
+ */
+ public const RENAME_YEAR = 1965;
+
+ /**
+ * Tests the holiday defined in this test.
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testHoliday()
+ {
+ $year = $this->generateRandomYear(1970);
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime("last monday of august $year", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday exception in 2020.
+ *
+ * @throws ReflectionException
+ * @throws Exception
+ */
+ public function testHolidayBefore1965()
+ {
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR, 1964);
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime("first monday of august $year", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday during trial period in 1965-1970.
+ * @throws ReflectionException
+ * @throws Exception
+ */
+ public function testHolidayTrialPeriod()
+ {
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 1965,
+ new DateTime('1965-8-30', new DateTimeZone(self::TIMEZONE))
+ );
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 1966,
+ new DateTime('1966-8-29', new DateTimeZone(self::TIMEZONE))
+ );
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 1967,
+ new DateTime('1967-8-28', new DateTimeZone(self::TIMEZONE))
+ );
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 1968,
+ new DateTime('1968-9-2', new DateTimeZone(self::TIMEZONE))
+ );
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 1969,
+ new DateTime('1969-9-1', new DateTimeZone(self::TIMEZONE))
+ );
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 1970,
+ new DateTime('1970-8-31', new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday defined in this test before establishment.
+ * @throws ReflectionException
+ */
+ public function testHolidayBeforeEstablishment()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ );
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::RENAME_YEAR),
+ [self::LOCALE => 'Summer Bank Holiday']
+ );
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslationBeforeRename(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR, self::RENAME_YEAR - 1),
+ [self::LOCALE => 'August Bank Holiday']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ Holiday::TYPE_BANK
+ );
+ }
+}
diff --git a/tests/UnitedKingdom/Scotland/BoxingDayTest.php b/tests/UnitedKingdom/Scotland/BoxingDayTest.php
new file mode 100644
index 000000000..b81708d4e
--- /dev/null
+++ b/tests/UnitedKingdom/Scotland/BoxingDayTest.php
@@ -0,0 +1,98 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\Scotland;
+
+use DateInterval;
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing Boxing Day in Scotland.
+ */
+class BoxingDayTest extends ScotlandBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'secondChristmasDay';
+
+ /**
+ * Tests the holiday defined in this test.
+ *
+ * @dataProvider HolidayDataProvider
+ *
+ * @param int $year the year for which the holiday defined in this test needs to be tested
+ * @param string $expected the expected date
+ *
+ * @throws ReflectionException
+ * @throws Exception
+ */
+ public function testHoliday($year, $expected)
+ {
+ $date = new DateTime($expected, new DateTimeZone(self::TIMEZONE));
+ $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $date);
+
+ if (\in_array((int)$date->format('w'), [0, 6], true)) {
+ $date->add(new DateInterval('P2D'));
+ $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date);
+ $this->assertHolidayType(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, Holiday::TYPE_BANK);
+ }
+ }
+
+ /**
+ * Returns a list of test dates
+ *
+ * @return array list of test dates for the holiday defined in this test
+ * @throws Exception
+ */
+ public function HolidayDataProvider(): array
+ {
+ $data = [];
+
+ for ($y = 0; $y < self::TEST_ITERATIONS; $y++) {
+ $year = $this->generateRandomYear();
+ $date = new DateTime("$year-12-26", new DateTimeZone(self::TIMEZONE));
+
+ $data[] = [$year, $date->format('Y-m-d')];
+ }
+
+ return $data;
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(),
+ [self::LOCALE => 'Boxing Day']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_BANK);
+ }
+}
diff --git a/tests/UnitedKingdom/Scotland/ChristmasDayTest.php b/tests/UnitedKingdom/Scotland/ChristmasDayTest.php
new file mode 100644
index 000000000..b9e829841
--- /dev/null
+++ b/tests/UnitedKingdom/Scotland/ChristmasDayTest.php
@@ -0,0 +1,98 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\Scotland;
+
+use DateInterval;
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing Christmas Day in Scotland.
+ */
+class ChristmasDayTest extends ScotlandBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'christmasDay';
+
+ /**
+ * Tests the holiday defined in this test.
+ *
+ * @dataProvider HolidayDataProvider
+ *
+ * @param int $year the year for which the holiday defined in this test needs to be tested
+ * @param string $expected the expected date
+ *
+ * @throws ReflectionException
+ * @throws Exception
+ */
+ public function testHoliday($year, $expected)
+ {
+ $date = new DateTime($expected, new DateTimeZone(self::TIMEZONE));
+ $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $date);
+
+ if (\in_array((int)$date->format('w'), [0, 6], true)) {
+ $date->add(new DateInterval('P2D'));
+ $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date);
+ $this->assertHolidayType(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, Holiday::TYPE_BANK);
+ }
+ }
+
+ /**
+ * Returns a list of test dates
+ *
+ * @return array list of test dates for the holiday defined in this test
+ * @throws Exception
+ */
+ public function HolidayDataProvider(): array
+ {
+ $data = [];
+
+ for ($y = 0; $y < self::TEST_ITERATIONS; $y++) {
+ $year = $this->generateRandomYear();
+ $date = new DateTime("$year-12-25", new DateTimeZone(self::TIMEZONE));
+
+ $data[] = [$year, $date->format('Y-m-d')];
+ }
+
+ return $data;
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(),
+ [self::LOCALE => 'Christmas Day']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_BANK);
+ }
+}
diff --git a/tests/UnitedKingdom/Scotland/GoodFridayTest.php b/tests/UnitedKingdom/Scotland/GoodFridayTest.php
new file mode 100644
index 000000000..066bdd63b
--- /dev/null
+++ b/tests/UnitedKingdom/Scotland/GoodFridayTest.php
@@ -0,0 +1,70 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\Scotland;
+
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class containing tests for Good Friday in Scotland.
+ */
+class GoodFridayTest extends ScotlandBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday to be tested
+ */
+ public const HOLIDAY = 'goodFriday';
+
+ /**
+ * Tests the holiday defined in this test.
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testHoliday()
+ {
+ $year = 1866;
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime("$year-3-30", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(),
+ [self::LOCALE => 'Good Friday']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_BANK);
+ }
+}
diff --git a/tests/UnitedKingdom/Scotland/MayDayBankHolidayTest.php b/tests/UnitedKingdom/Scotland/MayDayBankHolidayTest.php
new file mode 100644
index 000000000..e3659fcf5
--- /dev/null
+++ b/tests/UnitedKingdom/Scotland/MayDayBankHolidayTest.php
@@ -0,0 +1,117 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\Scotland;
+
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing the May Day Bank Holiday in Scotland.
+ */
+class MayDayBankHolidayTest extends ScotlandBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'mayDayBankHoliday';
+
+ /**
+ * The year in which the holiday was first established
+ */
+ public const ESTABLISHMENT_YEAR = 1978;
+
+ /**
+ * Tests the holiday defined in this test.
+ *
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testHoliday()
+ {
+ $year = 2101;
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime("$year-5-2", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday exception in 1995 and 2020.
+ *
+ * @throws ReflectionException
+ * @throws Exception
+ */
+ public function testHolidayExceptions()
+ {
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 1995,
+ new DateTime('1995-5-8', new DateTimeZone(self::TIMEZONE))
+ );
+
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 2020,
+ new DateTime('2020-5-8', new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday defined in this test before establishment.
+ * @throws ReflectionException
+ */
+ public function testHolidayBeforeEstablishment()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ );
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ [self::LOCALE => 'May Day Bank Holiday']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ Holiday::TYPE_BANK
+ );
+ }
+}
diff --git a/tests/UnitedKingdom/Scotland/NewYearsDayTest.php b/tests/UnitedKingdom/Scotland/NewYearsDayTest.php
new file mode 100644
index 000000000..96ac0792f
--- /dev/null
+++ b/tests/UnitedKingdom/Scotland/NewYearsDayTest.php
@@ -0,0 +1,138 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\Scotland;
+
+use DateInterval;
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing New Years Day in Scotland.
+ */
+class NewYearsDayTest extends ScotlandBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The year in which the holiday was first established
+ */
+ public const ESTABLISHMENT_YEAR = 1871;
+
+ /**
+ * The year in which the holiday was adjusted
+ */
+ public const ADJUSTMENT_YEAR = 1974;
+
+ /**
+ * The name of the holiday to be tested
+ */
+ public const HOLIDAY = 'newYearsDay';
+
+ /**
+ * Tests the holiday defined in this test on or after establishment.
+ *
+ * @dataProvider HolidayDataProvider
+ *
+ * @param int $year the year for which the holiday defined in this test needs to be tested
+ * @param string $expected the expected date
+ *
+ * @throws ReflectionException
+ * @throws Exception
+ */
+ public function testHolidayOnAfterEstablishment($year, $expected)
+ {
+ $date = new DateTime($expected, new DateTimeZone(self::TIMEZONE));
+ $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $date);
+
+ if (\in_array((int)$date->format('w'), [0, 6], true)) {
+ $date->add(new DateInterval('P2D'));
+ $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date);
+ }
+ }
+
+ /**
+ * Tests the holiday defined in this test before establishment.
+ * @throws ReflectionException
+ */
+ public function testHolidayBeforeEstablishment()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ );
+ }
+
+ /**
+ * Tests that the holiday defined in this test is of the type 'observance' before the year it was changed.
+ * @throws ReflectionException
+ */
+ public function testHolidayIsObservedTypeBeforeChange()
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR, self::ADJUSTMENT_YEAR - 1),
+ Holiday::TYPE_OBSERVANCE
+ );
+ }
+
+ /**
+ * Returns a list of random test dates used for assertion of the holiday defined in this test
+ *
+ * @return array list of test dates for the holiday defined in this test
+ * @throws Exception
+ */
+ public function HolidayDataProvider(): array
+ {
+ $data = [];
+
+ for ($y = 0; $y < self::TEST_ITERATIONS; $y++) {
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $date = new DateTime("$year-1-1", new DateTimeZone(self::TIMEZONE));
+ $data[] = [$year, $date->format('Y-m-d')];
+ }
+
+ return $data;
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ [self::LOCALE => 'New Year\'s Day']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ADJUSTMENT_YEAR + 1),
+ Holiday::TYPE_BANK
+ );
+ }
+}
diff --git a/tests/UnitedKingdom/Scotland/ScotlandBaseTestCase.php b/tests/UnitedKingdom/Scotland/ScotlandBaseTestCase.php
new file mode 100644
index 000000000..e59c806ff
--- /dev/null
+++ b/tests/UnitedKingdom/Scotland/ScotlandBaseTestCase.php
@@ -0,0 +1,44 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\Scotland;
+
+use Yasumi\tests\UnitedKingdom\UnitedKingdomBaseTestCase;
+use Yasumi\tests\YasumiBase;
+
+/**
+ * Base class for test cases of the Scotland holiday provider.
+ */
+abstract class ScotlandBaseTestCase extends UnitedKingdomBaseTestCase
+{
+ use YasumiBase;
+
+ /**
+ * Name of the region (e.g. country / state) to be tested
+ */
+ public const REGION = 'UnitedKingdom\Scotland';
+
+ /**
+ * Timezone in which this provider has holidays defined
+ */
+ public const TIMEZONE = 'Europe/London';
+
+ /**
+ * Locale that is considered common for this provider
+ */
+ public const LOCALE = 'en_GB';
+
+ /**
+ * Number of iterations to be used for the various unit tests of this provider
+ */
+ public const TEST_ITERATIONS = 50;
+}
diff --git a/tests/UnitedKingdom/Scotland/ScotlandTest.php b/tests/UnitedKingdom/Scotland/ScotlandTest.php
new file mode 100644
index 000000000..495d790fd
--- /dev/null
+++ b/tests/UnitedKingdom/Scotland/ScotlandTest.php
@@ -0,0 +1,88 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\Scotland;
+
+use ReflectionException;
+use Yasumi\Holiday;
+
+/**
+ * Class for testing holidays in Scotland.
+ */
+class ScotlandTest extends ScotlandBaseTestCase
+{
+ /**
+ * @var int year random year number used for all tests in this Test Case
+ */
+ protected $year;
+
+ /**
+ * Tests if all official holidays in Scotland are defined by the provider class
+ * @throws ReflectionException
+ */
+ public function testOfficialHolidays(): void
+ {
+ $this->assertDefinedHolidays([
+ ], self::REGION, $this->year, Holiday::TYPE_OFFICIAL);
+ }
+
+ /**
+ * Tests if all observed holidays in Scotland are defined by the provider class
+ * @throws ReflectionException
+ */
+ public function testObservedHolidays(): void
+ {
+ $this->assertDefinedHolidays([], self::REGION, $this->year, Holiday::TYPE_OBSERVANCE);
+ }
+
+ /**
+ * Tests if all seasonal holidays in Scotland are defined by the provider class
+ * @throws ReflectionException
+ */
+ public function testSeasonalHolidays(): void
+ {
+ $this->assertDefinedHolidays([], self::REGION, $this->year, Holiday::TYPE_SEASON);
+ }
+
+ /**
+ * Tests if all bank holidays in Scotland are defined by the provider class
+ * @throws ReflectionException
+ */
+ public function testBankHolidays(): void
+ {
+ $this->assertDefinedHolidays([
+ 'goodFriday',
+ 'mayDayBankHoliday',
+ 'springBankHoliday',
+ 'christmasDay',
+ 'secondChristmasDay',
+ 'newYearsDay',
+ ], self::REGION, $this->year, Holiday::TYPE_BANK);
+ }
+
+ /**
+ * Tests if all other holidays in Scotland are defined by the provider class
+ * @throws ReflectionException
+ */
+ public function testOtherHolidays(): void
+ {
+ $this->assertDefinedHolidays([], self::REGION, $this->year, Holiday::TYPE_OTHER);
+ }
+
+ /**
+ * Initial setup of this Test Case
+ */
+ protected function setUp(): void
+ {
+ $this->year = $this->generateRandomYear(1978);
+ }
+}
diff --git a/tests/UnitedKingdom/Scotland/SecondNewYearsDayTest.php b/tests/UnitedKingdom/Scotland/SecondNewYearsDayTest.php
new file mode 100644
index 000000000..d2aaefed6
--- /dev/null
+++ b/tests/UnitedKingdom/Scotland/SecondNewYearsDayTest.php
@@ -0,0 +1,138 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\Scotland;
+
+use DateInterval;
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing New Years Day in Scotland.
+ */
+class SecondNewYearsDayTest extends ScotlandBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The year in which the holiday was first established
+ */
+ public const ESTABLISHMENT_YEAR = 1871;
+
+ /**
+ * The year in which the holiday was adjusted
+ */
+ public const ADJUSTMENT_YEAR = 1974;
+
+ /**
+ * The name of the holiday to be tested
+ */
+ public const HOLIDAY = 'secondNewYearsDay';
+
+ /**
+ * Tests the holiday defined in this test on or after establishment.
+ *
+ * @dataProvider HolidayDataProvider
+ *
+ * @param int $year the year for which the holiday defined in this test needs to be tested
+ * @param string $expected the expected date
+ *
+ * @throws ReflectionException
+ * @throws Exception
+ */
+ public function testHolidayOnAfterEstablishment($year, $expected)
+ {
+ $date = new DateTime($expected, new DateTimeZone(self::TIMEZONE));
+ $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $date);
+
+ if (\in_array((int)$date->format('w'), [0, 6], true)) {
+ $date->add(new DateInterval('P2D'));
+ $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date);
+ }
+ }
+
+ /**
+ * Tests the holiday defined in this test before establishment.
+ * @throws ReflectionException
+ */
+ public function testHolidayBeforeEstablishment()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ );
+ }
+
+ /**
+ * Tests that the holiday defined in this test is of the type 'observance' before the year it was changed.
+ * @throws ReflectionException
+ */
+ public function testHolidayIsObservedTypeBeforeChange()
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR, self::ADJUSTMENT_YEAR - 1),
+ Holiday::TYPE_OBSERVANCE
+ );
+ }
+
+ /**
+ * Returns a list of random test dates used for assertion of the holiday defined in this test
+ *
+ * @return array list of test dates for the holiday defined in this test
+ * @throws Exception
+ */
+ public function HolidayDataProvider(): array
+ {
+ $data = [];
+
+ for ($y = 0; $y < self::TEST_ITERATIONS; $y++) {
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $date = new DateTime("$year-1-2", new DateTimeZone(self::TIMEZONE));
+ $data[] = [$year, $date->format('Y-m-d')];
+ }
+
+ return $data;
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ [self::LOCALE => '2nd January']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ADJUSTMENT_YEAR + 1),
+ Holiday::TYPE_BANK
+ );
+ }
+}
diff --git a/tests/UnitedKingdom/Scotland/SpringBankHolidayTest.php b/tests/UnitedKingdom/Scotland/SpringBankHolidayTest.php
new file mode 100644
index 000000000..014d6e97c
--- /dev/null
+++ b/tests/UnitedKingdom/Scotland/SpringBankHolidayTest.php
@@ -0,0 +1,93 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\Scotland;
+
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing the Spring Bank Holiday in Scotland.
+ */
+class SpringBankHolidayTest extends ScotlandBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'springBankHoliday';
+
+ /**
+ * The year in which the holiday was first established
+ */
+ public const ESTABLISHMENT_YEAR = 1965;
+
+ /**
+ * Tests the holiday defined in this test.
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testHoliday()
+ {
+ $year = 1988;
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime("$year-5-30", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday defined in this test before establishment.
+ * @throws ReflectionException
+ */
+ public function testHolidayBeforeEstablishment()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ );
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ [self::LOCALE => 'Spring Bank Holiday']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ Holiday::TYPE_BANK
+ );
+ }
+}
diff --git a/tests/UnitedKingdom/Scotland/StAndrewsDayTest.php b/tests/UnitedKingdom/Scotland/StAndrewsDayTest.php
new file mode 100644
index 000000000..151485d38
--- /dev/null
+++ b/tests/UnitedKingdom/Scotland/StAndrewsDayTest.php
@@ -0,0 +1,106 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\Scotland;
+
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing St. Patrick's Day in Scotland.
+ */
+class StAndrewsDayTest extends ScotlandBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday to be tested
+ */
+ public const HOLIDAY = 'stAndrewsDay';
+
+ /**
+ * The year in which the holiday was first established
+ */
+ public const ESTABLISHMENT_YEAR = 2007;
+
+ /**
+ * Tests the holiday defined in this test.
+ *
+ * @dataProvider HolidayDataProvider
+ *
+ * @param int $year the year for which the holiday defined in this test needs to be tested
+ * @param \DateTime $expected the expected date
+ *
+ * @throws ReflectionException
+ * @throws Exception
+ */
+ public function testHoliday($year, $expected)
+ {
+ $date = new DateTime($expected, new DateTimeZone(self::TIMEZONE));
+ $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $date);
+
+ if (\in_array((int)$date->format('w'), [0, 6], true)) {
+ $date->modify('next monday');
+ $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date);
+ }
+ }
+
+ /**
+ * Returns a list of random test dates used for assertion of the holiday defined in this test
+ *
+ * @return array list of test dates for the holiday defined in this test
+ * @throws Exception
+ */
+ public function HolidayDataProvider(): array
+ {
+ $data = [];
+
+ for ($y = 0; $y < self::TEST_ITERATIONS; $y++) {
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $date = new DateTime("$year-11-30", new DateTimeZone(self::TIMEZONE));
+ $data[] = [$year, $date->format('Y-m-d')];
+ }
+
+ return $data;
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ *
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ [self::LOCALE => 'St. Andrew\'s Day']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ Holiday::TYPE_BANK
+ );
+ }
+}
diff --git a/tests/UnitedKingdom/Scotland/SummerBankHolidayTest.php b/tests/UnitedKingdom/Scotland/SummerBankHolidayTest.php
new file mode 100644
index 000000000..783106888
--- /dev/null
+++ b/tests/UnitedKingdom/Scotland/SummerBankHolidayTest.php
@@ -0,0 +1,93 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\Scotland;
+
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing the August Bank Holiday in Scotland.
+ */
+class SummerBankHolidayTest extends ScotlandBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'summerBankHoliday';
+
+ /**
+ * The year in which the holiday was first established
+ */
+ public const ESTABLISHMENT_YEAR = 1871;
+
+ /**
+ * Tests the holiday defined in this test.
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testHoliday()
+ {
+ $year = $this->generateRandomYear(1970);
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime("first monday of august $year", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday defined in this test before establishment.
+ * @throws ReflectionException
+ */
+ public function testHolidayBeforeEstablishment()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ );
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ [self::LOCALE => 'August Bank Holiday']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ Holiday::TYPE_BANK
+ );
+ }
+}
diff --git a/tests/UnitedKingdom/SpringBankHolidayTest.php b/tests/UnitedKingdom/SpringBankHolidayTest.php
index 79c390e20..348b5b7a1 100644
--- a/tests/UnitedKingdom/SpringBankHolidayTest.php
+++ b/tests/UnitedKingdom/SpringBankHolidayTest.php
@@ -1,4 +1,4 @@
-assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 2002,
+ new DateTime('2002-6-4', new DateTimeZone(self::TIMEZONE))
+ );
+
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 2012,
+ new DateTime('2012-6-4', new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
/**
* Tests the holiday defined in this test before establishment.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayBeforeEstablishment()
{
@@ -63,7 +87,7 @@ public function testHolidayBeforeEstablishment()
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
@@ -77,7 +101,7 @@ public function testTranslation(): void
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/UnitedKingdom/SummerBankHolidayTest.php b/tests/UnitedKingdom/SummerBankHolidayTest.php
index ad0ee64f9..fe591a8c4 100644
--- a/tests/UnitedKingdom/SummerBankHolidayTest.php
+++ b/tests/UnitedKingdom/SummerBankHolidayTest.php
@@ -1,4 +1,4 @@
-generateRandomYear(self::ESTABLISHMENT_YEAR);
+ $year = $this->generateRandomYear(1970);
$this->assertHoliday(
self::REGION,
self::HOLIDAY,
@@ -48,9 +55,70 @@ public function testHoliday()
);
}
+ /**
+ * Tests the holiday exception in 2020.
+ * @throws ReflectionException
+ * @throws Exception
+ */
+ public function testHolidayBefore1965()
+ {
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR, 1964);
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime("first monday of august $year", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday during trial period in 1965-1970.
+ * @throws ReflectionException
+ * @throws Exception
+ */
+ public function testHolidayTrialPeriod()
+ {
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 1965,
+ new DateTime('1965-8-30', new DateTimeZone(self::TIMEZONE))
+ );
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 1966,
+ new DateTime('1966-8-29', new DateTimeZone(self::TIMEZONE))
+ );
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 1967,
+ new DateTime('1967-8-28', new DateTimeZone(self::TIMEZONE))
+ );
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 1968,
+ new DateTime('1968-9-2', new DateTimeZone(self::TIMEZONE))
+ );
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 1969,
+ new DateTime('1969-9-1', new DateTimeZone(self::TIMEZONE))
+ );
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 1970,
+ new DateTime('1970-8-31', new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
/**
* Tests the holiday defined in this test before establishment.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayBeforeEstablishment()
{
@@ -63,21 +131,35 @@ public function testHolidayBeforeEstablishment()
/**
* Tests the translated name of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testTranslation(): void
{
$this->assertTranslatedHolidayName(
self::REGION,
self::HOLIDAY,
- $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ $this->generateRandomYear(self::RENAME_YEAR),
[self::LOCALE => 'Summer Bank Holiday']
);
}
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslationBeforeRename(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR, self::RENAME_YEAR - 1),
+ [self::LOCALE => 'August Bank Holiday']
+ );
+ }
+
/**
* Tests type of the holiday defined in this test.
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testHolidayType(): void
{
diff --git a/tests/UnitedKingdom/UnitedKingdomBaseTestCase.php b/tests/UnitedKingdom/UnitedKingdomBaseTestCase.php
index 4a8bdb472..fcc0013be 100644
--- a/tests/UnitedKingdom/UnitedKingdomBaseTestCase.php
+++ b/tests/UnitedKingdom/UnitedKingdomBaseTestCase.php
@@ -1,4 +1,4 @@
-year, Holiday::TYPE_BANK);
}
/**
* Tests if all other holidays in the United Kingdom are defined by the provider class
- * @throws \ReflectionException
+ * @throws ReflectionException
*/
public function testOtherHolidays(): void
{
@@ -81,7 +82,7 @@ public function testOtherHolidays(): void
/**
* Initial setup of this Test Case
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->year = $this->generateRandomYear(1978);
}
diff --git a/tests/UnitedKingdom/Wales/BoxingDayTest.php b/tests/UnitedKingdom/Wales/BoxingDayTest.php
new file mode 100644
index 000000000..eee71a3cb
--- /dev/null
+++ b/tests/UnitedKingdom/Wales/BoxingDayTest.php
@@ -0,0 +1,98 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\Wales;
+
+use DateInterval;
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing Boxing Day in Wales.
+ */
+class BoxingDayTest extends WalesBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'secondChristmasDay';
+
+ /**
+ * Tests the holiday defined in this test.
+ *
+ * @dataProvider HolidayDataProvider
+ *
+ * @param int $year the year for which the holiday defined in this test needs to be tested
+ * @param string $expected the expected date
+ *
+ * @throws ReflectionException
+ * @throws Exception
+ */
+ public function testHoliday($year, $expected)
+ {
+ $date = new DateTime($expected, new DateTimeZone(self::TIMEZONE));
+ $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $date);
+
+ if (\in_array((int)$date->format('w'), [0, 6], true)) {
+ $date->add(new DateInterval('P2D'));
+ $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date);
+ $this->assertHolidayType(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, Holiday::TYPE_BANK);
+ }
+ }
+
+ /**
+ * Returns a list of test dates
+ *
+ * @return array list of test dates for the holiday defined in this test
+ * @throws Exception
+ */
+ public function HolidayDataProvider(): array
+ {
+ $data = [];
+
+ for ($y = 0; $y < self::TEST_ITERATIONS; $y++) {
+ $year = $this->generateRandomYear();
+ $date = new DateTime("$year-12-26", new DateTimeZone(self::TIMEZONE));
+
+ $data[] = [$year, $date->format('Y-m-d')];
+ }
+
+ return $data;
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(),
+ [self::LOCALE => 'Boxing Day']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_BANK);
+ }
+}
diff --git a/tests/UnitedKingdom/Wales/ChristmasDayTest.php b/tests/UnitedKingdom/Wales/ChristmasDayTest.php
new file mode 100644
index 000000000..b32321bc1
--- /dev/null
+++ b/tests/UnitedKingdom/Wales/ChristmasDayTest.php
@@ -0,0 +1,98 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\Wales;
+
+use DateInterval;
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing Christmas Day in Wales.
+ */
+class ChristmasDayTest extends WalesBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'christmasDay';
+
+ /**
+ * Tests the holiday defined in this test.
+ *
+ * @dataProvider HolidayDataProvider
+ *
+ * @param int $year the year for which the holiday defined in this test needs to be tested
+ * @param string $expected the expected date
+ *
+ * @throws ReflectionException
+ * @throws Exception
+ */
+ public function testHoliday($year, $expected)
+ {
+ $date = new DateTime($expected, new DateTimeZone(self::TIMEZONE));
+ $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $date);
+
+ if (\in_array((int)$date->format('w'), [0, 6], true)) {
+ $date->add(new DateInterval('P2D'));
+ $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date);
+ $this->assertHolidayType(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, Holiday::TYPE_BANK);
+ }
+ }
+
+ /**
+ * Returns a list of test dates
+ *
+ * @return array list of test dates for the holiday defined in this test
+ * @throws Exception
+ */
+ public function HolidayDataProvider(): array
+ {
+ $data = [];
+
+ for ($y = 0; $y < self::TEST_ITERATIONS; $y++) {
+ $year = $this->generateRandomYear();
+ $date = new DateTime("$year-12-25", new DateTimeZone(self::TIMEZONE));
+
+ $data[] = [$year, $date->format('Y-m-d')];
+ }
+
+ return $data;
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(),
+ [self::LOCALE => 'Christmas Day']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL);
+ }
+}
diff --git a/tests/UnitedKingdom/Wales/EasterMondayTest.php b/tests/UnitedKingdom/Wales/EasterMondayTest.php
new file mode 100644
index 000000000..03910b78e
--- /dev/null
+++ b/tests/UnitedKingdom/Wales/EasterMondayTest.php
@@ -0,0 +1,97 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\Wales;
+
+use DateInterval;
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing Easter Monday in Wales.
+ */
+class EasterMondayTest extends WalesBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'easterMonday';
+
+ /**
+ * Tests Easter Monday
+ *
+ * @dataProvider HolidayDataProvider
+ *
+ * @param int $year the year for which the holiday defined in this test needs to be tested
+ * @param string $expected the expected date
+ *
+ * @throws ReflectionException
+ * @throws Exception
+ */
+ public function testHoliday($year, $expected)
+ {
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime($expected, new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Returns a list of test dates
+ *
+ * @return array list of test dates for the holiday defined in this test
+ * @throws Exception
+ */
+ public function HolidayDataProvider(): array
+ {
+ $data = [];
+
+ for ($y = 0; $y < 50; $y++) {
+ $year = $this->generateRandomYear();
+ $date = $this->calculateEaster($year, self::TIMEZONE);
+ $date->add(new DateInterval('P1D'));
+
+ $data[] = [$year, $date->format('Y-m-d')];
+ }
+
+ return $data;
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(),
+ [self::LOCALE => 'Easter Monday']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_BANK);
+ }
+}
diff --git a/tests/UnitedKingdom/Wales/GoodFridayTest.php b/tests/UnitedKingdom/Wales/GoodFridayTest.php
new file mode 100644
index 000000000..d4ec2a195
--- /dev/null
+++ b/tests/UnitedKingdom/Wales/GoodFridayTest.php
@@ -0,0 +1,70 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\Wales;
+
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class containing tests for Good Friday in Wales.
+ */
+class GoodFridayTest extends WalesBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday to be tested
+ */
+ public const HOLIDAY = 'goodFriday';
+
+ /**
+ * Tests the holiday defined in this test.
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testHoliday()
+ {
+ $year = 1866;
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime("$year-3-30", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(),
+ [self::LOCALE => 'Good Friday']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL);
+ }
+}
diff --git a/tests/UnitedKingdom/Wales/MayDayBankHolidayTest.php b/tests/UnitedKingdom/Wales/MayDayBankHolidayTest.php
new file mode 100644
index 000000000..b8d710000
--- /dev/null
+++ b/tests/UnitedKingdom/Wales/MayDayBankHolidayTest.php
@@ -0,0 +1,117 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\Wales;
+
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing the May Day Bank Holiday in Wales.
+ */
+class MayDayBankHolidayTest extends WalesBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'mayDayBankHoliday';
+
+ /**
+ * The year in which the holiday was first established
+ */
+ public const ESTABLISHMENT_YEAR = 1978;
+
+ /**
+ * Tests the holiday defined in this test.
+ *
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testHoliday()
+ {
+ $year = 2101;
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime("$year-5-2", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday exception in 1995 and 2020.
+ *
+ * @throws ReflectionException
+ * @throws Exception
+ */
+ public function testHolidayExceptions()
+ {
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 1995,
+ new DateTime('1995-5-8', new DateTimeZone(self::TIMEZONE))
+ );
+
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 2020,
+ new DateTime('2020-5-8', new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday defined in this test before establishment.
+ * @throws ReflectionException
+ */
+ public function testHolidayBeforeEstablishment()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ );
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ [self::LOCALE => 'May Day Bank Holiday']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ Holiday::TYPE_BANK
+ );
+ }
+}
diff --git a/tests/UnitedKingdom/Wales/NewYearsDayTest.php b/tests/UnitedKingdom/Wales/NewYearsDayTest.php
new file mode 100644
index 000000000..eb0c293a9
--- /dev/null
+++ b/tests/UnitedKingdom/Wales/NewYearsDayTest.php
@@ -0,0 +1,128 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\Wales;
+
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing New Years Day in Wales.
+ */
+class NewYearsDayTest extends WalesBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The year in which the holiday was first established
+ */
+ public const ESTABLISHMENT_YEAR = 1871;
+
+ /**
+ * The year in which the holiday was adjusted
+ */
+ public const ADJUSTMENT_YEAR = 1974;
+
+ /**
+ * The name of the holiday to be tested
+ */
+ public const HOLIDAY = 'newYearsDay';
+
+ /**
+ * Tests the holiday defined in this test on or after establishment.
+ *
+ * @dataProvider HolidayDataProvider
+ *
+ * @param int $year the year for which the holiday defined in this test needs to be tested
+ * @param string $expected the expected date
+ *
+ * @throws ReflectionException
+ * @throws Exception
+ */
+ public function testHolidayOnAfterEstablishment($year, $expected)
+ {
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime($expected, new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday defined in this test before establishment.
+ * @throws ReflectionException
+ */
+ public function testHolidayBeforeEstablishment()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ );
+ }
+
+ /**
+ * Tests that the holiday defined in this test is of the type 'observance' before the year it was changed.
+ * @throws ReflectionException
+ */
+ public function testHolidayIsObservedTypeBeforeChange()
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR, self::ADJUSTMENT_YEAR - 1),
+ Holiday::TYPE_OBSERVANCE
+ );
+ }
+
+ /**
+ * Returns a list of random test dates used for assertion of the holiday defined in this test
+ *
+ * @return array list of test dates for the holiday defined in this test
+ * @throws Exception
+ */
+ public function HolidayDataProvider(): array
+ {
+ return $this->generateRandomDatesWithHolidayMovedToMonday(01, 01, self::TIMEZONE, 10, self::ESTABLISHMENT_YEAR);
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ [self::LOCALE => 'New Year\'s Day']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ADJUSTMENT_YEAR + 1),
+ Holiday::TYPE_BANK
+ );
+ }
+}
diff --git a/tests/UnitedKingdom/Wales/SpringBankHolidayTest.php b/tests/UnitedKingdom/Wales/SpringBankHolidayTest.php
new file mode 100644
index 000000000..d9b7a577a
--- /dev/null
+++ b/tests/UnitedKingdom/Wales/SpringBankHolidayTest.php
@@ -0,0 +1,116 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\Wales;
+
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing the Spring Bank Holiday in Wales.
+ */
+class SpringBankHolidayTest extends WalesBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'springBankHoliday';
+
+ /**
+ * The year in which the holiday was first established
+ */
+ public const ESTABLISHMENT_YEAR = 1965;
+
+ /**
+ * Tests the holiday defined in this test.
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testHoliday()
+ {
+ $year = 1988;
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime("$year-5-30", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday exceptions in 2002 and 2012.
+ *
+ * @throws ReflectionException
+ * @throws Exception
+ */
+ public function testHolidayException()
+ {
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 2002,
+ new DateTime('2002-6-4', new DateTimeZone(self::TIMEZONE))
+ );
+
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 2012,
+ new DateTime('2012-6-4', new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday defined in this test before establishment.
+ * @throws ReflectionException
+ */
+ public function testHolidayBeforeEstablishment()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ );
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ [self::LOCALE => 'Spring Bank Holiday']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ Holiday::TYPE_BANK
+ );
+ }
+}
diff --git a/tests/UnitedKingdom/Wales/SummerBankHolidayTest.php b/tests/UnitedKingdom/Wales/SummerBankHolidayTest.php
new file mode 100644
index 000000000..ca69ded05
--- /dev/null
+++ b/tests/UnitedKingdom/Wales/SummerBankHolidayTest.php
@@ -0,0 +1,175 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\Wales;
+
+use DateTime;
+use DateTimeZone;
+use Exception;
+use ReflectionException;
+use Yasumi\Holiday;
+use Yasumi\tests\YasumiTestCaseInterface;
+
+/**
+ * Class for testing the Summer Bank Holiday in Wales.
+ */
+class SummerBankHolidayTest extends WalesBaseTestCase implements YasumiTestCaseInterface
+{
+ /**
+ * The name of the holiday
+ */
+ public const HOLIDAY = 'summerBankHoliday';
+
+ /**
+ * The year in which the holiday was first established
+ */
+ public const ESTABLISHMENT_YEAR = 1871;
+
+ /**
+ * The year in which the holiday was renamed from August Bank Holiday to Summer Bank Holiday.
+ */
+ public const RENAME_YEAR = 1965;
+
+ /**
+ * Tests the holiday defined in this test.
+ * @throws Exception
+ * @throws ReflectionException
+ */
+ public function testHoliday()
+ {
+ $year = $this->generateRandomYear(1970);
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime("last monday of august $year", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday exception in 2020.
+ *
+ * @throws ReflectionException
+ * @throws Exception
+ */
+ public function testHolidayBefore1965()
+ {
+ $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR, 1964);
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $year,
+ new DateTime("first monday of august $year", new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday during trial period in 1965-1970.
+ *
+ * @throws ReflectionException
+ * @throws Exception
+ */
+ public function testHolidayTrialPeriod()
+ {
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 1965,
+ new DateTime('1965-8-30', new DateTimeZone(self::TIMEZONE))
+ );
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 1966,
+ new DateTime('1966-8-29', new DateTimeZone(self::TIMEZONE))
+ );
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 1967,
+ new DateTime('1967-8-28', new DateTimeZone(self::TIMEZONE))
+ );
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 1968,
+ new DateTime('1968-9-2', new DateTimeZone(self::TIMEZONE))
+ );
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 1969,
+ new DateTime('1969-9-1', new DateTimeZone(self::TIMEZONE))
+ );
+ $this->assertHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ 1970,
+ new DateTime('1970-8-31', new DateTimeZone(self::TIMEZONE))
+ );
+ }
+
+ /**
+ * Tests the holiday defined in this test before establishment.
+ * @throws ReflectionException
+ */
+ public function testHolidayBeforeEstablishment()
+ {
+ $this->assertNotHoliday(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
+ );
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslation(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::RENAME_YEAR),
+ [self::LOCALE => 'Summer Bank Holiday']
+ );
+ }
+
+ /**
+ * Tests the translated name of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testTranslationBeforeRename(): void
+ {
+ $this->assertTranslatedHolidayName(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR, self::RENAME_YEAR - 1),
+ [self::LOCALE => 'August Bank Holiday']
+ );
+ }
+
+ /**
+ * Tests type of the holiday defined in this test.
+ * @throws ReflectionException
+ */
+ public function testHolidayType(): void
+ {
+ $this->assertHolidayType(
+ self::REGION,
+ self::HOLIDAY,
+ $this->generateRandomYear(self::ESTABLISHMENT_YEAR),
+ Holiday::TYPE_BANK
+ );
+ }
+}
diff --git a/tests/UnitedKingdom/Wales/WalesBaseTestCase.php b/tests/UnitedKingdom/Wales/WalesBaseTestCase.php
new file mode 100644
index 000000000..27d3e1836
--- /dev/null
+++ b/tests/UnitedKingdom/Wales/WalesBaseTestCase.php
@@ -0,0 +1,44 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\Wales;
+
+use Yasumi\tests\UnitedKingdom\UnitedKingdomBaseTestCase;
+use Yasumi\tests\YasumiBase;
+
+/**
+ * Base class for test cases of the Wales holiday provider.
+ */
+abstract class WalesBaseTestCase extends UnitedKingdomBaseTestCase
+{
+ use YasumiBase;
+
+ /**
+ * Name of the region (e.g. country / state) to be tested
+ */
+ public const REGION = 'UnitedKingdom\Wales';
+
+ /**
+ * Timezone in which this provider has holidays defined
+ */
+ public const TIMEZONE = 'Europe/London';
+
+ /**
+ * Locale that is considered common for this provider
+ */
+ public const LOCALE = 'en_GB';
+
+ /**
+ * Number of iterations to be used for the various unit tests of this provider
+ */
+ public const TEST_ITERATIONS = 50;
+}
diff --git a/tests/UnitedKingdom/Wales/WalesTest.php b/tests/UnitedKingdom/Wales/WalesTest.php
new file mode 100644
index 000000000..279b5dc01
--- /dev/null
+++ b/tests/UnitedKingdom/Wales/WalesTest.php
@@ -0,0 +1,89 @@
+
+ */
+
+namespace Yasumi\tests\UnitedKingdom\Wales;
+
+use ReflectionException;
+use Yasumi\Holiday;
+
+/**
+ * Class for testing holidays in Wales.
+ */
+class WalesTest extends WalesBaseTestCase
+{
+ /**
+ * @var int year random year number used for all tests in this Test Case
+ */
+ protected $year;
+
+ /**
+ * Tests if all official holidays in Wales are defined by the provider class
+ * @throws ReflectionException
+ */
+ public function testOfficialHolidays(): void
+ {
+ $this->assertDefinedHolidays([
+ 'goodFriday',
+ 'christmasDay',
+ ], self::REGION, $this->year, Holiday::TYPE_OFFICIAL);
+ }
+
+ /**
+ * Tests if all observed holidays in Wales are defined by the provider class
+ * @throws ReflectionException
+ */
+ public function testObservedHolidays(): void
+ {
+ $this->assertDefinedHolidays([], self::REGION, $this->year, Holiday::TYPE_OBSERVANCE);
+ }
+
+ /**
+ * Tests if all seasonal holidays in Wales are defined by the provider class
+ * @throws ReflectionException
+ */
+ public function testSeasonalHolidays(): void
+ {
+ $this->assertDefinedHolidays([], self::REGION, $this->year, Holiday::TYPE_SEASON);
+ }
+
+ /**
+ * Tests if all bank holidays in Wales are defined by the provider class
+ * @throws ReflectionException
+ */
+ public function testBankHolidays(): void
+ {
+ $this->assertDefinedHolidays([
+ 'newYearsDay',
+ 'easterMonday',
+ 'mayDayBankHoliday',
+ 'springBankHoliday',
+ 'secondChristmasDay',
+ ], self::REGION, $this->year, Holiday::TYPE_BANK);
+ }
+
+ /**
+ * Tests if all other holidays in Wales are defined by the provider class
+ * @throws ReflectionException
+ */
+ public function testOtherHolidays(): void
+ {
+ $this->assertDefinedHolidays([], self::REGION, $this->year, Holiday::TYPE_OTHER);
+ }
+
+ /**
+ * Initial setup of this Test Case
+ */
+ protected function setUp(): void
+ {
+ $this->year = $this->generateRandomYear(1978);
+ }
+}
diff --git a/tests/YasumiBase.php b/tests/YasumiBase.php
index b7b16756b..8677c9116 100644
--- a/tests/YasumiBase.php
+++ b/tests/YasumiBase.php
@@ -1,4 +1,4 @@
-getHoliday($shortName);
+ $holiday = $holidays->getHoliday($shortName);
$this->assertInstanceOf('Yasumi\Provider\\' . \str_replace('/', '\\', $provider), $holidays);
$this->assertInstanceOf(Holiday::class, $holiday);
@@ -108,21 +116,21 @@ public function assertHoliday($provider, $shortName, $year, $expected): void
/**
* Asserts that the given holiday for that given year does not exist.
*
- * @param string $provider the holiday provider (i.e. country/state) for which the holiday need to be tested
+ * @param string $provider the holiday provider (i.e. country/state) for which the holiday need to be tested
* @param string $shortName the short name of the holiday to be checked against
- * @param int $year holiday calendar year
- *
- * @throws \InvalidArgumentException
- * @throws \RuntimeException
- * @throws \Yasumi\Exception\UnknownLocaleException
- * @throws \Yasumi\Exception\InvalidDateException
- * @throws \PHPUnit\Framework\AssertionFailedError
- * @throws \ReflectionException
+ * @param int $year holiday calendar year
+ *
+ * @throws InvalidArgumentException
+ * @throws RuntimeException
+ * @throws UnknownLocaleException
+ * @throws InvalidDateException
+ * @throws AssertionFailedError
+ * @throws ReflectionException
*/
public function assertNotHoliday($provider, $shortName, $year): void
{
$holidays = Yasumi::create($provider, $year);
- $holiday = $holidays->getHoliday($shortName);
+ $holiday = $holidays->getHoliday($shortName);
$this->assertInstanceOf('Yasumi\Provider\\' . \str_replace('/', '\\', $provider), $holidays);
$this->assertNull($holiday);
@@ -133,33 +141,45 @@ public function assertNotHoliday($provider, $shortName, $year): void
/**
* Asserts that the expected name is indeed provided as a translated holiday name for that given year and name
*
- * @param string $provider the holiday provider (i.e. country/state) for which the holiday need to be tested
- * @param string $shortName string the short name of the holiday to be checked against
- * @param int $year holiday calendar year
- * @param array $translations the translations to be checked against
- *
- * @throws \InvalidArgumentException
- * @throws \RuntimeException
- * @throws \Yasumi\Exception\UnknownLocaleException
- * @throws \PHPUnit\Framework\AssertionFailedError
- * @throws \ReflectionException
+ * @param string $provider the holiday provider (i.e. country/state) for which the holiday need to be tested
+ * @param string $shortName string the short name of the holiday to be checked against
+ * @param int $year holiday calendar year
+ * @param array $translations the translations to be checked against
+ *
+ * @throws InvalidArgumentException
+ * @throws RuntimeException
+ * @throws UnknownLocaleException
+ * @throws AssertionFailedError
+ * @throws ReflectionException
*/
public function assertTranslatedHolidayName($provider, $shortName, $year, $translations): void
{
$holidays = Yasumi::create($provider, $year);
- $holiday = $holidays->getHoliday($shortName);
+ $holiday = $holidays->getHoliday($shortName);
$this->assertInstanceOf('Yasumi\Provider\\' . \str_replace('/', '\\', $provider), $holidays);
$this->assertInstanceOf(Holiday::class, $holiday);
$this->assertNotNull($holiday);
$this->assertTrue($holidays->isHoliday($holiday));
- if (\is_array($translations) && ! empty($translations)) {
+ if (\is_array($translations) && !empty($translations)) {
foreach ($translations as $locale => $name) {
- $translationExists = isset($holiday->translations[$locale]) ? true : false;
+ $locales = [$locale];
+ $parts = \explode('_', $locale);
+ while (\array_pop($parts) && $parts) {
+ $locales[] = \implode('_', $parts);
+ }
- $this->assertTrue($translationExists);
- $this->assertEquals($name, $holiday->translations[$locale]);
+ $translation = null;
+ foreach ($locales as $l) {
+ if (isset($holiday->translations[$l])) {
+ $translation = $holiday->translations[$l];
+ break;
+ }
+ }
+
+ $this->assertTrue(isset($translation));
+ $this->assertEquals($name, $translation);
}
}
@@ -169,21 +189,21 @@ public function assertTranslatedHolidayName($provider, $shortName, $year, $trans
/**
* Asserts that the expected type is indeed the associated type of the given holiday
*
- * @param string $provider the holiday provider (i.e. country/region) for which the holiday need to be tested
+ * @param string $provider the holiday provider (i.e. country/region) for which the holiday need to be tested
* @param string $shortName string the short name of the holiday to be checked against
- * @param int $year holiday calendar year
- * @param string $type the type to be checked against
- *
- * @throws \InvalidArgumentException
- * @throws \RuntimeException
- * @throws \PHPUnit\Framework\AssertionFailedError
- * @throws \Yasumi\Exception\UnknownLocaleException
- * @throws \ReflectionException
+ * @param int $year holiday calendar year
+ * @param string $type the type to be checked against
+ *
+ * @throws InvalidArgumentException
+ * @throws RuntimeException
+ * @throws AssertionFailedError
+ * @throws UnknownLocaleException
+ * @throws ReflectionException
*/
public function assertHolidayType($provider, $shortName, $year, $type): void
{
$holidays = Yasumi::create($provider, $year);
- $holiday = $holidays->getHoliday($shortName);
+ $holiday = $holidays->getHoliday($shortName);
$this->assertInstanceOf('Yasumi\Provider\\' . \str_replace('/', '\\', $provider), $holidays);
$this->assertInstanceOf(Holiday::class, $holiday);
@@ -196,22 +216,22 @@ public function assertHolidayType($provider, $shortName, $year, $type): void
/**
* Asserts that the expected week day is indeed the week day for the given holiday and year
*
- * @param string $provider the holiday provider (i.e. country/state) for which the holiday need to be
+ * @param string $provider the holiday provider (i.e. country/state) for which the holiday need to be
* tested
- * @param string $shortName string the short name of the holiday to be checked against
- * @param int $year holiday calendar year
+ * @param string $shortName string the short name of the holiday to be checked against
+ * @param int $year holiday calendar year
* @param string $expectedDayOfWeek the expected week day (i.e. "Saturday", "Sunday", etc.)
*
- * @throws \PHPUnit\Framework\AssertionFailedError
- * @throws \InvalidArgumentException
- * @throws \RuntimeException
- * @throws \Yasumi\Exception\UnknownLocaleException
- * @throws \ReflectionException
+ * @throws AssertionFailedError
+ * @throws InvalidArgumentException
+ * @throws RuntimeException
+ * @throws UnknownLocaleException
+ * @throws ReflectionException
*/
public function assertDayOfWeek($provider, $shortName, $year, $expectedDayOfWeek): void
{
$holidays = Yasumi::create($provider, $year);
- $holiday = $holidays->getHoliday($shortName);
+ $holiday = $holidays->getHoliday($shortName);
$this->assertInstanceOf('Yasumi\Provider\\' . \str_replace('/', '\\', $provider), $holidays);
$this->assertInstanceOf(Holiday::class, $holiday);
@@ -225,21 +245,22 @@ public function assertDayOfWeek($provider, $shortName, $year, $expectedDayOfWeek
/**
* Returns a list of random test dates used for assertion of holidays.
*
- * @param int $month month (number) for which the test date needs to be generated
- * @param int $day day (number) for which the test date needs to be generated
- * @param string $timezone name of the timezone for which the dates need to be generated
- * @param int $iterations number of iterations (i.e. samples) that need to be generated (default: 10)
- * @param int $range year range from which dates will be generated (default: 1000)
+ * @param int $month month (number) for which the test date needs to be generated
+ * @param int $day day (number) for which the test date needs to be generated
+ * @param string $timezone name of the timezone for which the dates need to be generated
+ * @param int $iterations number of iterations (i.e. samples) that need to be generated (default: 10)
+ * @param int $range year range from which dates will be generated (default: 1000)
*
* @return array list of random test dates used for assertion of holidays.
- * @throws \Exception
+ * @throws Exception
*/
- public function generateRandomDates($month, $day, $timezone = 'UTC', $iterations = 10, $range = 1000): array
+ public function generateRandomDates($month, $day, $timezone = null, $iterations = null, $range = null): array
{
$data = [];
- for ($y = 1; $y <= $iterations; $y++) {
- $year = Faker::create()->dateTimeBetween("-$range years", "+$range years")->format('Y');
- $data[] = [$year, new DateTime("$year-$month-$day", new DateTimeZone($timezone))];
+ $range = $range ?? 1000;
+ for ($y = 1; $y <= ($iterations ?? 10); $y++) {
+ $year = (int)Faker::create()->dateTimeBetween("-$range years", "+$range years")->format('Y');
+ $data[] = [$year, new DateTime("$year-$month-$day", new DateTimeZone($timezone ?? 'UTC'))];
}
return $data;
@@ -248,20 +269,21 @@ public function generateRandomDates($month, $day, $timezone = 'UTC', $iterations
/**
* Returns a list of random easter test dates used for assertion of holidays.
*
- * @param string $timezone name of the timezone for which the dates need to be generated
- * @param int $iterations number of iterations (i.e. samples) that need to be generated (default: 10)
- * @param int $range year range from which dates will be generated (default: 1000)
+ * @param string $timezone name of the timezone for which the dates need to be generated
+ * @param int $iterations number of iterations (i.e. samples) that need to be generated (default: 10)
+ * @param int $range year range from which dates will be generated (default: 1000)
*
* @return array list of random easter test dates used for assertion of holidays.
- * @throws \Exception
+ * @throws Exception
*/
- public function generateRandomEasterDates($timezone = 'UTC', $iterations = 10, $range = 1000): array
+ public function generateRandomEasterDates($timezone = null, $iterations = null, $range = null): array
{
$data = [];
+ $range = $range ?? 1000;
- for ($i = 1; $i <= $iterations; ++$i) {
- $year = Faker::create()->dateTimeBetween("-$range years", "+$range years")->format('Y');
- $date = $this->calculateEaster($year, $timezone);
+ for ($i = 1; $i <= ($iterations ?? 10); ++$i) {
+ $year = (int)Faker::create()->dateTimeBetween("-$range years", "+$range years")->format('Y');
+ $date = $this->calculateEaster($year, $timezone ?? 'UTC');
$data[] = [$year, $date->format('Y-m-d')];
}
@@ -281,17 +303,17 @@ public function generateRandomEasterDates($timezone = 'UTC', $iterations = 10, $
*
* Note: In calendrical calculations, frequently operations called integer division are used.
*
+ * @param int $year the year for which Easter needs to be calculated
+ * @param string $timezone the timezone in which Easter is celebrated
+ *
+ * @return DateTime date of Easter
+ * @throws Exception
* @see easter_days
*
* @link https://github.com/php/php-src/blob/c8aa6f3a9a3d2c114d0c5e0c9fdd0a465dbb54a5/ext/calendar/easter.c
* @link http://www.gmarts.org/index.php?go=415#EasterMallen
* @link http://www.tondering.dk/claus/cal/easter.php
*
- * @param int $year the year for which Easter needs to be calculated
- * @param string $timezone the timezone in which Easter is celebrated
- *
- * @return \DateTime date of Easter
- * @throws \Exception
*/
protected function calculateEaster(int $year, string $timezone): DateTime
{
@@ -330,7 +352,7 @@ protected function calculateEaster(int $year, string $timezone): DateTime
}
// Corrected date of the Paschal full moon, - days after 21st March
- if (($pfm === 29) || ($pfm === 28 && $golden > 11)) {
+ if ((29 === $pfm) || (28 === $pfm && $golden > 11)) {
--$pfm;
}
@@ -351,43 +373,44 @@ protected function calculateEaster(int $year, string $timezone): DateTime
/**
* Returns a list of random Easter Monday test dates used for assertion of holidays.
*
- * @param string $timezone name of the timezone for which the dates need to be generated
- * @param int $iterations number of iterations (i.e. samples) that need to be generated (default: 10)
- * @param int $range year range from which dates will be generated (default: 1000)
+ * @param string $timezone name of the timezone for which the dates need to be generated
+ * @param int $iterations number of iterations (i.e. samples) that need to be generated (default: 10)
+ * @param int $range year range from which dates will be generated (default: 1000)
*
* @return array list of random Easter Monday test dates used for assertion of holidays.
*
- * @throws \Exception
+ * @throws Exception
*/
- public function generateRandomEasterMondayDates($timezone = 'UTC', $iterations = 10, $range = 1000): array
+ public function generateRandomEasterMondayDates($timezone = null, $iterations = null, $range = null): array
{
- return $this->generateRandomModifiedEasterDates(function (DateTime $date) {
+ $range = $range ?? 1000;
+ return $this->generateRandomModifiedEasterDates(static function (DateTime $date) {
$date->add(new DateInterval('P1D'));
- }, $timezone, $iterations, $range);
+ }, $timezone ?? 'UTC', $iterations ?? 10, $range);
}
/**
* Returns a list of random modified Easter day test dates for assertion of holidays.
*
- * @param callable $cb callback(DateTime $date) to modify $date by custom rules
- * @param string $timezone name of the timezone for which the dates need to be generated
- * @param int $iterations number of iterations (i.e. samples) that need to be generated (default: 10)
- * @param int $range year range from which dates will be generated (default: 1000)
+ * @param callable $cb callback(DateTime $date) to modify $date by custom rules
+ * @param string $timezone name of the timezone for which the dates need to be generated
+ * @param int $iterations number of iterations (i.e. samples) that need to be generated (default: 10)
+ * @param int $range year range from which dates will be generated (default: 1000)
*
* @return array list of random modified Easter day test dates for assertion of holidays.
- * @throws \Exception
+ * @throws Exception
*/
public function generateRandomModifiedEasterDates(
callable $cb,
- $timezone = 'UTC',
- $iterations = 10,
- $range = 1000
+ $timezone = null,
+ $iterations = null,
+ $range = null
): array {
$data = [];
-
- for ($i = 1; $i <= $iterations; ++$i) {
- $year = Faker::create()->dateTimeBetween("-$range years", "+$range years")->format('Y');
- $date = $this->calculateEaster($year, $timezone);
+ $range = $range ?? 1000;
+ for ($i = 1; $i <= ($iterations ?? 10); ++$i) {
+ $year = (int)Faker::create()->dateTimeBetween("-$range years", "+$range years")->format('Y');
+ $date = $this->calculateEaster($year, $timezone ?? 'UTC');
$cb($date);
@@ -400,84 +423,88 @@ public function generateRandomModifiedEasterDates(
/**
* Returns a list of random Good Friday test dates used for assertion of holidays.
*
- * @param string $timezone name of the timezone for which the dates need to be generated
- * @param int $iterations number of iterations (i.e. samples) that need to be generated (default: 10)
- * @param int $range year range from which dates will be generated (default: 1000)
+ * @param string $timezone name of the timezone for which the dates need to be generated
+ * @param int $iterations number of iterations (i.e. samples) that need to be generated (default: 10)
+ * @param int $range year range from which dates will be generated (default: 1000)
*
* @return array list of random Good Friday test dates used for assertion of holidays.
*
- * @throws \Exception
+ * @throws Exception
*/
- public function generateRandomGoodFridayDates($timezone = 'UTC', $iterations = 10, $range = 1000): array
+ public function generateRandomGoodFridayDates($timezone = null, $iterations = null, $range = null): array
{
- return $this->generateRandomModifiedEasterDates(function (DateTime $date) {
+ $range = $range ?? 1000;
+
+ return $this->generateRandomModifiedEasterDates(static function (DateTime $date) {
$date->sub(new DateInterval('P2D'));
- }, $timezone, $iterations, $range);
+ }, $timezone ?? 'UTC', $iterations ?? 10, $range);
}
/**
* Returns a list of random Pentecost test dates used for assertion of holidays.
*
- * @param string $timezone name of the timezone for which the dates need to be generated
- * @param int $iterations number of iterations (i.e. samples) that need to be generated (default: 10)
- * @param int $range year range from which dates will be generated (default: 1000)
+ * @param string $timezone name of the timezone for which the dates need to be generated
+ * @param int $iterations number of iterations (i.e. samples) that need to be generated (default: 10)
+ * @param int $range year range from which dates will be generated (default: 1000)
*
* @return array list of random Pentecost test dates used for assertion of holidays.
*
- * @throws \Exception
+ * @throws Exception
*/
- public function generateRandomPentecostDates($timezone = 'UTC', $iterations = 10, $range = 1000): array
+ public function generateRandomPentecostDates($timezone = null, $iterations = null, $range = null): array
{
- return $this->generateRandomModifiedEasterDates(function (DateTime $date) {
+ $range = $range ?? 1000;
+
+ return $this->generateRandomModifiedEasterDates(static function (DateTime $date) {
$date->add(new DateInterval('P49D'));
- }, $timezone, $iterations, $range);
+ }, $timezone ?? 'UTC', $iterations ?? 10, $range);
}
/**
* Returns a list of random test dates used for assertion of holidays. If the date falls in a weekend, random
* holiday day is moved to to Monday.
*
- * @param int $month month (number) for which the test date needs to be generated
- * @param int $day day (number) for which the test date needs to be generated
- * @param string $timezone name of the timezone for which the dates need to be generated
- * @param int $iterations number of iterations (i.e. samples) that need to be generated (default: 10)
- * @param int $range year range from which dates will be generated (default: 1000)
+ * @param int $month month (number) for which the test date needs to be generated
+ * @param int $day day (number) for which the test date needs to be generated
+ * @param string $timezone name of the timezone for which the dates need to be generated
+ * @param int $iterations number of iterations (i.e. samples) that need to be generated (default: 10)
+ * @param int $range year range from which dates will be generated (default: 1000)
*
* @return array list of random test dates used for assertion of holidays.
- * @throws \Exception
+ * @throws Exception
*/
public function generateRandomDatesWithHolidayMovedToMonday(
$month,
$day,
- $timezone = 'UTC',
- $iterations = 10,
- $range = 1000
+ $timezone = null,
+ $iterations = null,
+ $range = null
): array {
- return $this->generateRandomDatesWithModifier($month, $day, function ($year, \DateTime $date) {
+ return $this->generateRandomDatesWithModifier($month, $day, function ($range, DateTime $date) {
if ($this->isWeekend($date)) {
$date->modify('next monday');
}
- }, $timezone, $iterations, $range);
+ }, $timezone ?? 'UTC', $iterations ?? 10, $range);
}
/**
* Returns a list of random test dates used for assertion of holidays with applied callback.
*
- * @param int $month month (number) for which the test date needs to be generated
- * @param int $day day (number) for which the test date needs to be generated
- * @param callable $callback callback(int $year, \DateTime $dateTime) to modify $dateTime by custom rules
- * @param string $timezone name of the timezone for which the dates need to be generated
- * @param int $iterations number of iterations (i.e. samples) that need to be generated (default: 10)
- * @param int $range year range from which dates will be generated (default: 1000)
+ * @param int $month month (number) for which the test date needs to be generated
+ * @param int $day day (number) for which the test date needs to be generated
+ * @param callable $callback callback(int $year, \DateTime $dateTime) to modify $dateTime by custom rules
+ * @param string $timezone name of the timezone for which the dates need to be generated
+ * @param int $iterations number of iterations (i.e. samples) that need to be generated (default: 10)
+ * @param int $range year range from which dates will be generated (default: 1000)
*
* @return array list of random test dates used for assertion of holidays with applied callback.
- * @throws \Exception
+ * @throws Exception
*/
public function generateRandomDatesWithModifier(
$month,
$day,
callable $callback,
- $timezone = 'UTC',
+ $timezone = null,
$iterations,
$range
): array {
@@ -485,7 +512,7 @@ public function generateRandomDatesWithModifier(
for ($i = 1; $i <= $iterations; ++$i) {
$year = $this->generateRandomYear($range);
- $date = new \DateTime("{$year}-{$month}-{$day}", new \DateTimeZone($timezone));
+ $date = new DateTime("{$year}-{$month}-{$day}", new DateTimeZone($timezone ?? 'UTC'));
$callback($year, $date);
@@ -503,20 +530,20 @@ public function generateRandomDatesWithModifier(
*
* @return int a year number
*/
- public function generateRandomYear($lowerLimit = 1000, $upperLimit = 9999): int
+ public function generateRandomYear($lowerLimit = null, $upperLimit = null): int
{
- return (int)Faker::create()->numberBetween($lowerLimit, $upperLimit);
+ return (int)Faker::create()->numberBetween($lowerLimit ?? 1000, $upperLimit ?? 9999);
}
/**
* Checks if given $dateTime is a weekend.
*
- * @param \DateTimeInterface $dateTime date for which weekend will be checked.
- * @param array $weekendDays weekend days. Saturday and Sunday are used by default.
+ * @param DateTimeInterface $dateTime date for which weekend will be checked.
+ * @param array $weekendDays weekend days. Saturday and Sunday are used by default.
*
* @return bool true if $dateTime is a weekend, false otherwise
*/
- public function isWeekend(\DateTimeInterface $dateTime, array $weekendDays = [0, 6]): bool
+ public function isWeekend(DateTimeInterface $dateTime, array $weekendDays = [0, 6]): bool
{
return \in_array((int)$dateTime->format('w'), $weekendDays, true);
}
diff --git a/tests/YasumiTestCaseInterface.php b/tests/YasumiTestCaseInterface.php
index e98bb8835..0c5203db8 100644
--- a/tests/YasumiTestCaseInterface.php
+++ b/tests/YasumiTestCaseInterface.php
@@ -1,4 +1,4 @@
-