GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

MaxMindTest   A
last analyzed

Complexity

Total Complexity 26

Size/Duplication

Total Lines 370
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 8

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 26
c 2
b 0
f 0
lcom 1
cbo 8
dl 0
loc 370
rs 10

22 Methods

Rating   Name   Duplication   Size   Complexity  
A getCacheDir() 0 4 1
A testGetName() 0 5 1
A testGeocodeWithAddress() 0 5 1
A testGeocodeWithLocalhostIPv4() 0 14 1
A testGeocodeWithLocalhostIPv6() 0 14 1
A testGeocodeWithRealIPv4AndNotSupportedService() 0 5 1
A testGeocodeWithRealIPv6AndNotSupportedService() 0 5 1
A testGeocodeWithRealIPv4GetsFakeContent() 0 56 1
A testGeocodeWithRealIPv4AndInvalidApiKeyGetsFakeContent() 0 5 1
A testGeocodeOmniServiceWithRealIPv6AndInvalidApiKeyGetsFakeContent() 0 6 1
A testGeocodeWithRealIPv4AndInvalidApiKey() 0 5 1
A testGeocodeWithRealIPv4AndInvalidApiKeyGetsFakeContent2() 0 5 1
A testGeocodeOmniServiceWithRealIPv6AndInvalidApiKeyGetsFakeContent2() 0 6 1
A testGeocodeWithRealIPv4GetsFakeContentWithIpNotFound() 0 8 1
A testGeocodeOmniServiceWithRealIPv6GetsFakeContentWithIpNotFound() 0 9 1
A testGeocodeGetsFakeContentWithInvalidData() 0 5 1
B testGeocodeServiceWithRealIPv4() 0 30 2
B testGeocodeOmniServiceWithRealIPv4() 0 31 2
B testGeocodeOmniServiceWithRealIPv4WithSslAndEncoding() 0 31 2
B testGeocodeOmniServiceWithRealIPv6WithSsl() 0 31 2
A testReverse() 0 5 1
A testGeocodeWithRealIPv4GetsFakeContentFormattedEmpty() 0 22 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Geocoder package.
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license    MIT License
11
 */
12
13
namespace Geocoder\Provider\MaxMind\Tests;
14
15
use Geocoder\Collection;
16
use Geocoder\IntegrationTest\BaseTestCase;
17
use Geocoder\Location;
18
use Geocoder\Query\GeocodeQuery;
19
use Geocoder\Query\ReverseQuery;
20
use Geocoder\Provider\MaxMind\MaxMind;
21
22
class MaxMindTest extends BaseTestCase
23
{
24
    protected function getCacheDir()
25
    {
26
        return __DIR__.'/.cached_responses';
27
    }
28
29
    public function testGetName()
30
    {
31
        $provider = new MaxMind($this->getMockedHttpClient(), 'api_key');
32
        $this->assertEquals('maxmind', $provider->getName());
33
    }
34
35
    /**
36
     * @expectedException \Geocoder\Exception\UnsupportedOperation
37
     * @expectedExceptionMessage The MaxMind provider does not support street addresses, only IP addresses.
38
     */
39
    public function testGeocodeWithAddress()
40
    {
41
        $provider = new MaxMind($this->getMockedHttpClient(), 'api_key');
42
        $provider->geocodeQuery(GeocodeQuery::create('10 avenue Gambetta, Paris, France'));
43
    }
44
45
    public function testGeocodeWithLocalhostIPv4()
46
    {
47
        $provider = new MaxMind($this->getMockedHttpClient(), 'api_key');
48
        $results = $provider->geocodeQuery(GeocodeQuery::create('127.0.0.1'));
49
50
        $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results);
51
        $this->assertCount(1, $results);
52
53
        /** @var Location $result */
54
        $result = $results->first();
55
        $this->assertInstanceOf('\Geocoder\Model\Address', $result);
56
        $this->assertEquals('localhost', $result->getLocality());
57
        $this->assertEquals('localhost', $result->getCountry()->getName());
58
    }
59
60
    public function testGeocodeWithLocalhostIPv6()
61
    {
62
        $provider = new MaxMind($this->getMockedHttpClient(), 'api_key');
63
        $results = $provider->geocodeQuery(GeocodeQuery::create('::1'));
64
65
        $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results);
66
        $this->assertCount(1, $results);
67
68
        /** @var Location $result */
69
        $result = $results->first();
70
        $this->assertInstanceOf('\Geocoder\Model\Address', $result);
71
        $this->assertEquals('localhost', $result->getLocality());
