mirror of
https://github.com/holidayapi/holidayapi-php.git
synced 2025-06-21 12:16:31 +00:00
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.
This commit is contained in:
parent
054eab9c02
commit
12f1ea69f8
3 changed files with 43 additions and 1 deletions
|
@ -67,6 +67,14 @@ try {
|
||||||
$holiday_api->countries();
|
$holiday_api->countries();
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Fetch only countries with public holidays
|
||||||
|
|
||||||
|
```php
|
||||||
|
$holiday_api->countries([
|
||||||
|
'public' => true,
|
||||||
|
]);
|
||||||
|
```
|
||||||
|
|
||||||
#### Fetch a supported country by code
|
#### Fetch a supported country by code
|
||||||
|
|
||||||
```php
|
```php
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "holidayapi/holidayapi-php",
|
"name": "holidayapi/holidayapi-php",
|
||||||
"description": "Official PHP library for Holiday API",
|
"description": "Official PHP library for Holiday API",
|
||||||
"version": "2.2.0",
|
"version": "2.2.1",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"calendar",
|
"calendar",
|
||||||
|
|
|
@ -165,6 +165,40 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
||||||
), $client->countries(array('country' => 'ST')));
|
), $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()
|
public function testCountriesRaise4xxErrors()
|
||||||
{
|
{
|
||||||
$url = self::BASE_URL . 'countries?key=' . self::KEY;
|
$url = self::BASE_URL . 'countries?key=' . self::KEY;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue