Skip to content

Commit 6cb7ff4

Browse files
authored
Merge pull request #82 from maxmind/greg/most-specific-subdivision-isset
Fix isset on mostSpecificSubdivision. Closes #81
2 parents 93eafde + 88b923d commit 6cb7ff4

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

CHANGELOG.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
CHANGELOG
22
=========
33

4+
2.4.4 (2016-10-11)
5+
------------------
6+
7+
* `isset()` on `mostSpecificSubdivision` attribute now returns the
8+
correct value. Reported by Juan Francisco Giordana. GitHub #81.
9+
410
2.4.3 (2016-10-11)
511
------------------
612

7-
* `isset()` on `name` attribute now returns the correct value. Fixes #79.
13+
* `isset()` on `name` attribute now returns the correct value. Reported by
14+
Juan Francisco Giordana. GitHub #79.
815

916
2.4.2 (2016-08-17)
1017
------------------
1118

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

1724
2.4.1 (2016-06-10)

src/Model/City.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,20 @@ public function __get($attr)
113113
}
114114
}
115115

116+
/**
117+
* @ignore
118+
*/
119+
public function __isset($attr)
120+
{
121+
if ($attr == 'mostSpecificSubdivision') {
122+
// We always return a mostSpecificSubdivision, even if it is the
123+
// empty subdivision
124+
return true;
125+
} else {
126+
return parent::__isset($attr);
127+
}
128+
}
129+
116130
private function mostSpecificSubdivision()
117131
{
118132
return empty($this->subdivisions) ?

tests/GeoIp2/Test/Model/InsightsTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,11 @@ public function testEmptyObjects()
229229
'$model->mostSpecificSubdivision'
230230
);
231231

232+
$this->assertTrue(
233+
isset($model->mostSpecificSubdivision),
234+
'mostSpecificSubdivision is set'
235+
);
236+
232237
$this->assertInstanceOf(
233238
'GeoIp2\Record\Traits',
234239
$model->traits,
@@ -271,4 +276,14 @@ public function testUnknown()
271276
'raw method returns raw input'
272277
);
273278
}
279+
280+
public function testMostSpecificSubdivisionWithNoSubdivisions()
281+
{
282+
$model = new Insights(array(), array('en'));
283+
284+
$this->assertTrue(
285+
isset($model->mostSpecificSubdivision),
286+
'mostSpecificSubdivision is set even on an empty response'
287+
);
288+
}
274289
}

0 commit comments

Comments
 (0)