X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FHttpTest.php;h=246c609ed2084e34f9036f12c4034d2586c4fce5;hp=fbd2c31a303ee40874b7919f28786759ec3a8a61;hb=6ae9367cddf8565c948f4d9458b07bb688f2ddc2;hpb=4259a54dcdc8d96d82fde9e839fb230ef834d31b diff --git a/tests/phpunit/includes/HttpTest.php b/tests/phpunit/includes/HttpTest.php index fbd2c31a30..246c609ed2 100644 --- a/tests/phpunit/includes/HttpTest.php +++ b/tests/phpunit/includes/HttpTest.php @@ -62,6 +62,17 @@ class HttpTest extends MediaWikiTestCase { ); } + /** + * @covers Http::getProxy + */ + public function testGetProxy() { + $this->setMwGlobals( 'wgHTTPProxy', 'proxy.domain.tld' ); + $this->assertEquals( + 'proxy.domain.tld', + Http::getProxy() + ); + } + /** * Feeds URI to test a long regular expression in Http::isValidURI */ @@ -95,8 +106,8 @@ class HttpTest extends MediaWikiTestCase { # (\S+) - host part is made of anything not whitespaces // commented these out in order to remove @group Broken // @todo are these valid tests? if so, fix Http::isValidURI so it can handle them - //array( false, 'http://!"èèè¿¿¿~~\'', 'hostname is made of any non whitespace' ), - //array( false, 'http://exam:ple.org/', 'hostname can not use colons!' ), + // array( false, 'http://!"èèè¿¿¿~~\'', 'hostname is made of any non whitespace' ), + // array( false, 'http://exam:ple.org/', 'hostname can not use colons!' ), # (:[0-9]+)? - port number array( true, 'http://example.org:80/' ), @@ -138,7 +149,7 @@ class HttpTest extends MediaWikiTestCase { * HTTP redirects). */ public function testRelativeRedirections() { - $h = MWHttpRequestTester::factory( 'http://oldsite/file.ext' ); + $h = MWHttpRequestTester::factory( 'http://oldsite/file.ext', array(), __METHOD__ ); # Forge a Location header $h->setRespHeaders( 'location', array( @@ -486,7 +497,7 @@ class HttpTest extends MediaWikiTestCase { class MWHttpRequestTester extends MWHttpRequest { // function derived from the MWHttpRequest factory function but // returns appropriate tester class here - public static function factory( $url, $options = null ) { + public static function factory( $url, $options = null, $caller = __METHOD__ ) { if ( !Http::$httpEngine ) { Http::$httpEngine = function_exists( 'curl_init' ) ? 'curl' : 'php'; } elseif ( Http::$httpEngine == 'curl' && !function_exists( 'curl_init' ) ) { @@ -496,7 +507,7 @@ class MWHttpRequestTester extends MWHttpRequest { switch ( Http::$httpEngine ) { case 'curl': - return new CurlHttpRequestTester( $url, $options ); + return new CurlHttpRequestTester( $url, $options, $caller ); case 'php': if ( !wfIniGetBool( 'allow_url_fopen' ) ) { throw new MWException( __METHOD__ . @@ -504,7 +515,7 @@ class MWHttpRequestTester extends MWHttpRequest { . 'If possible, curl should be used instead. See http://php.net/curl.' ); } - return new PhpHttpRequestTester( $url, $options ); + return new PhpHttpRequestTester( $url, $options, $caller ); default: } }