Index: trunk/phase3/tests/HttpTest.php |
— | — | @@ -10,6 +10,7 @@ |
11 | 11 | static $content; |
12 | 12 | static $headers; |
13 | 13 | static $has_curl; |
| 14 | + static $has_fopen; |
14 | 15 | static $has_proxy = false; |
15 | 16 | static $proxy = "http://hulk:8080/"; |
16 | 17 | var $test_geturl = array( |
— | — | @@ -24,11 +25,12 @@ |
25 | 26 | var $test_posturl = array( "http://www.comp.leeds.ac.uk/cgi-bin/Perl/environment-example" => "review=test" ); |
26 | 27 | |
27 | 28 | function setup() { |
28 | | - putenv("http_proxy"); /* Remove any proxy env var, so curl doesn't get confused */ |
| 29 | + putenv("http_proxy"); /* Remove any proxy env var, so curl doesn't get confused */ |
29 | 30 | if ( is_array( self::$content ) ) { |
30 | 31 | return; |
31 | 32 | } |
32 | 33 | self::$has_curl = function_exists( 'curl_init' ); |
| 34 | + self::$has_fopen = wfIniGetBool( 'allow_url_fopen' ); |
33 | 35 | |
34 | 36 | if ( !file_exists("/usr/bin/curl") ) { |
35 | 37 | $this->markTestIncomplete("This test requires the curl binary at /usr/bin/curl. If you have curl, please file a bug on this test, or, better yet, provide a patch."); |
— | — | @@ -79,6 +81,9 @@ |
80 | 82 | } |
81 | 83 | unset($r); |
82 | 84 | |
| 85 | + if( !self::$has_fopen ) { |
| 86 | + $this->setExpectedException( 'MWException' ); |
| 87 | + } |
83 | 88 | Http::$httpEngine = 'php'; |
84 | 89 | $r = HttpRequest::factory("http://www.example.com/"); |
85 | 90 | $this->assertThat($r, $this->isInstanceOf( 'PhpHttpRequest' )); |
— | — | @@ -112,13 +117,17 @@ |
113 | 118 | } |
114 | 119 | |
115 | 120 | function testFailurePhp() { |
| 121 | + if ( !self::$has_fopen ) { |
| 122 | + $this->markTestIncomplete( "This test requires allow_url_fopen=true." ); |
| 123 | + } |
| 124 | + |
116 | 125 | Http::$httpEngine = "php"; |
117 | 126 | self::runHTTPFailureChecks(); |
118 | 127 | } |
119 | 128 | |
120 | 129 | function testFailureCurl() { |
121 | | - if (!self::$has_curl ) { |
122 | | - $this->markTestIncomplete("This test requires curl."); |
| 130 | + if ( !self::$has_curl ) { |
| 131 | + $this->markTestIncomplete( "This test requires curl." ); |
123 | 132 | } |
124 | 133 | |
125 | 134 | Http::$httpEngine = "curl"; |
— | — | @@ -150,13 +159,17 @@ |
151 | 160 | } |
152 | 161 | |
153 | 162 | function testRequestPhp() { |
| 163 | + if ( !self::$has_fopen ) { |
| 164 | + $this->markTestIncomplete( "This test requires allow_url_fopen=true." ); |
| 165 | + } |
| 166 | + |
154 | 167 | Http::$httpEngine = "php"; |
155 | 168 | self::runHTTPRequests(); |
156 | 169 | } |
157 | 170 | |
158 | 171 | function testRequestCurl() { |
159 | | - if (!self::$has_curl ) { |
160 | | - $this->markTestIncomplete("This test requires curl."); |
| 172 | + if ( !self::$has_curl ) { |
| 173 | + $this->markTestIncomplete( "This test requires curl." ); |
161 | 174 | } |
162 | 175 | |
163 | 176 | Http::$httpEngine = "curl"; |
— | — | @@ -228,13 +241,17 @@ |
229 | 242 | } |
230 | 243 | |
231 | 244 | function testGetPhp() { |
| 245 | + if ( !self::$has_fopen ) { |
| 246 | + $this->markTestIncomplete( "This test requires allow_url_fopen=true." ); |
| 247 | + } |
| 248 | + |
232 | 249 | Http::$httpEngine = "php"; |
233 | 250 | self::runHTTPGets(); |
234 | 251 | } |
235 | 252 | |
236 | 253 | function testGetCurl() { |
237 | | - if (!self::$has_curl ) { |
238 | | - $this->markTestIncomplete("This test requires curl."); |
| 254 | + if ( !self::$has_curl ) { |
| 255 | + $this->markTestIncomplete( "This test requires curl." ); |
239 | 256 | } |
240 | 257 | |
241 | 258 | Http::$httpEngine = "curl"; |
— | — | @@ -265,13 +282,17 @@ |
266 | 283 | } |
267 | 284 | |
268 | 285 | function testPostPhp() { |
| 286 | + if ( !self::$has_fopen ) { |
| 287 | + $this->markTestIncomplete( "This test requires allow_url_fopen=true." ); |
| 288 | + } |
| 289 | + |
269 | 290 | Http::$httpEngine = "php"; |
270 | 291 | self::runHTTPPosts(); |
271 | 292 | } |
272 | 293 | |
273 | 294 | function testPostCurl() { |
274 | | - if (!self::$has_curl ) { |
275 | | - $this->markTestIncomplete("This test requires curl."); |
| 295 | + if ( !self::$has_curl ) { |
| 296 | + $this->markTestIncomplete( "This test requires curl." ); |
276 | 297 | } |
277 | 298 | |
278 | 299 | Http::$httpEngine = "curl"; |
— | — | @@ -280,7 +301,7 @@ |
281 | 302 | |
282 | 303 | function runProxyRequests() { |
283 | 304 | if(!self::$has_proxy) { |
284 | | - $this->markTestIncomplete("This test requires a proxy."); |
| 305 | + $this->markTestIncomplete( "This test requires a proxy." ); |
285 | 306 | } |
286 | 307 | self::runHTTPGets(self::$proxy); |
287 | 308 | self::runHTTPPosts(self::$proxy); |
— | — | @@ -298,13 +319,17 @@ |
299 | 320 | } |
300 | 321 | |
301 | 322 | function testProxyPhp() { |
| 323 | + if ( !self::$has_fopen ) { |
| 324 | + $this->markTestIncomplete( "This test requires allow_url_fopen=true." ); |
| 325 | + } |
| 326 | + |
302 | 327 | Http::$httpEngine = 'php'; |
303 | 328 | self::runProxyRequests(); |
304 | 329 | } |
305 | 330 | |
306 | 331 | function testProxyCurl() { |
307 | | - if (!self::$has_curl ) { |
308 | | - $this->markTestIncomplete("This test requires curl."); |
| 332 | + if ( !self::$has_curl ) { |
| 333 | + $this->markTestIncomplete( "This test requires curl." ); |
309 | 334 | } |
310 | 335 | |
311 | 336 | Http::$httpEngine = 'curl'; |
— | — | @@ -455,12 +480,16 @@ |
456 | 481 | self::runCookieRequests(); |
457 | 482 | } |
458 | 483 | function testCookieRequestPhp() { |
| 484 | + if ( !self::$has_fopen ) { |
| 485 | + $this->markTestIncomplete( "This test requires allow_url_fopen=true." ); |
| 486 | + } |
| 487 | + |
459 | 488 | Http::$httpEngine = 'php'; |
460 | 489 | self::runCookieRequests(); |
461 | 490 | } |
462 | 491 | function testCookieRequestCurl() { |
463 | | - if (!self::$has_curl ) { |
464 | | - $this->markTestIncomplete("This test requires curl."); |
| 492 | + if ( !self::$has_curl ) { |
| 493 | + $this->markTestIncomplete( "This test requires curl." ); |
465 | 494 | } |
466 | 495 | |
467 | 496 | Http::$httpEngine = 'curl'; |