Skip to content

Commit

Permalink
Merge pull request #82 from maxmind/greg/most-specific-subdivision-isset
Browse files Browse the repository at this point in the history
Fix isset on mostSpecificSubdivision. Closes #81
  • Loading branch information
klp2 authored Oct 11, 2016
2 parents 93eafde + 88b923d commit 6cb7ff4
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
CHANGELOG
=========

2.4.4 (2016-10-11)
------------------

* `isset()` on `mostSpecificSubdivision` attribute now returns the
correct value. Reported by Juan Francisco Giordana. GitHub #81.

2.4.3 (2016-10-11)
------------------

* `isset()` on `name` attribute now returns the correct value. Fixes #79.
* `isset()` on `name` attribute now returns the correct value. Reported by
Juan Francisco Giordana. GitHub #79.

2.4.2 (2016-08-17)
------------------

* Updated documentation to clarify what the accuracy radius refers to.
* Upgraded `maxmind/web-service-common` to 0.3.0. This version uses
`composer/ca-bundle` rather than our own CA bundle. Fixes #75.
`composer/ca-bundle` rather than our own CA bundle. GitHub #75.
* Improved PHP documentation generation.

2.4.1 (2016-06-10)
Expand Down
14 changes: 14 additions & 0 deletions src/Model/City.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,20 @@ public function __get($attr)
}
}

/**
* @ignore
*/
public function __isset($attr)
{
if ($attr == 'mostSpecificSubdivision') {
// We always return a mostSpecificSubdivision, even if it is the
// empty subdivision
return true;
} else {
return parent::__isset($attr);
}
}

private function mostSpecificSubdivision()
{
return empty($this->subdivisions) ?
Expand Down
15 changes: 15 additions & 0 deletions tests/GeoIp2/Test/Model/InsightsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@ public function testEmptyObjects()
'$model->mostSpecificSubdivision'
);

$this->assertTrue(
isset($model->mostSpecificSubdivision),
'mostSpecificSubdivision is set'
);

$this->assertInstanceOf(
'GeoIp2\Record\Traits',
$model->traits,
Expand Down Expand Up @@ -271,4 +276,14 @@ public function testUnknown()
'raw method returns raw input'
);
}

public function testMostSpecificSubdivisionWithNoSubdivisions()
{
$model = new Insights(array(), array('en'));

$this->assertTrue(
isset($model->mostSpecificSubdivision),
'mostSpecificSubdivision is set even on an empty response'
);
}
}

0 comments on commit 6cb7ff4

Please sign in to comment.