Tidying and doc fixes

This commit is contained in:
Gregory Oschwald
2013-10-21 06:18:12 -07:00
parent 234dcaff7c
commit e03b9558a9
13 changed files with 102 additions and 104 deletions
+12 -12
View File
@@ -9,19 +9,19 @@ class CountryTest extends \PHPUnit_Framework_TestCase
private $raw = array(
'continent' => array(
'code' => 'NA',
'code' => 'NA',
'geoname_id' => 42,
'names' => array( 'en' => 'North America' ),
'names' => array('en' => 'North America'),
),
'country' => array(
'geoname_id' => 1,
'iso_code' => 'US',
'names' => array( 'en' => 'United States of America' ),
'iso_code' => 'US',
'names' => array('en' => 'United States of America'),
),
'registered_country' => array(
'geoname_id' => 2,
'iso_code' => 'CA',
'names' => array( 'en' => 'Canada' ),
'iso_code' => 'CA',
'names' => array('en' => 'Canada'),
),
'traits' => array(
'ip_address' => '1.2.3.4',
@@ -30,12 +30,12 @@ class CountryTest extends \PHPUnit_Framework_TestCase
private $model;
public function setUp ()
public function setUp()
{
$this->model = new Country($this->raw, array('en'));
}
public function testObjects ()
public function testObjects()
{
$this->assertInstanceOf(
'GeoIp2\Model\Country',
@@ -80,7 +80,7 @@ class CountryTest extends \PHPUnit_Framework_TestCase
);
$this->assertEquals(
array( 'en' => 'North America' ),
array('en' => 'North America'),
$this->model->continent->names,
'continent names'
);
@@ -104,7 +104,7 @@ class CountryTest extends \PHPUnit_Framework_TestCase
);
$this->assertEquals(
array( 'en' => 'United States of America' ),
array('en' => 'United States of America'),
$this->model->country->names,
'country name'
);
@@ -134,7 +134,7 @@ class CountryTest extends \PHPUnit_Framework_TestCase
);
$this->assertEquals(
array( 'en' => 'Canada' ),
array('en' => 'Canada'),
$this->model->registeredCountry->names,
'registered_country names'
);
@@ -145,7 +145,7 @@ class CountryTest extends \PHPUnit_Framework_TestCase
'registered_country name is Canada'
);
foreach (array( 'isAnonymousProxy', 'isSatelliteProvider' ) as $meth) {
foreach (array('isAnonymousProxy', 'isSatelliteProvider') as $meth) {
$this->assertEquals(
0,
$this->model->traits->$meth,
+20 -20
View File
@@ -7,31 +7,31 @@ use GeoIp2\Model\Country;
class NameTest extends \PHPUnit_Framework_TestCase
{
public $raw = array(
'continent' => array(
'code' => 'NA',
'geoname_id' => 42,
'names' => array(
'en' => 'North America',
'zh-CN' => '北美洲',
),
'continent' => array(
'code' => 'NA',
'geoname_id' => 42,
'names' => array(
'en' => 'North America',
'zh-CN' => '北美洲',
),
'country' => array(
'geoname_id' => 1,
'iso_code' => 'US',
'names' => array(
'en' => 'United States of America',
'ru' => 'объединяет государства',
'zh-CN' => '美国',
),
),
'country' => array(
'geoname_id' => 1,
'iso_code' => 'US',
'names' => array(
'en' => 'United States of America',
'ru' => 'объединяет государства',
'zh-CN' => '美国',
),
'traits' => array(
'ip_address' => '1.2.3.4',
),
);
),
'traits' => array(
'ip_address' => '1.2.3.4',
),
);
public function testFallback()
{
$model = new Country($this->raw, array( 'ru', 'zh-CN', 'en' ));
$model = new Country($this->raw, array('ru', 'zh-CN', 'en'));
$this->assertEquals(
'北美洲',
+30 -30
View File
@@ -14,58 +14,58 @@ class OmniTest extends \PHPUnit_Framework_TestCase
'city' => array(
'confidence' => 76,
'geoname_id' => 9876,
'names' => array( 'en' => 'Minneapolis' ),
'names' => array('en' => 'Minneapolis'),
),
'continent' => array(
'code' => 'NA',
'code' => 'NA',
'geoname_id' => 42,
'names' => array( 'en' => 'North America' ),
'names' => array('en' => 'North America'),
),
'country' => array(
'confidence' => 99,
'geoname_id' => 1,
'iso_code' => 'US',
'names' => array( 'en' => 'United States of America' ),
'iso_code' => 'US',
'names' => array('en' => 'United States of America'),
),
'location' => array(
'accuracy_radius' => 1500,
'latitude' => 44.98,
'longitude' => 93.2636,
'metro_code' => 765,
'postal_code' => '55401',
'accuracy_radius' => 1500,
'latitude' => 44.98,
'longitude' => 93.2636,
'metro_code' => 765,
'postal_code' => '55401',
'postal_confidence' => 33,
'time_zone' => 'America/Chicago',
'time_zone' => 'America/Chicago',
),
'maxmind' => array(
'queries_remaining' => 22,
),
'registered_country' => array(
'geoname_id' => 2,
'iso_code' => 'CA',
'names' => array( 'en' => 'Canada' ),
'iso_code' => 'CA',
'names' => array('en' => 'Canada'),
),
'represented_country' => array(
'geoname_id' => 3,
'iso_code' => 'GB',
'names' => array( 'en' => 'United Kingdom' ),
'iso_code' => 'GB',
'names' => array('en' => 'United Kingdom'),
),
'subdivisions' => array(
array(
'confidence' => 88,
'geoname_id' => 574635,
'iso_code' => 'MN',
'names' => array( 'en' => 'Minnesota' ),
'iso_code' => 'MN',
'names' => array('en' => 'Minnesota'),
)
),
'traits' => array(
'autonomous_system_number' => 1234,
'autonomous_system_number' => 1234,
'autonomous_system_organization' => 'AS Organization',
'domain' => 'example.com',
'ip_address' => '1.2.3.4',
'is_satellite_provider' => 1,
'isp' => 'Comcast',
'organization' => 'Blorg',
'user_type' => 'college',
'domain' => 'example.com',
'ip_address' => '1.2.3.4',
'is_satellite_provider' => 1,
'isp' => 'Comcast',
'organization' => 'Blorg',
'user_type' => 'college',
),
);
@@ -145,7 +145,7 @@ class OmniTest extends \PHPUnit_Framework_TestCase
public function testEmptyObjects()
{
$raw = array( 'traits' => array( 'ip_address' => '5.6.7.8' ) );
$raw = array('traits' => array('ip_address' => '5.6.7.8'));
$model = new Omni($raw, array('en'));
@@ -220,14 +220,14 @@ class OmniTest extends \PHPUnit_Framework_TestCase
public function testUnknown()
{
$raw = array(
'new_top_level' => array( 'foo' => 42 ),
'city' => array(
'new_top_level' => array('foo' => 42),
'city' => array(
'confidence' => 76,
'geoname_id_id' => 9876,
'names' => array( 'en' => 'Minneapolis' ),
'geoname_id_id' => 9876,
'names' => array('en' => 'Minneapolis'),
'population' => 50,
),
'traits' => array( 'ip_address' => '5.6.7.8' )
'traits' => array('ip_address' => '5.6.7.8')
);
// checking whether there are exceptions with unknown keys
+22 -22
View File
@@ -13,14 +13,14 @@ class ClientTest extends \PHPUnit_Framework_TestCase
private $country
= array(
'continent' => array(
'code' => 'NA',
'code' => 'NA',
'geoname_id' => 42,
'names' => array( 'en' => 'North America' ),
'names' => array('en' => 'North America'),
),
'country' => array(
'geoname_id' => 1,
'iso_code' => 'US',
'names' => array( 'en' => 'United States of America' ),
'iso_code' => 'US',
'names' => array('en' => 'United States of America'),
),
'maxmind' => array('queries_remaining' => 11),
'traits' => array(
@@ -44,11 +44,11 @@ class ClientTest extends \PHPUnit_Framework_TestCase
),
'1.2.3.5' => $this->response('country', 200),
'2.2.3.5' => $this->response('country', 200, 'bad body'),
'1.2.3.6'=> $this->response(
'1.2.3.6' => $this->response(
'error',
400,
array(
'code' => 'IP_ADDRESS_INVALID',
'code' => 'IP_ADDRESS_INVALID',
'error' => 'The value "1.2.3" is not a valid ip address'
)
),
@@ -59,7 +59,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
'1.2.3.8' => $this->response(
'error',
400,
array( 'weird' => 42 )
array('weird' => 42)
),
'1.2.3.9' => $this->response(
'error',
@@ -82,51 +82,51 @@ class ClientTest extends \PHPUnit_Framework_TestCase
null,
'text/plain'
),
'1.2.3.13'=> $this->response(
'1.2.3.13' => $this->response(
'error',
404,
array(
'code' => 'IP_ADDRESS_NOT_FOUND',
'code' => 'IP_ADDRESS_NOT_FOUND',
'error' => 'The address "1.2.3.13" is not in our database.'
)
),
'1.2.3.14'=> $this->response(
'1.2.3.14' => $this->response(
'error',
400,
array(
'code' => 'IP_ADDRESS_RESERVED',
'code' => 'IP_ADDRESS_RESERVED',
'error' => 'The address "1.2.3.14" is a private address.'
)
),
'1.2.3.15'=> $this->response(
'1.2.3.15' => $this->response(
'error',
401,
array(
'code' => 'AUTHORIZATION_INVALID',
'code' => 'AUTHORIZATION_INVALID',
'error' => 'A user ID and license key are required to use this service'
)
),
'1.2.3.16'=> $this->response(
'1.2.3.16' => $this->response(
'error',
401,
array(
'code' => 'LICENSE_KEY_REQUIRED',
'code' => 'LICENSE_KEY_REQUIRED',
'error' => 'A license key is required to use this service'
)
),
'1.2.3.17'=> $this->response(
'1.2.3.17' => $this->response(
'error',
401,
array(
'code' => 'USER_ID_REQUIRED',
'code' => 'USER_ID_REQUIRED',
'error' => 'A user ID is required to use this service'
)
),
'1.2.3.18'=> $this->response(
'1.2.3.18' => $this->response(
'error',
402,
array(
'code' => 'OUT_OF_QUERIES',
'code' => 'OUT_OF_QUERIES',
'error' => 'The license key you have provided is out of queries.'
)
),
@@ -178,7 +178,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
);
$this->assertEquals(
array( 'en' => 'United States of America' ),
array('en' => 'United States of America'),
$country->country->names,
'country names'
);
@@ -478,7 +478,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
$headers = array();
if ($contentType) {
$headers['Content-Type'] = $contentType;
} elseif ($status == 200 || ( $status >= 400 && $status < 500 )) {
} elseif ($status == 200 || ($status >= 400 && $status < 500)) {
$headers['Content-Type'] = 'application/vnd.maxmind.com-'
. $endpoint . '+json; charset=UTF-8; version=1.0;';
}
@@ -486,7 +486,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
if ($bad) {
$body = '{ invalid: }';
} elseif (is_array($body)) {
$body = json_encode($body);
$body = json_encode($body);
}
$headers['Content-Length'] = strlen($body);
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
if (!$loader = @include __DIR__.'/../vendor/autoload.php') {
if (!$loader = @include __DIR__ . '/../vendor/autoload.php') {
die('Project dependencies missing');
}