@@ -293,153 +293,137 @@ public function testMe()
293293 );
294294 }
295295
296- /**
297- * @expectedException \GeoIp2\Exception\GeoIp2Exception
298- * @expectedExceptionMessage Received a 200 response for GeoIP2 Country but did not receive a HTTP body.
299- */
300296 public function testNoBodyException ()
301297 {
298+ $ this ->expectException (\GeoIp2 \Exception \GeoIp2Exception::class);
299+ $ this ->expectExceptionMessage ('Received a 200 response for GeoIP2 Country but did not receive a HTTP body. ' );
300+
302301 $ this ->makeRequest ('Country ' , '1.2.3.5 ' );
303302 }
304303
305- /**
306- * @expectedException \GeoIp2\Exception\GeoIp2Exception
307- * @expectedExceptionMessage Received a 200 response for GeoIP2 Country but could not decode the response as JSON:
308- */
309304 public function testBadBodyException ()
310305 {
306+ $ this ->expectException (\GeoIp2 \Exception \GeoIp2Exception::class);
307+ $ this ->expectExceptionMessage ('Received a 200 response for GeoIP2 Country but could not decode the response as JSON: ' );
308+
311309 $ this ->makeRequest ('Country ' , '2.2.3.5 ' );
312310 }
313311
314- /**
315- * @expectedException \GeoIp2\Exception\InvalidRequestException
316- * @expectedExceptionCode 400
317- * @expectedExceptionMessage The value "1.2.3" is not a valid ip address
318- */
319312 public function testInvalidIPException ()
320313 {
314+ $ this ->expectException (\GeoIp2 \Exception \InvalidRequestException::class);
315+ $ this ->expectExceptionCode (400 );
316+ $ this ->expectExceptionMessage ('The value "1.2.3" is not a valid ip address ' );
317+
321318 $ this ->makeRequest ('Country ' , '1.2.3.6 ' );
322319 }
323320
324- /**
325- * @expectedException \GeoIp2\Exception\HttpException
326- * @expectedExceptionCode 400
327- * @expectedExceptionMessage with no body
328- */
329321 public function testNoErrorBodyIPException ()
330322 {
323+ $ this ->expectException (\GeoIp2 \Exception \HttpException::class);
324+ $ this ->expectExceptionCode (400 );
325+ $ this ->expectExceptionMessage ('with no body ' );
326+
331327 $ this ->makeRequest ('Country ' , '1.2.3.7 ' );
332328 }
333329
334- /**
335- * @expectedException \GeoIp2\Exception\GeoIp2Exception
336- * @expectedExceptionMessage Error response contains JSON but it does not specify code or error keys: {"weird":42}
337- */
338330 public function testWeirdErrorBodyIPException ()
339331 {
332+ $ this ->expectException (\GeoIp2 \Exception \GeoIp2Exception::class);
333+ $ this ->expectExceptionMessage ('Error response contains JSON but it does not specify code or error keys: {"weird":42} ' );
334+
340335 $ this ->makeRequest ('Country ' , '1.2.3.8 ' );
341336 }
342337
343- /**
344- * @expectedException \GeoIp2\Exception\HttpException
345- * @expectedExceptionCode 400
346- * @expectedExceptionMessage Received a 400 error for GeoIP2 Country but could not decode the response as JSON: Syntax error. Body: { invalid: }
347- */
348338 public function testInvalidErrorBodyIPException ()
349339 {
340+ $ this ->expectException (\GeoIp2 \Exception \HttpException::class);
341+ $ this ->expectExceptionCode (400 );
342+ $ this ->expectExceptionMessage ('Received a 400 error for GeoIP2 Country but could not decode the response as JSON: Syntax error. Body: { invalid: } ' );
343+
350344 $ this ->makeRequest ('Country ' , '1.2.3.9 ' );
351345 }
352346
353- /**
354- * @expectedException \GeoIp2\Exception\HttpException
355- * @expectedExceptionCode 500
356- * @expectedExceptionMessage Received a server error (500)
357- */
358347 public function test500PException ()
359348 {
349+ $ this ->expectException (\GeoIp2 \Exception \HttpException::class);
350+ $ this ->expectExceptionCode (500 );
351+ $ this ->expectExceptionMessage ('Received a server error (500) ' );
352+
360353 $ this ->makeRequest ('Country ' , '1.2.3.10 ' );
361354 }
362355
363- /**
364- * @expectedException \GeoIp2\Exception\HttpException
365- * @expectedExceptionCode 300
366- * @expectedExceptionMessage Received an unexpected HTTP status (300) for GeoIP2 Country
367- */
368356 public function test3xxException ()
369357 {
358+ $ this ->expectException (\GeoIp2 \Exception \HttpException::class);
359+ $ this ->expectExceptionCode (300 );
360+ $ this ->expectExceptionMessage ('Received an unexpected HTTP status (300) for GeoIP2 Country ' );
361+
370362 $ this ->makeRequest ('Country ' , '1.2.3.11 ' );
371363 }
372364
373- /**
374- * @expectedException \GeoIp2\Exception\HttpException
375- * @expectedExceptionCode 406
376- * @expectedExceptionMessage Received a 406 error for GeoIP2 Country with the following body: Cannot satisfy your Accept-Charset requirements
377- */
378365 public function test406Exception ()
379366 {
367+ $ this ->expectException (\GeoIp2 \Exception \HttpException::class);
368+ $ this ->expectExceptionCode (406 );
369+ $ this ->expectExceptionMessage ('Received a 406 error for GeoIP2 Country with the following body: Cannot satisfy your Accept-Charset requirements ' );
370+
380371 $ this ->makeRequest ('Country ' , '1.2.3.12 ' );
381372 }
382373
383- /**
384- * @expectedException \GeoIp2\Exception\AddressNotFoundException
385- * @expectedExceptionMessage The address "1.2.3.13" is not in our database.
386- */
387374 public function testAddressNotFoundException ()
388375 {
376+ $ this ->expectException (\GeoIp2 \Exception \AddressNotFoundException::class);
377+ $ this ->expectExceptionMessage ('The address "1.2.3.13" is not in our database. ' );
378+
389379 $ this ->makeRequest ('Country ' , '1.2.3.13 ' );
390380 }
391381
392- /**
393- * @expectedException \GeoIp2\Exception\AddressNotFoundException
394- * @expectedExceptionMessage The address "1.2.3.14" is a private address.
395- */
396382 public function testAddressReservedException ()
397383 {
384+ $ this ->expectException (\GeoIp2 \Exception \AddressNotFoundException::class);
385+ $ this ->expectExceptionMessage ('The address "1.2.3.14" is a private address. ' );
386+
398387 $ this ->makeRequest ('Country ' , '1.2.3.14 ' );
399388 }
400389
401- /**
402- * @expectedException \GeoIp2\Exception\AuthenticationException
403- * @expectedExceptionMessage A user ID and license key are required to use this service
404- */
405390 public function testAuthorizationException ()
406391 {
392+ $ this ->expectException (\GeoIp2 \Exception \AuthenticationException::class);
393+ $ this ->expectExceptionMessage ('A user ID and license key are required to use this service ' );
394+
407395 $ this ->makeRequest ('Country ' , '1.2.3.15 ' );
408396 }
409397
410- /**
411- * @expectedException \GeoIp2\Exception\AuthenticationException
412- * @expectedExceptionMessage A license key is required to use this service
413- */
414398 public function testMissingLicenseKeyException ()
415399 {
400+ $ this ->expectException (\GeoIp2 \Exception \AuthenticationException::class);
401+ $ this ->expectExceptionMessage ('A license key is required to use this service ' );
402+
416403 $ this ->makeRequest ('Country ' , '1.2.3.16 ' );
417404 }
418405
419- /**
420- * @expectedException \GeoIp2\Exception\AuthenticationException
421- * @expectedExceptionMessage A user ID is required to use this service
422- */
423406 public function testMissingUserIdException ()
424407 {
408+ $ this ->expectException (\GeoIp2 \Exception \AuthenticationException::class);
409+ $ this ->expectExceptionMessage ('A user ID is required to use this service ' );
410+
425411 $ this ->makeRequest ('Country ' , '1.2.3.17 ' );
426412 }
427413
428- /**
429- * @expectedException \GeoIp2\Exception\AuthenticationException
430- * @expectedExceptionMessage A account ID is required to use this service
431- */
432414 public function testMissingAccountIdException ()
433415 {
416+ $ this ->expectException (\GeoIp2 \Exception \AuthenticationException::class);
417+ $ this ->expectExceptionMessage ('A account ID is required to use this service ' );
418+
434419 $ this ->makeRequest ('Country ' , '1.2.3.19 ' );
435420 }
436421
437- /**
438- * @expectedException \GeoIp2\Exception\OutOfQueriesException
439- * @expectedExceptionMessage The license key you have provided is out of queries.
440- */
441422 public function testOutOfQueriesException ()
442423 {
424+ $ this ->expectException (\GeoIp2 \Exception \OutOfQueriesException::class);
425+ $ this ->expectExceptionMessage ('The license key you have provided is out of queries. ' );
426+
443427 $ this ->makeRequest ('Country ' , '1.2.3.18 ' );
444428 }
445429
@@ -498,8 +482,8 @@ private function makeRequest(
498482 list ($ statusCode , $ headers , $ responseBody )
499483 = $ this ->getResponse ($ service , $ ipAddress );
500484
501- $ stub = $ this ->getMockForAbstractClass (
502- ' MaxMind \\ WebService \\ Http \\ Request '
485+ $ stub = $ this ->createMock (
486+ \ MaxMind \WebService \Http \Request::class
503487 );
504488 $ contentType = isset ($ headers ['Content-Type ' ])
505489 ? $ headers ['Content-Type ' ]
0 commit comments