72
        $this->assertEquals('localhost', $result->getCountry()->getName());
73
    }
74
75
    /**
76
     * @expectedException \Geocoder\Exception\UnsupportedOperation
77
     * @expectedExceptionMessage Unknown MaxMind service foo
78
     */
79
    public function testGeocodeWithRealIPv4AndNotSupportedService()
80
    {
81
        $provider = new MaxMind($this->getMockedHttpClient(), 'api_key', 'foo');
82
        $provider->geocodeQuery(GeocodeQuery::create('74.200.247.59'));
83
    }
84
85
    /**
86
     * @expectedException \Geocoder\Exception\UnsupportedOperation
87
     * @expectedExceptionMessage Unknown MaxMind service 12345
88
     */
89
    public function testGeocodeWithRealIPv6AndNotSupportedService()
90
    {
91
        $provider = new MaxMind($this->getMockedHttpClient(), 'api_key', '12345');
92
        $provider->geocodeQuery(GeocodeQuery::create('::ffff:74.200.247.59'));
93
    }
94
95
    public function testGeocodeWithRealIPv4GetsFakeContentFormattedEmpty()
96
    {
97
        $provider = new MaxMind($this->getMockedHttpClient(',,,,,,,,,'), 'api_key');
98
        $results = $provider->geocodeQuery(GeocodeQuery::create('74.200.247.59'));
99
100
        $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results);
101
        $this->assertCount(1, $results);
102
103
        /** @var Location $result */
104
        $result = $results->first();
105
        $this->assertInstanceOf('\Geocoder\Model\Address', $result);
106
        $this->assertNull($result->getCoordinates());
107
108
        $this->assertNull($result->getStreetNumber());
109
        $this->assertNull($result->getStreetName());
110
        $this->assertNull($result->getPostalCode());
111
        $this->assertNull($result->getLocality());
112
        $this->assertNull($result->getSubLocality());
113
        $this->assertEmpty($result->getAdminLevels());
114
        $this->assertNull($result->getCountry());
115
        $this->assertNull($result->getTimezone());
116
    }
117
118
    public function testGeocodeWithRealIPv4GetsFakeContent()
119
    {
120
        $provider = new MaxMind($this->getMockedHttpClient(
121
            'US,TX,Plano,75093,33.034698486328,-96.813400268555,,,,'), 'api_key');
122
        $results = $provider->geocodeQuery(GeocodeQuery::create('74.200.247.59'));
123
124
        $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results);
125
        $this->assertCount(1, $results);
126
127
        /** @var Location $result */
128
        $result = $results->first();
129
        $this->assertInstanceOf('\Geocoder\Model\Address', $result);
130
        $this->assertEquals(33.034698486328, $result->getCoordinates()->getLatitude(), '', 0.0001);
131
        $this->assertEquals(-96.813400268555, $result->getCoordinates()->getLongitude(), '', 0.0001);
132
        $this->assertNull($result->getStreetNumber());
133
        $this->assertNull($result->getStreetName());
134
        $this->assertEquals(75093, $result->getPostalCode());
135
        $this->assertEquals('Plano', $result->getLocality());
136
        $this->assertNull($result->getSubLocality());
137
        $this->assertCount(1, $result->getAdminLevels());
138
        $this->assertEquals('TX', $result->getAdminLevels()->get(1)->getCode());
139
        $this->assertEquals('United States', $result->getCountry()->getName());
140
        $this->assertEquals('US', $result->getCountry()->getCode());
141
        $this->assertNull($result->getTimezone());
142
143
        $provider2 = new MaxMind($this->getMockedHttpClient('FR,,,,,,,,,'), 'api_key');
144
        $result2 = $provider2->geocodeQuery(GeocodeQuery::create('74.200.247.59'));
145
        $this->assertEquals('France', $result2->first()->getCountry()->getName());
146
147
        $provider3 = new MaxMind($this->getMockedHttpClient('GB,,,,,,,,,'), 'api_key');
148
        $result3 = $provider3->geocodeQuery(GeocodeQuery::create('74.200.247.59'));
149
        $this->assertEquals('United Kingdom', $result3->first()->getCountry()->getName());
150
151
        $provider4 = new MaxMind($this->getMockedHttpClient(
152
            'US,CA,San Francisco,94110,37.748402,-122.415604,807,415,"Layered Technologies","Automattic"'), 'api_key');
153
        $results = $provider4->geocodeQuery(GeocodeQuery::create('74.200.247.59'));
154
155
        $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results);
156
        $this->assertCount(1, $results);
