r96563 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96562‎ | r96563 | r96564 >
Date:13:49, 8 September 2011
Author:catrope
Status:ok
Tags:
Comment:
Add tests for r96562. HttpTest still has 5 failing test (which is why it's marked @broken) and per Chad on IRC most of this suite is pure evil
Modified paths:
  • /trunk/phase3/tests/phpunit/includes/HttpTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/HttpTest.php
@@ -82,7 +82,16 @@
8383 } else {
8484 $this->assertThat( $r, $this->isInstanceOf( 'PhpHttpRequest' ) );
8585 }
 86+ $this->assertTrue( $r->status->isGood(), '$r->status is good' );
8687 unset( $r );
 88+
 89+ $r = MWHttpRequest::factory( "//www.example.com/" );
 90+ if ( self::$has_curl ) {
 91+ $this->assertThat( $r, $this->isInstanceOf( 'CurlHttpRequest' ) );
 92+ } else {
 93+ $this->assertThat( $r, $this->isInstanceOf( 'PhpHttpRequest' ) );
 94+ }
 95+ $this->assertTrue( $r->status->isGood(), '$r->status is good' );
8796
8897 if ( !self::$has_fopen ) {
8998 $this->setExpectedException( 'MWException' );
@@ -90,6 +99,7 @@
91100 Http::$httpEngine = 'php';
92101 $r = MWHttpRequest::factory( "http://www.example.com/" );
93102 $this->assertThat( $r, $this->isInstanceOf( 'PhpHttpRequest' ) );
 103+ $this->assertTrue( $r->status->isGood(), '$r->status is good' );
94104 unset( $r );
95105
96106 if ( !self::$has_curl ) {
@@ -99,6 +109,7 @@
100110 $r = MWHttpRequest::factory( "http://www.example.com/" );
101111 if ( self::$has_curl ) {
102112 $this->assertThat( $r, $this->isInstanceOf( 'CurlHttpRequest' ) );
 113+ $this->assertTrue( $r->status->isGood(), '$r->status is good' );
103114 }
104115 }
105116
@@ -165,6 +176,15 @@
166177 foreach ( $this->test_requesturl as $u ) {
167178 $r = Http::request( "POST", $u, $opt );
168179 $this->assertEquals( self::$content["POST $u"], "$r", "POST $u with " . Http::$httpEngine );
 180+
 181+ // If this was an HTTP URL, repeat the same test with a protocol-relative URL
 182+ // We can't do this with HTTPS URLs because MWHttpRequest expands protocol-relative
 183+ // URLs to HTTP.
 184+ list( $prot, $url ) = explode( ':', $u, 2 );
 185+ if ( $prot === 'http' ) {
 186+ $r = Http::request( "POST", $url, $opt );
 187+ $this->assertEquals( self::$content["POST $u"], "$r", "POST $url with " . Http::$httpEngine );
 188+ }
169189 }
170190 }
171191
@@ -203,6 +223,15 @@
204224 foreach ( $this->test_geturl as $u ) {
205225 $r = Http::get( $u, 30, $opt ); /* timeout of 30s */
206226 $this->assertEquals( self::$content["GET $u"], "$r", "Get $u with " . Http::$httpEngine );
 227+
 228+ // If this was an HTTP URL, repeat the same test with a protocol-relative URL
 229+ // We can't do this with HTTPS URLs because MWHttpRequest expands protocol-relative
 230+ // URLs to HTTP.
 231+ list( $prot, $url ) = explode( ':', $u, 2 );
 232+ if ( $prot === 'http' ) {
 233+ $r = Http::get( $url, 30, $opt );
 234+ $this->assertEquals( self::$content["GET $u"], "$r", "Get $url with " . Http::$httpEngine );
 235+ }
207236 }
208237 }
209238
@@ -243,6 +272,16 @@
244273 $r = Http::post( $u, $opt );
245274 $this->assertEquals( self::$content["POST $u => $postData"], "$r",
246275 "POST $u (postData=$postData) with " . Http::$httpEngine );
 276+
 277+ // If this was an HTTP URL, repeat the same test with a protocol-relative URL
 278+ // We can't do this with HTTPS URLs because MWHttpRequest expands protocol-relative
 279+ // URLs to HTTP.
 280+ list( $prot, $url ) = explode( ':', $u, 2 );
 281+ if ( $prot === 'http' ) {
 282+ $r = Http::post( $url, $opt );
 283+ $this->assertEquals( self::$content["POST $u => $postData"], "$r",
 284+ "POST $u (postData=$postData) with " . Http::$httpEngine );
 285+ }
247286 }
248287 }
249288

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r96562Move URL expansion from Http::request() (where it was put in r93820) to MWHtt...catrope13:48, 8 September 2011

Status & tagging log