mirror of
https://github.com/holidayapi/holidayapi-php.git
synced 2025-06-21 12:16:31 +00:00
feat: pull country or language by code
* feat: pull country or language by code. This differs from the existing `search` functionality in that it allows you to explicitly pull back a single country or language instead of anything that matches (which could result in more items returned than expected). * docs(readme): update to include examples for new functionality. * test: expand tests to include new parameters. * fix(client): dropped some commented out code that wasn't in use. * docs(license): bump the year of the license.
This commit is contained in:
parent
0f45ca781a
commit
054eab9c02
5 changed files with 88 additions and 30 deletions
|
@ -131,6 +131,40 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
|||
), $client->countries(array('search' => 'Sao')));
|
||||
}
|
||||
|
||||
public function testReturnCountryByCode()
|
||||
{
|
||||
$url = self::BASE_URL . 'countries?key=' . self::KEY . '&country=ST';
|
||||
|
||||
$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('country' => 'ST')));
|
||||
}
|
||||
|
||||
public function testCountriesRaise4xxErrors()
|
||||
{
|
||||
$url = self::BASE_URL . 'countries?key=' . self::KEY;
|
||||
|
@ -434,6 +468,40 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
|||
), $client->languages(array('search' => 'Eng')));
|
||||
}
|
||||
|
||||
public function testReturnLanguageByCode()
|
||||
{
|
||||
$url = self::BASE_URL . 'languages?key=' . self::KEY . '&language=en';
|
||||
|
||||
$request = new Request(array(
|
||||
'execute' => array(
|
||||
$url => function ()
|
||||
{
|
||||
return json_encode(array(
|
||||
'status' => 200,
|
||||
'languages' => array(
|
||||
array(
|
||||
'code' => 'en',
|
||||
'name' => 'English',
|
||||
),
|
||||
),
|
||||
));
|
||||
},
|
||||
),
|
||||
));
|
||||
|
||||
$client = new Client(array('key' => self::KEY, 'handler' => $request));
|
||||
|
||||
$this->assertEquals(array(
|
||||
'status' => 200,
|
||||
'languages' => array(
|
||||
array(
|
||||
'code' => 'en',
|
||||
'name' => 'English',
|
||||
),
|
||||
),
|
||||
), $client->languages(array('language' => 'en')));
|
||||
}
|
||||
|
||||
public function testLanguagesRaise4xxErrors()
|
||||
{
|
||||
$url = self::BASE_URL . 'languages?key=' . self::KEY;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue