From 12f1ea69f8c395e0bf3c623aeb2be3fe897d329d Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Tue, 3 Mar 2020 21:51:57 -0600 Subject: [PATCH] feat: filter out countries without public holidays Fairly minor update, no code change, just added a new test to cover the flag that was recently added to the API and expanded the documentation to also include it. --- README.md | 8 ++++++++ composer.json | 2 +- tests/ClientTest.php | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5712dd2..e3e827e 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,14 @@ try { $holiday_api->countries(); ``` +#### Fetch only countries with public holidays + +```php +$holiday_api->countries([ + 'public' => true, +]); +``` + #### Fetch a supported country by code ```php diff --git a/composer.json b/composer.json index cefa821..93d9423 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "holidayapi/holidayapi-php", "description": "Official PHP library for Holiday API", - "version": "2.2.0", + "version": "2.2.1", "type": "library", "keywords": [ "calendar", diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 267d572..30a96b3 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -165,6 +165,40 @@ class ClientTest extends \PHPUnit_Framework_TestCase ), $client->countries(array('country' => 'ST'))); } + public function testReturnCountryWithPublic() + { + $url = self::BASE_URL . 'countries?key=' . self::KEY . '&public=1'; + + $request = new Request(array( + 'execute' => array( + $url => function () + { + return json_encode(array( + 'status' => 200, + 'countries' => array( + array( + 'code' => 'ST', + 'name' => 'Sao Tome and Principle', + ), + ), + )); + }, + ), + )); + + $client = new Client(array('key' => self::KEY, 'handler' => $request)); + + $this->assertEquals(array( + 'status' => 200, + 'countries' => array( + array( + 'code' => 'ST', + 'name' => 'Sao Tome and Principle', + ), + ), + ), $client->countries(array('public' => true))); + } + public function testCountriesRaise4xxErrors() { $url = self::BASE_URL . 'countries?key=' . self::KEY;