@@ -15,7 +15,7 @@ public function testGetName()
15
15
16
16
/**
17
17
* @expectedException \Geocoder\Exception\UnsupportedOperation
18
- * @expectedExceptionMessage The FreeGeoIp does not support Street addresses.
18
+ * @expectedExceptionMessage The FreeGeoIp provider does not support street addresses.
19
19
*/
20
20
public function testGeocodeWithNull ()
21
21
{
@@ -25,7 +25,7 @@ public function testGeocodeWithNull()
25
25
26
26
/**
27
27
* @expectedException \Geocoder\Exception\UnsupportedOperation
28
- * @expectedExceptionMessage The FreeGeoIp does not support Street addresses.
28
+ * @expectedExceptionMessage The FreeGeoIp provider does not support street addresses.
29
29
*/
30
30
public function testGeocodeWithEmpty ()
31
31
{
@@ -35,7 +35,7 @@ public function testGeocodeWithEmpty()
35
35
36
36
/**
37
37
* @expectedException \Geocoder\Exception\UnsupportedOperation
38
- * @expectedExceptionMessage The FreeGeoIp does not support Street addresses.
38
+ * @expectedExceptionMessage The FreeGeoIp provider does not support street addresses.
39
39
*/
40
40
public function testGeocodeWithAddress ()
41
41
{
@@ -48,41 +48,27 @@ public function testGeocodeWithLocalhostIPv4()
48
48
$ provider = new FreeGeoIp ($ this ->getMockAdapter ($ this ->never ()));
49
49
$ result = $ provider ->geocode ('127.0.0.1 ' );
50
50
51
- $ this ->assertInternalType ('array ' , $ result );
52
51
$ this ->assertCount (1 , $ result );
53
52
54
- $ result = $ result [0 ];
55
- $ this ->assertInternalType ('array ' , $ result );
56
- $ this ->assertArrayNotHasKey ('latitude ' , $ result );
57
- $ this ->assertArrayNotHasKey ('longitude ' , $ result );
58
- $ this ->assertArrayNotHasKey ('postalCode ' , $ result );
59
- $ this ->assertArrayNotHasKey ('timezone ' , $ result );
60
-
61
- $ this ->assertEquals ('localhost ' , $ result ['locality ' ]);
62
- $ this ->assertEquals ('localhost ' , $ result ['region ' ]);
63
- $ this ->assertEquals ('localhost ' , $ result ['county ' ]);
64
- $ this ->assertEquals ('localhost ' , $ result ['country ' ]);
53
+ $ result = $ result [0 ]->toArray ();
54
+ $ this ->assertEquals ('Localhost ' , $ result ['locality ' ]);
55
+ $ this ->assertEquals ('Localhost ' , $ result ['region ' ]);
56
+ $ this ->assertEquals ('Localhost ' , $ result ['county ' ]);
57
+ $ this ->assertEquals ('Localhost ' , $ result ['country ' ]);
65
58
}
66
59
67
60
public function testGeocodeWithLocalhostIPv6 ()
68
61
{
69
62
$ provider = new FreeGeoIp ($ this ->getMockAdapter ($ this ->never ()));
70
63
$ result = $ provider ->geocode ('::1 ' );
71
64
72
- $ this ->assertInternalType ('array ' , $ result );
73
65
$ this ->assertCount (1 , $ result );
74
66
75
- $ result = $ result [0 ];
76
- $ this ->assertInternalType ('array ' , $ result );
77
- $ this ->assertArrayNotHasKey ('latitude ' , $ result );
78
- $ this ->assertArrayNotHasKey ('longitude ' , $ result );
79
- $ this ->assertArrayNotHasKey ('postalCode ' , $ result );
80
- $ this ->assertArrayNotHasKey ('timezone ' , $ result );
81
-
82
- $ this ->assertEquals ('localhost ' , $ result ['locality ' ]);
83
- $ this ->assertEquals ('localhost ' , $ result ['region ' ]);
84
- $ this ->assertEquals ('localhost ' , $ result ['county ' ]);
85
- $ this ->assertEquals ('localhost ' , $ result ['country ' ]);
67
+ $ result = $ result [0 ]->toArray ();
68
+ $ this ->assertEquals ('Localhost ' , $ result ['locality ' ]);
69
+ $ this ->assertEquals ('Localhost ' , $ result ['region ' ]);
70
+ $ this ->assertEquals ('Localhost ' , $ result ['county ' ]);
71
+ $ this ->assertEquals ('Localhost ' , $ result ['country ' ]);
86
72
}
87
73
88
74
/**
@@ -110,11 +96,9 @@ public function testGeocodeWithRealIPv4()
110
96
$ provider = new FreeGeoIp ($ this ->getAdapter ());
111
97
$ result = $ provider ->geocode ('74.200.247.59 ' );
112
98
113
- $ this ->assertInternalType ('array ' , $ result );
114
99
$ this ->assertCount (1 , $ result );
115
100
116
- $ result = $ result [0 ];
117
- $ this ->assertInternalType ('array ' , $ result );
101
+ $ result = $ result [0 ]->toArray ();
118
102
$ this ->assertEquals (33.0347 , $ result ['latitude ' ], '' , 0.01 );
119
103
$ this ->assertEquals (-96.8134 , $ result ['longitude ' ], '' , 0.01 );
120
104
$ this ->assertEquals (75093 , $ result ['postalCode ' ]);
@@ -129,11 +113,9 @@ public function testGeocodeWithRealIPv6()
129
113
$ provider = new FreeGeoIp ($ this ->getAdapter ());
130
114
$ result = $ provider ->geocode ('::ffff:74.200.247.59 ' );
131
115
132
- $ this ->assertInternalType ('array ' , $ result );
133
116
$ this ->assertCount (1 , $ result );
134
117
135
- $ result = $ result [0 ];
136
- $ this ->assertInternalType ('array ' , $ result );
118
+ $ result = $ result [0 ]->toArray ();
137
119
$ this ->assertEquals (33.0347 , $ result ['latitude ' ], '' , 0.01 );
138
120
$ this ->assertEquals (-96.8134 , $ result ['longitude ' ], '' , 0.01 );
139
121
$ this ->assertEquals (75093 , $ result ['postalCode ' ]);
@@ -158,11 +140,9 @@ public function testGeocodeWithUSIPv4()
158
140
$ provider = new FreeGeoIp ($ this ->getAdapter ());
159
141
$ result = $ provider ->geocode ('74.200.247.59 ' );
160
142
161
- $ this ->assertInternalType ('array ' , $ result );
162
143
$ this ->assertCount (1 , $ result );
163
144
164
- $ result = $ result [0 ];
165
- $ this ->assertInternalType ('array ' , $ result );
145
+ $ result = $ result [0 ]->toArray ();
166
146
$ this ->assertEquals ('48 ' , $ result ['regionCode ' ]);
167
147
}
168
148
@@ -171,11 +151,9 @@ public function testGeocodeWithUSIPv6()
171
151
$ provider = new FreeGeoIp ($ this ->getAdapter ());
172
152
$ result = $ provider ->geocode ('::ffff:74.200.247.59 ' );
173
153
174
- $ this ->assertInternalType ('array ' , $ result );
175
154
$ this ->assertCount (1 , $ result );
176
155
177
- $ result = $ result [0 ];
178
- $ this ->assertInternalType ('array ' , $ result );
156
+ $ result = $ result [0 ]->toArray ();
179
157
$ this ->assertEquals ('48 ' , $ result ['regionCode ' ]);
180
158
}
181
159
@@ -184,11 +162,9 @@ public function testGeocodeWithUKIPv4()
184
162
$ provider = new FreeGeoIp ($ this ->getAdapter ());
185
163
$ result = $ provider ->geocode ('132.185.255.60 ' );
186
164
187
- $ this ->assertInternalType ('array ' , $ result );
188
165
$ this ->assertCount (1 , $ result );
189
166
190
- $ result = $ result [0 ];
191
- $ this ->assertInternalType ('array ' , $ result );
167
+ $ result = $ result [0 ]->toArray ();
192
168
$ this ->assertEquals ('H9 ' , $ result ['regionCode ' ]);
193
169
}
194
170
@@ -197,17 +173,14 @@ public function testGeocodeWithUKIPv6()
197
173
$ provider = new FreeGeoIp ($ this ->getAdapter ());
198
174
$ result = $ provider ->geocode ('::ffff:132.185.255.60 ' );
199
175
200
- $ this ->assertInternalType ('array ' , $ result );
201
176
$ this ->assertCount (1 , $ result );
202
177
203
- $ result = $ result [0 ];
204
- $ this ->assertInternalType ('array ' , $ result );
205
- $ this ->assertEquals ('H9 ' , $ result ['regionCode ' ]);
178
+ $ this ->assertEquals ('H9 ' , $ result [0 ]->getRegion ()->getCode ());
206
179
}
207
180
208
181
/**
209
182
* @expectedException \Geocoder\Exception\UnsupportedOperation
210
- * @expectedExceptionMessage The FreeGeoIp is not able to do reverse geocoding.
183
+ * @expectedExceptionMessage The FreeGeoIp provider is not able to do reverse geocoding.
211
184
*/
212
185
public function testReverse ()
213
186
{
0 commit comments