Skip to content

Commit 7ab7d2c

Browse files
committed
Add unit tests to show how to retrieve state and admin levels
1 parent 57ccbef commit 7ab7d2c

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

composer.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@
99
"homepage": "http://geocoder-php.org/",
1010
"license": "MIT",
1111
"authors": [
12-
{
13-
"name": "Antoine Corcy",
14-
"email": "[email protected]",
15-
"homepage": "http://sbin.dk",
16-
"role": "Developer"
17-
},
1812
{
1913
"name": "Mike Bronner",
2014
"email": "[email protected]",
2115
"homepage": "https://genealabs.com",
22-
"role": "developer"
16+
"role": "Developer, Maintainer"
17+
},
18+
{
19+
"name": "Antoine Corcy",
20+
"email": "[email protected]",
21+
"homepage": "http://sbin.dk",
22+
"role": "Original Creator"
2323
}
2424
],
2525
"require": {

tests/Laravel5_3/Providers/GeocoderServiceTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,4 +278,18 @@ public function testJapaneseCharacterGeocoding()
278278
$this->assertEquals($cacheKey, '108-0075e69db1e4baace983bde6b8afe58cbae6b8afe58d97efbc92e4b881e79baeefbc91efbc96efbc8defbc93');
279279
$this->assertTrue(app('cache')->has("geocoder-{$cacheKey}"));
280280
}
281+
282+
public function testItProvidesState()
283+
{
284+
$results = Geocoder::geocode('1600 Pennsylvania Ave., Washington, DC USA')->get();
285+
286+
$this->assertEquals('Washington', $results->first()->getLocality());
287+
}
288+
289+
public function testItProvidesAdminLevel()
290+
{
291+
$results = Geocoder::geocode('1600 Pennsylvania Ave., Washington, DC USA')->get();
292+
293+
$this->assertEquals('District of Columbia', $results->first()->getAdminLevels()->first()->getName());
294+
}
281295
}

0 commit comments

Comments
 (0)