r61928 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61927‎ | r61928 | r61929 >
Date:13:33, 3 February 2010
Author:ialex
Status:ok
Tags:
Comment:
Catch the case when allow_url_fopen=false
Modified paths:
  • /trunk/phase3/tests/HttpTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/HttpTest.php
@@ -10,6 +10,7 @@
1111 static $content;
1212 static $headers;
1313 static $has_curl;
 14+ static $has_fopen;
1415 static $has_proxy = false;
1516 static $proxy = "http://hulk:8080/";
1617 var $test_geturl = array(
@@ -24,11 +25,12 @@
2526 var $test_posturl = array( "http://www.comp.leeds.ac.uk/cgi-bin/Perl/environment-example" => "review=test" );
2627
2728 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 */
2930 if ( is_array( self::$content ) ) {
3031 return;
3132 }
3233 self::$has_curl = function_exists( 'curl_init' );
 34+ self::$has_fopen = wfIniGetBool( 'allow_url_fopen' );
3335
3436 if ( !file_exists("/usr/bin/curl") ) {
3537 $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 @@
8082 }
8183 unset($r);
8284
 85+ if( !self::$has_fopen ) {
 86+ $this->setExpectedException( 'MWException' );
 87+ }
8388 Http::$httpEngine = 'php';
8489 $r = HttpRequest::factory("http://www.example.com/");
8590 $this->assertThat($r, $this->isInstanceOf( 'PhpHttpRequest' ));
@@ -112,13 +117,17 @@
113118 }
114119
115120 function testFailurePhp() {
 121+ if ( !self::$has_fopen ) {
 122+ $this->markTestIncomplete( "This test requires allow_url_fopen=true." );
 123+ }
 124+
116125 Http::$httpEngine = "php";
117126 self::runHTTPFailureChecks();
118127 }
119128
120129 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." );
123132 }
124133
125134 Http::$httpEngine = "curl";
@@ -150,13 +159,17 @@
151160 }
152161
153162 function testRequestPhp() {
 163+ if ( !self::$has_fopen ) {
 164+ $this->markTestIncomplete( "This test requires allow_url_fopen=true." );
 165+ }
 166+
154167 Http::$httpEngine = "php";
155168 self::runHTTPRequests();
156169 }
157170
158171 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." );
161174 }
162175
163176 Http::$httpEngine = "curl";
@@ -228,13 +241,17 @@
229242 }
230243
231244 function testGetPhp() {
 245+ if ( !self::$has_fopen ) {
 246+ $this->markTestIncomplete( "This test requires allow_url_fopen=true." );
 247+ }
 248+
232249 Http::$httpEngine = "php";
233250 self::runHTTPGets();
234251 }
235252
236253 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." );
239256 }
240257
241258 Http::$httpEngine = "curl";
@@ -265,13 +282,17 @@
266283 }
267284
268285 function testPostPhp() {
 286+ if ( !self::$has_fopen ) {
 287+ $this->markTestIncomplete( "This test requires allow_url_fopen=true." );
 288+ }
 289+
269290 Http::$httpEngine = "php";
270291 self::runHTTPPosts();
271292 }
272293
273294 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." );
276297 }
277298
278299 Http::$httpEngine = "curl";
@@ -280,7 +301,7 @@
281302
282303 function runProxyRequests() {
283304 if(!self::$has_proxy) {
284 - $this->markTestIncomplete("This test requires a proxy.");
 305+ $this->markTestIncomplete( "This test requires a proxy." );
285306 }
286307 self::runHTTPGets(self::$proxy);
287308 self::runHTTPPosts(self::$proxy);
@@ -298,13 +319,17 @@
299320 }
300321
301322 function testProxyPhp() {
 323+ if ( !self::$has_fopen ) {
 324+ $this->markTestIncomplete( "This test requires allow_url_fopen=true." );
 325+ }
 326+
302327 Http::$httpEngine = 'php';
303328 self::runProxyRequests();
304329 }
305330
306331 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." );
309334 }
310335
311336 Http::$httpEngine = 'curl';
@@ -455,12 +480,16 @@
456481 self::runCookieRequests();
457482 }
458483 function testCookieRequestPhp() {
 484+ if ( !self::$has_fopen ) {
 485+ $this->markTestIncomplete( "This test requires allow_url_fopen=true." );
 486+ }
 487+
459488 Http::$httpEngine = 'php';
460489 self::runCookieRequests();
461490 }
462491 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." );
465494 }
466495
467496 Http::$httpEngine = 'curl';

Status & tagging log