Updated code to follow the PSR-2 style guidelines.
This commit is contained in:
@@ -8,7 +8,7 @@ class CountryTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
private $raw = array(
|
||||
'continent' => array(
|
||||
'continent' => array(
|
||||
'continent_code' => 'NA',
|
||||
'geoname_id' => 42,
|
||||
'names' => array( 'en' => 'North America' ),
|
||||
@@ -30,101 +30,133 @@ class CountryTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
private $model;
|
||||
|
||||
public function setUp () {
|
||||
$this->model = new Country($this->raw, ['en']);
|
||||
|
||||
public function setUp ()
|
||||
{
|
||||
$this->model = new Country($this->raw, ['en']);
|
||||
}
|
||||
|
||||
public function testObjects () {
|
||||
$this->assertInstanceOf('GeoIP2\Model\Country', $this->model,
|
||||
'minimal GeoIP2::Model::Country object');
|
||||
$this->assertInstanceOf('GeoIP2\Record\Continent', $this->model->continent);
|
||||
$this->assertInstanceOf('GeoIP2\Record\Country', $this->model->country);
|
||||
$this->assertInstanceOf('GeoIP2\Record\Country', $this->model->registeredCountry);
|
||||
$this->assertInstanceOf('GeoIP2\Record\RepresentedCountry',
|
||||
$this->model->representedCountry);
|
||||
$this->assertInstanceOf('GeoIP2\Record\Traits', $this->model->traits);
|
||||
}
|
||||
|
||||
public function testValues() {
|
||||
|
||||
$this->assertEquals(42, $this->model->continent->geonameId,
|
||||
'continent geoname_id is 42');
|
||||
|
||||
$this->assertEquals('NA', $this->model->continent->continentCode,
|
||||
'continent continent_code is NA');
|
||||
|
||||
$this->assertEquals(array( 'en' => 'North America' ),
|
||||
$this->model->continent->names,
|
||||
'continent names');
|
||||
|
||||
$this->assertEquals(
|
||||
'North America',
|
||||
$this->model->continent->name,
|
||||
'continent name is North America');
|
||||
|
||||
$this->assertEquals(
|
||||
1,
|
||||
$this->model->country->geonameId,
|
||||
'country geoname_id is 1'
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'US',
|
||||
$this->model->country->isoCode,
|
||||
'country iso_code is US'
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
array( 'en' => 'United States of America' ),
|
||||
$this->model->country->names,
|
||||
'country names'
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
$this->model->country->name,
|
||||
'United States of America',
|
||||
'country name is United States of America'
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
null,
|
||||
$this->model->country->confidence,
|
||||
'country confidence is undef'
|
||||
);
|
||||
|
||||
$this->assertEquals(2, $this->model->registeredCountry->geonameId,
|
||||
'registered_country geoname_id is 2'
|
||||
);
|
||||
|
||||
$this->assertEquals('CA',
|
||||
$this->model->registeredCountry->isoCode,
|
||||
'registered_country iso_code is CA'
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
array( 'en' => 'Canada' ),
|
||||
$this->model->registeredCountry->names,
|
||||
'registered_country names'
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'Canada',
|
||||
$this->model->registeredCountry->name,
|
||||
'registered_country name is Canada'
|
||||
);
|
||||
|
||||
foreach (array( 'isAnonymousProxy', 'isSatelliteProvider' ) as $meth) {
|
||||
|
||||
$this->assertEquals(0, $this->model->traits->$meth,
|
||||
"traits $meth returns 0 by default"
|
||||
public function testObjects ()
|
||||
{
|
||||
$this->assertInstanceOf(
|
||||
'GeoIP2\Model\Country',
|
||||
$this->model,
|
||||
'minimal GeoIP2::Model::Country object'
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
'GeoIP2\Record\Continent',
|
||||
$this->model->continent
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
'GeoIP2\Record\Country',
|
||||
$this->model->country
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
'GeoIP2\Record\Country',
|
||||
$this->model->registeredCountry
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
'GeoIP2\Record\RepresentedCountry',
|
||||
$this->model->representedCountry
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
'GeoIP2\Record\Traits',
|
||||
$this->model->traits
|
||||
);
|
||||
}
|
||||
|
||||
$this->assertEquals(
|
||||
$this->raw,
|
||||
$this->model->raw,
|
||||
'raw method returns raw input'
|
||||
);
|
||||
public function testValues()
|
||||
{
|
||||
|
||||
$this->assertEquals(
|
||||
42,
|
||||
$this->model->continent->geonameId,
|
||||
'continent geoname_id is 42'
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'NA',
|
||||
$this->model->continent->continentCode,
|
||||
'continent continent_code is NA'
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
array( 'en' => 'North America' ),
|
||||
$this->model->continent->names,
|
||||
'continent names'
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'North America',
|
||||
$this->model->continent->name,
|
||||
'continent name is North America'
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
1,
|
||||
$this->model->country->geonameId,
|
||||
'country geoname_id is 1'
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'US',
|
||||
$this->model->country->isoCode,
|
||||
'country iso_code is US'
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
array( 'en' => 'United States of America' ),
|
||||
$this->model->country->names,
|
||||
'country name'
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
$this->model->country->name,
|
||||
'United States of America',
|
||||
'country name is United States of America'
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
null,
|
||||
$this->model->country->confidence,
|
||||
'country confidence is undef'
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
2,
|
||||
$this->model->registeredCountry->geonameId,
|
||||
'registered_country geoname_id is 2'
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'CA',
|
||||
$this->model->registeredCountry->isoCode,
|
||||
'registered_country iso_code is CA'
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
array( 'en' => 'Canada' ),
|
||||
$this->model->registeredCountry->names,
|
||||
'registered_country names'
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'Canada',
|
||||
$this->model->registeredCountry->name,
|
||||
'registered_country name is Canada'
|
||||
);
|
||||
|
||||
foreach (array( 'isAnonymousProxy', 'isSatelliteProvider' ) as $meth) {
|
||||
$this->assertEquals(
|
||||
0,
|
||||
$this->model->traits->$meth,
|
||||
"traits $meth returns 0 by default"
|
||||
);
|
||||
}
|
||||
|
||||
$this->assertEquals(
|
||||
$this->raw,
|
||||
$this->model->raw,
|
||||
'raw method returns raw input'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user