Changeset 43695
- Timestamp:
- 10/11/2018 03:17:44 AM (6 years ago)
- Location:
- branches/5.0
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.0
-
branches/5.0/tests/phpunit/tests/http/base.php
r41289 r43695 29 29 } 30 30 31 if ( 0 === strpos( $response->get_error_message(), 'Operation timed out after' ) ){31 if ( false !== strpos( $response->get_error_message(), 'timed out after' ) ) { 32 32 $this->markTestSkipped( 'HTTP timeout' ); 33 33 } … … 74 74 // 5 : 5 & 301 75 75 $res = wp_remote_request($this->redirection_script . '?code=301&rt=' . 5, array('redirection' => 5) ); 76 77 $this->skipTestOnTimeout( $res ); 76 78 $this->assertNotWPError( $res ); 77 79 $this->assertEquals(200, (int)$res['response']['code'] ); … … 81 83 // 5 : 5 & 302 82 84 $res = wp_remote_request($this->redirection_script . '?code=302&rt=' . 5, array('redirection' => 5) ); 85 86 $this->skipTestOnTimeout( $res ); 83 87 $this->assertNotWPError( $res ); 84 88 $this->assertEquals(200, (int)$res['response']['code'] ); … … 91 95 // 5 > 0 & 301 92 96 $res = wp_remote_request($this->redirection_script . '?code=301&rt=' . 5, array('redirection' => 0) ); 97 98 $this->skipTestOnTimeout( $res ); 93 99 $this->assertNotWPError( $res ); 94 100 $this->assertEquals(301, (int)$res['response']['code'] ); … … 101 107 // 5 > 0 & 302 102 108 $res = wp_remote_request($this->redirection_script . '?code=302&rt=' . 5, array('redirection' => 0) ); 109 110 $this->skipTestOnTimeout( $res ); 103 111 $this->assertNotWPError( $res ); 104 112 $this->assertEquals(302, (int)$res['response']['code'] ); … … 108 116 // 5 - 5 109 117 $res = wp_remote_request($this->redirection_script . '?rt=' . 5, array('redirection' => 5) ); 118 119 $this->skipTestOnTimeout( $res ); 110 120 $this->assertNotWPError( $res ); 111 121 $this->assertEquals(200, (int)$res['response']['code'] ); … … 115 125 // No redirections on HEAD request: 116 126 $res = wp_remote_request($this->redirection_script . '?code=302&rt=' . 1, array('method' => 'HEAD') ); 127 128 $this->skipTestOnTimeout( $res ); 117 129 $this->assertNotWPError( $res ); 118 130 $this->assertEquals( 302, (int)$res['response']['code'] ); … … 125 137 // Redirections on HEAD request when Requested 126 138 $res = wp_remote_request($this->redirection_script . '?rt=' . 5, array('redirection' => 5, 'method' => 'HEAD') ); 139 140 $this->skipTestOnTimeout( $res ); 127 141 $this->assertNotWPError( $res ); 128 142 $this->assertEquals( 200, (int)$res['response']['code'] ); … … 132 146 // 10 > 5 133 147 $res = wp_remote_request($this->redirection_script . '?rt=' . 10, array('redirection' => 5) ); 148 149 $this->skipTestOnTimeout( $res ); 134 150 $this->assertWPError( $res ); 135 151 } … … 138 154 // 6 > 5 (close edgecase) 139 155 $res = wp_remote_request($this->redirection_script . '?rt=' . 6, array('redirection' => 5) ); 156 157 $this->skipTestOnTimeout( $res ); 140 158 $this->assertWPError( $res ); 141 159 } … … 144 162 // 4 < 5 (close edgecase) 145 163 $res = wp_remote_request($this->redirection_script . '?rt=' . 4, array('redirection' => 5) ); 164 165 $this->skipTestOnTimeout( $res ); 146 166 $this->assertNotWPError( $res ); 147 167 } … … 153 173 // 0 redirections asked for, Should return the document? 154 174 $res = wp_remote_request($this->redirection_script . '?code=302&rt=' . 5, array('redirection' => 0) ); 175 176 $this->skipTestOnTimeout( $res ); 155 177 $this->assertNotWPError( $res ); 156 178 $this->assertEquals( 302, (int)$res['response']['code'] ); … … 165 187 // Prints PASS on initial load, FAIL if the client follows the specified redirection 166 188 $res = wp_remote_request( $this->redirection_script . '?201-location=true' ); 189 190 $this->skipTestOnTimeout( $res ); 167 191 $this->assertNotWPError( $res ); 168 192 $this->assertEquals( 'PASS', $res['body']); … … 179 203 // Test 301 - POST to POST 180 204 $res = wp_remote_request( $url, array( 'method' => 'PUT', 'timeout' => 30 ) ); 205 206 $this->skipTestOnTimeout( $res ); 181 207 $this->assertEquals( 'PASS', wp_remote_retrieve_body( $res ) ); 182 208 $this->assertTrue( !empty( $res['headers']['location'] ) ); … … 191 217 $res = wp_remote_request( $this->redirection_script . '?header-check', array('headers' => $headers) ); 192 218 219 $this->skipTestOnTimeout( $res ); 193 220 $this->assertNotWPError( $res ); 194 221 … … 221 248 222 249 $this->skipTestOnTimeout( $res ); 223 224 250 $this->assertNotWPError( $res ); 225 251 $this->assertEquals( '', $res['body'] ); // The body should be empty. … … 244 270 245 271 $this->skipTestOnTimeout( $res ); 246 247 272 $this->assertNotWPError( $res ); 248 273 $this->assertEquals( $size, $filesize ); // Check that the file is written to disk correctly without any extra characters … … 262 287 263 288 $this->skipTestOnTimeout( $res ); 264 265 289 $this->assertNotWPError( $res ); 266 290 $this->assertEquals( $size, strlen( $res['body'] ) ); … … 278 302 279 303 $res = wp_remote_post( add_query_arg( 'response_code', $response_code, $url ), array( 'timeout' => 30 ) ); 304 305 $this->skipTestOnTimeout( $res ); 280 306 $this->assertEquals( $method, wp_remote_retrieve_body( $res ) ); 281 307 } … … 323 349 324 350 $res = wp_remote_get( $url, $args ); 351 352 $this->skipTestOnTimeout( $res ); 325 353 $this->assertEquals( 'PASS', wp_remote_retrieve_body( $res ) ); 326 354 … … 344 372 remove_filter( 'http_request_args', array( $this, 'filter_http_request_args' ) ); 345 373 374 $this->skipTestOnTimeout( $res ); 346 375 $this->assertNotEmpty( $this->http_request_args['sslcertificates'] ); 347 376 $this->assertNotWPError( $res ); … … 357 386 $res = wp_remote_head( $url, array( 'timeout' => 30 ) ); 358 387 388 $this->skipTestOnTimeout( $res ); 359 389 $this->assertInternalType( 'array', wp_remote_retrieve_header( $res, 'location' ) ); 360 390 $this->assertCount( 2, wp_remote_retrieve_header( $res, 'location' ) ); 361 391 362 392 $res = wp_remote_get( $url, array( 'timeout' => 30 ) ); 393 394 $this->skipTestOnTimeout( $res ); 363 395 $this->assertEquals( 'PASS', wp_remote_retrieve_body( $res ) ); 364 396 … … 374 406 375 407 $res = wp_remote_get( $url ); 408 409 $this->skipTestOnTimeout( $res ); 376 410 $this->assertEquals( 'PASS', wp_remote_retrieve_body( $res ) ); 377 411 } … … 388 422 389 423 $res = wp_remote_get( 'https://wordpress.org/' ); 424 425 $this->skipTestOnTimeout( $res ); 390 426 $this->assertNotWPError( $res ); 391 427 } … … 401 437 402 438 $res = wp_remote_request( $url ); 439 440 $this->skipTestOnTimeout( $res ); 403 441 $this->assertNotWPError( $res ); 404 442 }
Note: See TracChangeset
for help on using the changeset viewer.