157
158
        /** @var Location $result */
159
        $result = $results->first();
160
        $this->assertInstanceOf('\Geocoder\Model\Address', $result);
161
        $this->assertEquals(37.748402, $result->getCoordinates()->getLatitude(), '', 0.0001);
162
        $this->assertEquals(-122.415604, $result->getCoordinates()->getLongitude(), '', 0.0001);
163
        $this->assertNull($result->getStreetNumber());
164
        $this->assertNull($result->getStreetName());
165
        $this->assertEquals(94110, $result->getPostalCode());
166
        $this->assertEquals('San Francisco', $result->getLocality());
167
        $this->assertNull($result->getSubLocality());
168
        $this->assertCount(1, $result->getAdminLevels());
169
        $this->assertEquals('CA', $result->getAdminLevels()->get(1)->getCode());
170
        $this->assertEquals('United States', $result->getCountry()->getName());
171
        $this->assertEquals('US', $result->getCountry()->getCode());
172
        $this->assertNull($result->getTimezone());
173
    }
174
175
    /**
176
     * @expectedException \Geocoder\Exception\InvalidCredentials
177
     * @expectedExceptionMessage API Key provided is not valid.
178
     */
179
    public function testGeocodeWithRealIPv4AndInvalidApiKeyGetsFakeContent()
180
    {
181
        $provider = new MaxMind($this->getMockedHttpClient(',,,,,,,,,,INVALID_LICENSE_KEY'), 'api_key');
182
        $provider->geocodeQuery(GeocodeQuery::create('74.200.247.59'));
183
    }
184
185
    /**
186
     * @expectedException \Geocoder\Exception\InvalidCredentials
187
     * @expectedExceptionMessage API Key provided is not valid.
188
     */
189
    public function testGeocodeOmniServiceWithRealIPv6AndInvalidApiKeyGetsFakeContent()
190
    {
191
        $provider = new MaxMind($this->getMockedHttpClient(',,,,,,,,,,,,,,,,,,,,,,,,INVALID_LICENSE_KEY'),
192
            'api_key', MaxMind::OMNI_SERVICE);
193
        $provider->geocodeQuery(GeocodeQuery::create('::ffff:74.200.247.59'));
194
    }
195
196
    /**
197
     * @expectedException \Geocoder\Exception\InvalidCredentials
198
     * @expectedExceptionMessage API Key provided is not valid.
199
     */
200
    public function testGeocodeWithRealIPv4AndInvalidApiKey()
201
    {
202
        $provider = new MaxMind($this->getHttpClient(), 'api_key');
203
        $provider->geocodeQuery(GeocodeQuery::create('74.200.247.59'));
204
    }
205
206
    /**
207
     * @expectedException \Geocoder\Exception\InvalidCredentials
208
     * @expectedExceptionMessage API Key provided is not valid.
209
     */
210
    public function testGeocodeWithRealIPv4AndInvalidApiKeyGetsFakeContent2()
211
    {
212
        $provider = new MaxMind($this->getMockedHttpClient(',,,,,,,,,,LICENSE_REQUIRED'), 'api_key');
213
        $provider->geocodeQuery(GeocodeQuery::create('74.200.247.59'));
214
    }
215
216
    /**
217
     * @expectedException \Geocoder\Exception\InvalidCredentials
218
     * @expectedExceptionMessage API Key provided is not valid.
219
     */
220
    public function testGeocodeOmniServiceWithRealIPv6AndInvalidApiKeyGetsFakeContent2()
221
    {
222
        $provider = new MaxMind($this->getMockedHttpClient(',,,,,,,,,,,,,,,,,,,,,,,INVALID_LICENSE_KEY'),
223
            'api_key', MaxMind::OMNI_SERVICE);
224
        $provider->geocodeQuery(GeocodeQuery::create('::ffff:74.200.247.59'));
225
    }
226
227
    public function testGeocodeWithRealIPv4GetsFakeContentWithIpNotFound()
228
    {
229
        $provider = new MaxMind($this->getMockedHttpClient(',,,,,,,,,,IP_NOT_FOUND'), 'api_key');
230
        $result = $provider->geocodeQuery(GeocodeQuery::create('74.200.247.59'));
231
232
        $this->assertInstanceOf(Collection::class, $result);
233
        $this->assertEquals(0, $result->count());
234
    }
235
236
    public function testGeocodeOmniServiceWithRealIPv6GetsFakeContentWithIpNotFound()
