Permalink
Browse files

Fix isset on mostSpecificSubdivision. Closes #81

  • Loading branch information...
1 parent 93eafde commit 88b923d548d72a7dec9f01054119238d18948dac @oschwald oschwald committed Oct 11, 2016
Showing with 38 additions and 2 deletions.
  1. +9 −2 CHANGELOG.md
  2. +14 −0 src/Model/City.php
  3. +15 −0 tests/GeoIp2/Test/Model/InsightsTest.php
View
@@ -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)
View
@@ -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) ?
@@ -229,6 +229,11 @@ public function testEmptyObjects()
'$model->mostSpecificSubdivision'
);
+ $this->assertTrue(
+ isset($model->mostSpecificSubdivision),
+ 'mostSpecificSubdivision is set'
+ );
+
$this->assertInstanceOf(
'GeoIp2\Record\Traits',
$model->traits,
@@ -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 88b923d

Please sign in to comment.