@@ -22,17 +22,11 @@ public function testGetName()
2222 */
2323 public function testGetGeocodedData ()
2424 {
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+ }
2828
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 ' ]);
3630 $ provider ->getGeocodedData ('foobar ' );
3731 }
3832
@@ -42,13 +36,21 @@ public function testGetGeocodedDataWithApiKey()
4236 */
4337 public function testGetGeocodedDataWithAddressGetsNullContent ()
4438 {
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 ' ]);
4644 $ provider ->getGeocodedData ('10 avenue Gambetta, Paris, France ' );
4745 }
4846
4947 public function testGetGeocodedDataWithRealAddress ()
5048 {
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 ' ]);
5254 $ results = $ provider ->getGeocodedData ('10 avenue Gambetta, Paris, France ' );
5355
5456 $ this ->assertInternalType ('array ' , $ results );
@@ -77,13 +79,21 @@ public function testGetGeocodedDataWithRealAddress()
7779 */
7880 public function testGetReversedData ()
7981 {
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 ' ]);
8187 $ provider ->getReversedData (array (1 , 2 ));
8288 }
8389
8490 public function testGetReversedDataWithRealCoordinates ()
8591 {
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 ' ]);
8797 $ result = $ provider ->getReversedData (array (54.0484068 , -2.7990345 ));
8898
8999 $ this ->assertInternalType ('array ' , $ result );
@@ -108,7 +118,11 @@ public function testGetReversedDataWithRealCoordinates()
108118
109119 public function testGetGeocodedDataWithCity ()
110120 {
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 ' ]);
112126 $ results = $ provider ->getGeocodedData ('Hanover ' );
113127
114128 $ this ->assertInternalType ('array ' , $ results );
@@ -148,7 +162,11 @@ public function testGetGeocodedDataWithCity()
148162
149163 public function testGetGeocodedDataWithCityDistrict ()
150164 {
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 ' ]);
152170 $ result = $ provider ->getGeocodedData ('Kalbacher Hauptstraße 10, 60437 Frankfurt, Germany ' );
153171
154172 $ this ->assertInternalType ('array ' , $ result );
@@ -178,7 +196,7 @@ public function testGetGeocodedDataWithCityDistrict()
178196 */
179197 public function testGetGeocodedDataWithLocalhostIPv4 ()
180198 {
181- $ provider = new MapQuestProvider ($ this ->getMockAdapter ($ this ->never ()));
199+ $ provider = new MapQuestProvider ($ this ->getMockAdapter ($ this ->never ()), null , $ apiKey = ' my-api-key ' );
182200 $ provider ->getGeocodedData ('127.0.0.1 ' );
183201 }
184202
@@ -188,7 +206,7 @@ public function testGetGeocodedDataWithLocalhostIPv4()
188206 */
189207 public function testGetGeocodedDataWithLocalhostIPv6 ()
190208 {
191- $ provider = new MapQuestProvider ($ this ->getMockAdapter ($ this ->never ()));
209+ $ provider = new MapQuestProvider ($ this ->getMockAdapter ($ this ->never ()), null , $ apiKey = ' my-api-key ' );
192210 $ provider ->getGeocodedData ('::1 ' );
193211 }
194212
@@ -198,7 +216,7 @@ public function testGetGeocodedDataWithLocalhostIPv6()
198216 */
199217 public function testGetGeocodedDataWithRealIPv4 ()
200218 {
201- $ provider = new MapQuestProvider ($ this ->getAdapter ());
219+ $ provider = new MapQuestProvider ($ this ->getAdapter (), null , $ apiKey = ' my-api-key ' );
202220 $ provider ->getGeocodedData ('74.200.247.59 ' );
203221 }
204222
@@ -208,7 +226,7 @@ public function testGetGeocodedDataWithRealIPv4()
208226 */
209227 public function testGetGeocodedDataWithRealIPv6 ()
210228 {
211- $ provider = new MapQuestProvider ($ this ->getAdapter ());
229+ $ provider = new MapQuestProvider ($ this ->getAdapter (), null , $ apiKey = ' my-api-key ' );
212230 $ provider ->getGeocodedData ('::ffff:74.200.247.59 ' );
213231 }
214232}
0 commit comments