@@ -22,17 +22,11 @@ public function testGetName()
22
22
*/
23
23
public function testGetGeocodedData ()
24
24
{
25
- $ provider = new MapQuestProvider ( $ this -> getMockAdapter ());
26
- $ provider -> getGeocodedData ( ' foobar ' );
27
- }
25
+ if (! isset ( $ _SERVER [ ' MAPQUEST_API_KEY ' ])) {
26
+ $ this -> markTestSkipped ( ' You need to configure the CLOUDMADE_API_KEY value in phpunit.xml ' );
27
+ }
28
28
29
- /**
30
- * @expectedException Geocoder\Exception\NoResultException
31
- * @expectedExceptionMessage Could not find results for given query: http://www.mapquestapi.com/geocoding/v1/address?location=foobar&outFormat=json&maxResults=5&key=my-api-key
32
- */
33
- public function testGetGeocodedDataWithApiKey ()
34
- {
35
- $ provider = new MapQuestProvider ($ this ->getMockAdapter (), null , $ apiKey = 'my-api-key ' );
29
+ $ provider = new MapQuestProvider ($ this ->getMockAdapter (), null , $ _SERVER ['MAPQUEST_API_KEY ' ]);
36
30
$ provider ->getGeocodedData ('foobar ' );
37
31
}
38
32
@@ -42,13 +36,21 @@ public function testGetGeocodedDataWithApiKey()
42
36
*/
43
37
public function testGetGeocodedDataWithAddressGetsNullContent ()
44
38
{
45
- $ provider = new MapQuestProvider ($ this ->getMockAdapterReturns (null ));
39
+ if (!isset ($ _SERVER ['MAPQUEST_API_KEY ' ])) {
40
+ $ this ->markTestSkipped ('You need to configure the CLOUDMADE_API_KEY value in phpunit.xml ' );
41
+ }
42
+
43
+ $ provider = new MapQuestProvider ($ this ->getMockAdapterReturns (null ), null , $ _SERVER ['MAPQUEST_API_KEY ' ]);
46
44
$ provider ->getGeocodedData ('10 avenue Gambetta, Paris, France ' );
47
45
}
48
46
49
47
public function testGetGeocodedDataWithRealAddress ()
50
48
{
51
- $ provider = new MapQuestProvider ($ this ->getAdapter ());
49
+ if (!isset ($ _SERVER ['MAPQUEST_API_KEY ' ])) {
50
+ $ this ->markTestSkipped ('You need to configure the CLOUDMADE_API_KEY value in phpunit.xml ' );
51
+ }
52
+
53
+ $ provider = new MapQuestProvider ($ this ->getAdapter (), null , $ _SERVER ['MAPQUEST_API_KEY ' ]);
52
54
$ results = $ provider ->getGeocodedData ('10 avenue Gambetta, Paris, France ' );
53
55
54
56
$ this ->assertInternalType ('array ' , $ results );
@@ -77,13 +79,21 @@ public function testGetGeocodedDataWithRealAddress()
77
79
*/
78
80
public function testGetReversedData ()
79
81
{
80
- $ provider = new MapQuestProvider ($ this ->getMockAdapter ());
82
+ if (!isset ($ _SERVER ['MAPQUEST_API_KEY ' ])) {
83
+ $ this ->markTestSkipped ('You need to configure the CLOUDMADE_API_KEY value in phpunit.xml ' );
84
+ }
85
+
86
+ $ provider = new MapQuestProvider ($ this ->getMockAdapter (), null , $ _SERVER ['MAPQUEST_API_KEY ' ]);
81
87
$ provider ->getReversedData (array (1 , 2 ));
82
88
}
83
89
84
90
public function testGetReversedDataWithRealCoordinates ()
85
91
{
86
- $ provider = new MapQuestProvider ($ this ->getAdapter ());
92
+ if (!isset ($ _SERVER ['MAPQUEST_API_KEY ' ])) {
93
+ $ this ->markTestSkipped ('You need to configure the CLOUDMADE_API_KEY value in phpunit.xml ' );
94
+ }
95
+
96
+ $ provider = new MapQuestProvider ($ this ->getAdapter (), null , $ _SERVER ['MAPQUEST_API_KEY ' ]);
87
97
$ result = $ provider ->getReversedData (array (54.0484068 , -2.7990345 ));
88
98
89
99
$ this ->assertInternalType ('array ' , $ result );
@@ -108,7 +118,11 @@ public function testGetReversedDataWithRealCoordinates()
108
118
109
119
public function testGetGeocodedDataWithCity ()
110
120
{
111
- $ provider = new MapQuestProvider ($ this ->getAdapter ());
121
+ if (!isset ($ _SERVER ['MAPQUEST_API_KEY ' ])) {
122
+ $ this ->markTestSkipped ('You need to configure the CLOUDMADE_API_KEY value in phpunit.xml ' );
123
+ }
124
+
125
+ $ provider = new MapQuestProvider ($ this ->getAdapter (), null , $ _SERVER ['MAPQUEST_API_KEY ' ]);
112
126
$ results = $ provider ->getGeocodedData ('Hanover ' );
113
127
114
128
$ this ->assertInternalType ('array ' , $ results );
@@ -148,7 +162,11 @@ public function testGetGeocodedDataWithCity()
148
162
149
163
public function testGetGeocodedDataWithCityDistrict ()
150
164
{
151
- $ provider = new MapQuestProvider ($ this ->getAdapter ());
165
+ if (!isset ($ _SERVER ['MAPQUEST_API_KEY ' ])) {
166
+ $ this ->markTestSkipped ('You need to configure the CLOUDMADE_API_KEY value in phpunit.xml ' );
167
+ }
168
+
169
+ $ provider = new MapQuestProvider ($ this ->getAdapter (), null , $ _SERVER ['MAPQUEST_API_KEY ' ]);
152
170
$ result = $ provider ->getGeocodedData ('Kalbacher Hauptstraße 10, 60437 Frankfurt, Germany ' );
153
171
154
172
$ this ->assertInternalType ('array ' , $ result );
@@ -178,7 +196,7 @@ public function testGetGeocodedDataWithCityDistrict()
178
196
*/
179
197
public function testGetGeocodedDataWithLocalhostIPv4 ()
180
198
{
181
- $ provider = new MapQuestProvider ($ this ->getMockAdapter ($ this ->never ()));
199
+ $ provider = new MapQuestProvider ($ this ->getMockAdapter ($ this ->never ()), null , $ apiKey = ' my-api-key ' );
182
200
$ provider ->getGeocodedData ('127.0.0.1 ' );
183
201
}
184
202
@@ -188,7 +206,7 @@ public function testGetGeocodedDataWithLocalhostIPv4()
188
206
*/
189
207
public function testGetGeocodedDataWithLocalhostIPv6 ()
190
208
{
191
- $ provider = new MapQuestProvider ($ this ->getMockAdapter ($ this ->never ()));
209
+ $ provider = new MapQuestProvider ($ this ->getMockAdapter ($ this ->never ()), null , $ apiKey = ' my-api-key ' );
192
210
$ provider ->getGeocodedData ('::1 ' );
193
211
}
194
212
@@ -198,7 +216,7 @@ public function testGetGeocodedDataWithLocalhostIPv6()
198
216
*/
199
217
public function testGetGeocodedDataWithRealIPv4 ()
200
218
{
201
- $ provider = new MapQuestProvider ($ this ->getAdapter ());
219
+ $ provider = new MapQuestProvider ($ this ->getAdapter (), null , $ apiKey = ' my-api-key ' );
202
220
$ provider ->getGeocodedData ('74.200.247.59 ' );
203
221
}
204
222
@@ -208,7 +226,7 @@ public function testGetGeocodedDataWithRealIPv4()
208
226
*/
209
227
public function testGetGeocodedDataWithRealIPv6 ()
210
228
{
211
- $ provider = new MapQuestProvider ($ this ->getAdapter ());
229
+ $ provider = new MapQuestProvider ($ this ->getAdapter (), null , $ apiKey = ' my-api-key ' );
212
230
$ provider ->getGeocodedData ('::ffff:74.200.247.59 ' );
213
231
}
214
232
}
0 commit comments