237
    {
238
        $provider = new MaxMind($this->getMockedHttpClient(',,,,,,,,,,,,,,,,,,,,,,,IP_NOT_FOUND'),
239
            'api_key', MaxMind::OMNI_SERVICE);
240
        $result = $provider->geocodeQuery(GeocodeQuery::create('::fff:74.200.247.59'));
241
242
        $this->assertInstanceOf(Collection::class, $result);
243
        $this->assertEquals(0, $result->count());
244
    }
245
246
    /**
247
     * @expectedException \Geocoder\Exception\InvalidServerResponse
248
     */
249
    public function testGeocodeGetsFakeContentWithInvalidData()
250
    {
251
        $provider = new MaxMind($this->getMockedHttpClient(',,,,,,,,,,'), 'api_key');
252
        $provider->geocodeQuery(GeocodeQuery::create('74.200.247.59'));
253
    }
254
255
    public function testGeocodeServiceWithRealIPv4()
0 ignored issues
show
Coding Style introduced by
testGeocodeServiceWithRealIPv4 uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
256
    {
257
        if (!isset($_SERVER['MAXMIND_API_KEY'])) {
258
            $this->markTestSkipped('You need to configure the MAXMIND_API_KEY value in phpunit.xml');
259
        }
260
261
        $provider = new MaxMind($this->getHttpClient($_SERVER['MAXMIND_API_KEY']), $_SERVER['MAXMIND_API_KEY']);
262
        $results = $provider->geocodeQuery(GeocodeQuery::create('74.200.247.159'));
263
264
        $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results);
265
        $this->assertCount(1, $results);
266
267
        /** @var Location $result */
268
        $result = $results->first();
269
        $this->assertInstanceOf('\Geocoder\Model\Address', $result);
270
        $this->assertEquals(33.034698, $result->getCoordinates()->getLatitude(), '', 0.1);
271
        $this->assertEquals(-96.813400, $result->getCoordinates()->getLongitude(), '', 0.1);
272
        $this->assertNull($result->getBounds());
273
        $this->assertNull($result->getStreetNumber());
274
        $this->assertNull($result->getStreetName());
275
        $this->assertEquals(75093, $result->getPostalCode());
276
        $this->assertEquals('Plano', $result->getLocality());
277
        $this->assertNull($result->getSubLocality());
278
        $this->assertCount(1, $result->getAdminLevels());
279
        $this->assertNull($result->getAdminLevels()->get(1)->getName());
280
        $this->assertEquals('TX', $result->getAdminLevels()->get(1)->getCode());
281
        $this->assertEquals('United States', $result->getCountry()->getName());
282
        $this->assertEquals('US', $result->getCountry()->getCode());
283
        $this->assertNull($result->getTimezone());
284
    }
285
286
    public function testGeocodeOmniServiceWithRealIPv4()
0 ignored issues
show
Coding Style introduced by
testGeocodeOmniServiceWithRealIPv4 uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
287
    {
288
        if (!isset($_SERVER['MAXMIND_API_KEY'])) {
289
            $this->markTestSkipped('You need to configure the MAXMIND_API_KEY value in phpunit.xml');
290
        }
291
292
        $provider = new MaxMind($this->getHttpClient($_SERVER['MAXMIND_API_KEY']), $_SERVER['MAXMIND_API_KEY'],
293
            MaxMind::OMNI_SERVICE);
294
        $results = $provider->geocodeQuery(GeocodeQuery::create('74.200.247.159'));
295
296
        $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results);
297
        $this->assertCount(1, $results);
298
299
        /** @var Location $result */
300
        $result = $results->first();
301
        $this->assertInstanceOf('\Geocoder\Model\Address', $result);
302
        $this->assertEquals(33.0347, $result->getCoordinates()->getLatitude(), '', 0.1);
303
        $this->assertEquals(-96.8134, $result->getCoordinates()->getLongitude(), '', 0.1);
304
        $this->assertNull($result->getBounds());
305
        $this->assertNull($result->getStreetNumber());
306
        $this->assertNull($result->getStreetName());
307
        $this->assertEquals(75093, $result->getPostalCode());
308
        $this->assertEquals('Plano', $result->getLocality());
309
        $this->assertNull($result->getSubLocality());
310
        $this->assertCount(1, $result->getAdminLevels());
311
        $this->assertEquals('Texas', $result->getAdminLevels()->get(1)->getName());
312
        $this->assertEquals('TX', $result->getAdminLevels()->get(1)->getCode());
313
        $this->assertEquals('United States', $result->getCountry()->getName());
314
        $this->assertEquals('US', $result->getCountry()->getCode());
315
        $this->assertEquals('America/Chicago', $result->getTimezone());
