Update for GeoIP2 web services v2.1

This commit is contained in:
Gregory Oschwald
2014-07-15 14:19:30 -07:00
parent 6b919b4cba
commit a5fe44c3d3
17 changed files with 134 additions and 130 deletions
+18 -14
View File
@@ -198,18 +198,22 @@ class ClientTest extends \PHPUnit_Framework_TestCase
}
public function testOmni()
public function testInsights()
{
$omni = $this->client($this->getResponse('1.2.3.4'))
->omni('1.2.3.4');
$this->assertInstanceOf('GeoIp2\Model\Omni', $omni);
$methods = array('omni', 'insights');
foreach ($methods as $method) {
$record = $this->client($this->getResponse('1.2.3.4'))
->$method('1.2.3.4');
$this->assertEquals(
42,
$omni->continent->geonameId,
'continent geoname_id is 42'
);
$this->assertInstanceOf('GeoIp2\Model\Insights', $record);
$this->assertEquals(
42,
$record->continent->geonameId,
'continent geoname_id is 42'
);
}
}
public function testCity()
@@ -225,7 +229,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
$client = $this->client($this->getResponse('me'));
$this->assertInstanceOf(
'GeoIp2\Model\CityIspOrg',
'GeoIp2\Model\City',
$client->cityIspOrg('me'),
'can set ip parameter to me'
);
@@ -233,7 +237,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
/**
* @expectedException GeoIp2\Exception\GeoIp2Exception
* @expectedExceptionMessage Received a 200 response for https://geoip.maxmind.com/geoip/v2.0/country/1.2.3.5 but did not receive a HTTP body.
* @expectedExceptionMessage Received a 200 response for https://geoip.maxmind.com/geoip/v2.1/country/1.2.3.5 but did not receive a HTTP body.
*/
public function testNoBodyException()
{
@@ -244,7 +248,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
/**
* @expectedException GeoIp2\Exception\GeoIp2Exception
* @expectedExceptionMessage Received a 200 response for https://geoip.maxmind.com/geoip/v2.0/country/2.2.3.5 but could not decode the response as JSON:
* @expectedExceptionMessage Received a 200 response for https://geoip.maxmind.com/geoip/v2.1/country/2.2.3.5 but could not decode the response as JSON:
*/
public function testBadBodyException()
{
@@ -332,7 +336,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
/**
* @expectedException GeoIp2\Exception\HttpException
* @expectedExceptionCode 406
* @expectedExceptionMessage Received a 406 error for https://geoip.maxmind.com/geoip/v2.0/country/1.2.3.12 with the following body: Cannot satisfy your Accept-Charset requirements
* @expectedExceptionMessage Received a 406 error for https://geoip.maxmind.com/geoip/v2.1/country/1.2.3.12 with the following body: Cannot satisfy your Accept-Charset requirements
*/
public function test406Exception()
{
@@ -426,7 +430,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
$request = $all_requests[0];
$this->assertEquals(
'https://geoip.maxmind.com/geoip/v2.0/country/1.2.3.4',
'https://geoip.maxmind.com/geoip/v2.1/country/1.2.3.4',
$request->getUrl(),
'got expected URI for Country request'
);