11<?php
22
3- namespace PulkitJalan \GeoIP \tests ;
3+ namespace PulkitJalan \GeoIP \Tests ;
44
55use Mockery ;
66use PHPUnit_Framework_TestCase ;
7+ use PulkitJalan \GeoIP \Exceptions \GeoIPException ;
8+ use PulkitJalan \GeoIP \Exceptions \InvalidCredentialsException ;
9+ use PulkitJalan \GeoIP \Exceptions \InvalidDatabaseException ;
10+ use PulkitJalan \GeoIP \Exceptions \InvalidDriverException ;
11+ use PulkitJalan \GeoIP \GeoIP ;
12+ use BadMethodCallException ;
713
814class GeoIPTest extends PHPUnit_Framework_TestCase
915{
@@ -18,25 +24,25 @@ public function tearDown()
1824
1925 public function test_invalid_driver_exception ()
2026 {
21- $ this ->setExpectedException (' PulkitJalan\GeoIP\Exceptions\ InvalidDriverException' );
27+ $ this ->setExpectedException (InvalidDriverException::class );
2228
23- $ geoip = new \ PulkitJalan \ GeoIP \ GeoIP ([]);
29+ $ geoip = new GeoIP ([]);
2430 }
2531
2632 public function test_bad_method_call_exception ()
2733 {
28- $ this ->setExpectedException (' BadMethodCallException ' );
34+ $ this ->setExpectedException (BadMethodCallException::class );
2935
30- $ geoip = new \ PulkitJalan \ GeoIP \ GeoIP ();
36+ $ geoip = new GeoIP ();
3137
3238 $ geoip ->setNothing ();
3339 }
3440
3541 public function test_maxmind_exception ()
3642 {
37- $ this ->setExpectedException (' PulkitJalan\GeoIP\Exceptions\ InvalidCredentialsException' );
43+ $ this ->setExpectedException (InvalidCredentialsException::class );
3844
39- $ geoip = new \ PulkitJalan \ GeoIP \ GeoIP (['driver ' => 'maxmind ' ]);
45+ $ geoip = new GeoIP (['driver ' => 'maxmind ' ]);
4046 }
4147
4248 public function test_maxmind_database_exception ()
@@ -48,9 +54,9 @@ public function test_maxmind_database_exception()
4854 ],
4955 ];
5056
51- $ this ->setExpectedException (' PulkitJalan\GeoIP\Exceptions\ InvalidCredentialsException' );
57+ $ this ->setExpectedException (InvalidCredentialsException::class );
5258
53- $ geoip = new \ PulkitJalan \ GeoIP \ GeoIP ($ config );
59+ $ geoip = new GeoIP ($ config );
5460 }
5561
5662 public function test_maxmind_invalid_database_exception ()
@@ -62,9 +68,9 @@ public function test_maxmind_invalid_database_exception()
6268 ],
6369 ];
6470
65- $ this ->setExpectedException (' PulkitJalan\GeoIP\Exceptions\ InvalidDatabaseException' );
71+ $ this ->setExpectedException (InvalidDatabaseException::class );
6672
67- $ geoip = new \ PulkitJalan \ GeoIP \ GeoIP ($ config );
73+ $ geoip = new GeoIP ($ config );
6874 }
6975
7076 public function test_maxmind_web_api_exception ()
@@ -76,9 +82,9 @@ public function test_maxmind_web_api_exception()
7682 ],
7783 ];
7884
79- $ this ->setExpectedException (' PulkitJalan\GeoIP\Exceptions\ InvalidCredentialsException' );
85+ $ this ->setExpectedException (InvalidCredentialsException::class );
8086
81- $ geoip = new \ PulkitJalan \ GeoIP \ GeoIP ($ config );
87+ $ geoip = new GeoIP ($ config );
8288 }
8389
8490 public function test_maxmind_web_api_authentication_exception ()
@@ -91,9 +97,9 @@ public function test_maxmind_web_api_authentication_exception()
9197 ],
9298 ];
9399
94- $ this ->setExpectedException (' PulkitJalan\GeoIP\Exceptions\ GeoIPException' );
100+ $ this ->setExpectedException (GeoIPException::class );
95101
96- $ geoip = new \ PulkitJalan \ GeoIP \ GeoIP ($ config );
102+ $ geoip = new GeoIP ($ config );
97103 $ geoip = $ geoip ->setIp ($ this ->validIp );
98104
99105 $ geoip ->get ();
@@ -106,11 +112,11 @@ public function test_get_random_ipaddress()
106112 'random ' => true ,
107113 ];
108114
109- $ geoip = new \ PulkitJalan \ GeoIP \ GeoIP ($ config );
115+ $ geoip = new GeoIP ($ config );
110116 $ ip = $ geoip ->getIp ();
111117
112118 $ this ->assertNotEquals ($ ip , $ this ->invalidIp );
113- $ this ->assertTrue (!(filter_var ($ ip , FILTER_VALIDATE_IP )) === False );
119+ $ this ->assertTrue (! (filter_var ($ ip , FILTER_VALIDATE_IP )) === false );
114120 }
115121
116122 public function test_get_non_random_ipaddress ()
@@ -120,11 +126,11 @@ public function test_get_non_random_ipaddress()
120126 'random ' => false ,
121127 ];
122128
123- $ geoip = new \ PulkitJalan \ GeoIP \ GeoIP ($ config );
129+ $ geoip = new GeoIP ($ config );
124130 $ ip = $ geoip ->getIp ();
125131
126132 $ this ->assertEquals ($ ip , $ this ->invalidIp );
127- $ this ->assertTrue (!(filter_var ($ ip , FILTER_VALIDATE_IP )) === False );
133+ $ this ->assertTrue (! (filter_var ($ ip , FILTER_VALIDATE_IP )) === false );
128134 }
129135
130136 public function test_get_multiple_ipaddress ()
@@ -133,12 +139,12 @@ public function test_get_multiple_ipaddress()
133139 'driver ' => 'ip-api ' ,
134140 ];
135141
136- $ geoip = new \ PulkitJalan \ GeoIP \ GeoIP ($ config );
142+ $ geoip = new GeoIP ($ config );
137143 $ geoip ->setIp ($ this ->multipleIps );
138144 $ ip = $ geoip ->getIp ();
139145
140146 $ this ->assertEquals ($ ip , $ this ->validIp );
141- $ this ->assertTrue (!(filter_var ($ ip , FILTER_VALIDATE_IP )) === False );
147+ $ this ->assertTrue (! (filter_var ($ ip , FILTER_VALIDATE_IP )) === false );
142148 }
143149
144150 public function test_maxmind_database ()
@@ -150,7 +156,7 @@ public function test_maxmind_database()
150156 ],
151157 ];
152158
153- $ geoip = new \ PulkitJalan \ GeoIP \ GeoIP ($ config );
159+ $ geoip = new GeoIP ($ config );
154160 $ geoip = $ geoip ->setIp ($ this ->validIp );
155161
156162 $ this ->assertEquals ($ geoip ->getCountry (), 'United Kingdom ' );
@@ -171,9 +177,9 @@ public function test_ip_api_pro_exception()
171177 ],
172178 ];
173179
174- $ this ->setExpectedException (' PulkitJalan\GeoIP\Exceptions\ GeoIPException' );
180+ $ this ->setExpectedException (GeoIPException::class );
175181
176- $ geoip = new \ PulkitJalan \ GeoIP \ GeoIP ($ config );
182+ $ geoip = new GeoIP ($ config );
177183 $ geoip = $ geoip ->setIp ($ this ->validIp );
178184
179185 $ geoip ->get ();
@@ -185,7 +191,7 @@ public function test_ip_api()
185191 'driver ' => 'ip-api ' ,
186192 ];
187193
188- $ geoip = new \ PulkitJalan \ GeoIP \ GeoIP ($ config );
194+ $ geoip = new GeoIP ($ config );
189195 $ geoip = $ geoip ->setIp ($ this ->validIp );
190196
191197 $ this ->assertEquals ($ geoip ->getCountry (), 'United Kingdom ' );
@@ -202,7 +208,7 @@ public function test_telize()
202208 'driver ' => 'telize ' ,
203209 ];
204210
205- $ geoip = new \ PulkitJalan \ GeoIP \ GeoIP ($ config );
211+ $ geoip = new GeoIP ($ config );
206212 $ geoip = $ geoip ->setIp ($ this ->validIp );
207213
208214 $ this ->assertEquals ($ geoip ->getCountry (), 'United Kingdom ' );
@@ -222,7 +228,7 @@ public function test_telize_secure()
222228 ],
223229 ];
224230
225- $ geoip = new \ PulkitJalan \ GeoIP \ GeoIP ($ config );
231+ $ geoip = new GeoIP ($ config );
226232 $ geoip = $ geoip ->setIp ($ this ->validIp );
227233
228234 $ this ->assertEquals ($ geoip ->getCountry (), 'United Kingdom ' );
0 commit comments