316
    }
317
318
    public function testGeocodeOmniServiceWithRealIPv4WithSslAndEncoding()
0 ignored issues
show
Coding Style introduced by
testGeocodeOmniServiceWi...lIPv4WithSslAndEncoding uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
319
    {
320
        if (!isset($_SERVER['MAXMIND_API_KEY'])) {
321
            $this->markTestSkipped('You need to configure the MAXMIND_API_KEY value in phpunit.xml');
322
        }
323
324
        $provider = new MaxMind($this->getHttpClient($_SERVER['MAXMIND_API_KEY']), $_SERVER['MAXMIND_API_KEY'],
325
            MaxMind::OMNI_SERVICE);
326
        $results = $provider->geocodeQuery(GeocodeQuery::create('189.26.128.80'));
327
328
        $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results);
329
        $this->assertCount(1, $results);
330
331
        /** @var Location $result */
332
        $result = $results->first();
333
        $this->assertInstanceOf('\Geocoder\Model\Address', $result);
334
        $this->assertEquals(-27.5833, $result->getCoordinates()->getLatitude(), '', 0.1);
335
        $this->assertEquals(-48.5666, $result->getCoordinates()->getLongitude(), '', 0.1);
336
        $this->assertNull($result->getBounds());
337
        $this->assertNull($result->getStreetNumber());
338
        $this->assertNull($result->getStreetName());
339
        $this->assertNull($result->getPostalCode());
340
        $this->assertEquals('Florianópolis', $result->getLocality());
341
        $this->assertNull($result->getSubLocality());
342
        $this->assertCount(1, $result->getAdminLevels());
343
        $this->assertEquals('Santa Catarina', $result->getAdminLevels()->get(1)->getName());
344
        $this->assertEquals('26', $result->getAdminLevels()->get(1)->getCode());
345
        $this->assertEquals('Brazil', $result->getCountry()->getName());
346
        $this->assertEquals('BR', $result->getCountry()->getCode());
347
        $this->assertEquals('America/Sao_Paulo', $result->getTimezone());
348
    }
349
350
    public function testGeocodeOmniServiceWithRealIPv6WithSsl()
0 ignored issues
show
Coding Style introduced by
testGeocodeOmniServiceWithRealIPv6WithSsl uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
351
    {
352
        if (!isset($_SERVER['MAXMIND_API_KEY'])) {
353
            $this->markTestSkipped('You need to configure the MAXMIND_API_KEY value in phpunit.xml');
354
        }
355
356
        $provider = new MaxMind($this->getHttpClient($_SERVER['MAXMIND_API_KEY']), $_SERVER['MAXMIND_API_KEY'],
357
            MaxMind::OMNI_SERVICE);
358
        $results = $provider->geocodeQuery(GeocodeQuery::create('2002:4293:f4d6:0:0:0:0:0'));
359
360
        $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results);
361
        $this->assertCount(1, $results);
362
363
        /** @var Location $result */
364
        $result = $results->first();
365
        $this->assertInstanceOf('\Geocoder\Model\Address', $result);
366
        $this->assertEquals(40.2181, $result->getCoordinates()->getLatitude(), '', 0.1);
367
        $this->assertEquals(-111.6133, $result->getCoordinates()->getLongitude(), '', 0.1);
368
        $this->assertNull($result->getBounds());
369
        $this->assertNull($result->getStreetNumber());
370
        $this->assertNull($result->getStreetName());
371
        $this->assertEquals(84606, $result->getPostalCode());
372
        $this->assertEquals('Provo', $result->getLocality());
373
        $this->assertNull($result->getSubLocality());
374
        $this->assertCount(1, $result->getAdminLevels());
375
        $this->assertEquals('Utah', $result->getAdminLevels()->get(1)->getName());
376
        $this->assertEquals('UT', $result->getAdminLevels()->get(1)->getCode());
377
        $this->assertEquals('United States', $result->getCountry()->getName());
378
        $this->assertEquals('US', $result->getCountry()->getCode());
379
        $this->assertEquals('America/Denver', $result->getTimezone());
380
    }
381
382
    /**
383
     * @expectedException \Geocoder\Exception\UnsupportedOperation
384
     * @expectedExceptionMessage The MaxMind provider is not able to do reverse geocoding.
385
     */
386
    public function testReverse()
387
    {
388
        $provider = new MaxMind($this->getMockedHttpClient(), 'api_key');
389
        $provider->reverseQuery(ReverseQuery::fromCoordinates(1, 2));
390
    }
391
}
392