From: Mark A. Hershberger Date: Wed, 27 Jan 2010 06:51:42 +0000 (+0000) Subject: Make the instantiation tests actually work. X-Git-Tag: 1.31.0-rc.0~38086 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/password.php?a=commitdiff_plain;h=a512cc91527e29ade043a8a2b0871d8c625aa001;p=lhc%2Fweb%2Fwiklou.git Make the instantiation tests actually work. --- diff --git a/includes/HttpFunctions.php b/includes/HttpFunctions.php index d575a884cc..8070b01cfd 100644 --- a/includes/HttpFunctions.php +++ b/includes/HttpFunctions.php @@ -171,7 +171,7 @@ class HttpRequest { * Generate a new request object * @see HttpRequest::__construct */ - public static function factory( $url, $options ) { + public static function factory( $url, $options = null ) { if ( !Http::$httpEngine ) { Http::$httpEngine = function_exists( 'curl_init' ) ? 'curl' : 'php'; } elseif ( Http::$httpEngine == 'curl' && !function_exists( 'curl_init' ) ) { @@ -315,10 +315,6 @@ class CurlHttpRequest extends HttpRequest { if ( !$this->status->isOK() ) { return $this->status; } - - // A lot of the action up front should probably be in - // set* methods, but we'll leave that for another time. - $this->curlOptions[CURLOPT_PROXY] = $this->proxy; $this->curlOptions[CURLOPT_TIMEOUT] = $this->timeout; $this->curlOptions[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_0; @@ -387,9 +383,6 @@ class PhpHttpRequest extends HttpRequest { return $this->status; } - // A lot of the action up front should probably be in - // set* methods, but we'll leave that for another time. - $this->reqHeaders['Accept'] = "*/*"; if ( $this->method == 'POST' ) { // Required for HTTP 1.0 POSTs diff --git a/tests/HttpTest.php b/tests/HttpTest.php index f4f85eb61d..4d0731f3fd 100644 --- a/tests/HttpTest.php +++ b/tests/HttpTest.php @@ -65,26 +65,26 @@ class HttpTest extends PhpUnit_Framework_TestCase { function testInstantiation() { Http::$httpEngine = false; - $r = new HttpRequest("http://www.example.com/"); + $r = HttpRequest::factory("http://www.example.com/"); if ( self::$has_curl ) { - $this->isInstanceOf( $r, 'CurlHttpRequest' ); + $this->assertThat($r, $this->isInstanceOf( 'CurlHttpRequest' )); } else { - $this->isInstanceOf( $r, 'PhpHttpRequest' ); + $this->assertThat($r, $this->isInstanceOf( 'PhpHttpRequest' )); } unset($r); Http::$httpEngine = 'php'; - $r = new HttpRequest("http://www.example.com/"); - $this->isInstanceOf( $r, 'PhpHttpRequest' ); + $r = HttpRequest::factory("http://www.example.com/"); + $this->assertThat($r, $this->isInstanceOf( 'PhpHttpRequest' )); unset($r); if( !self::$has_curl ) { $this->setExpectedException( 'MWException' ); } Http::$httpEngine = 'curl'; - $r = new HttpRequest("http://www.example.com/"); + $r = HttpRequest::factory("http://www.example.com/"); if( self::$has_curl ) { - $this->isInstanceOf( $r, 'CurlHttpRequest' ); + $this->assertThat($r, $this->isInstanceOf( 'CurlHttpRequest' )); } }