Changeset 43511 for trunk/tests/phpunit/tests/http/base.php
- Timestamp:
- 07/19/2018 07:09:56 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/http/base.php
r42343 r43511 29 29 } 30 30 31 if ( 0 === strpos( $response->get_error_message(), 'Operationtimed out after' ) ) {31 if ( false !== strpos( $response->get_error_message(), 'timed out after' ) ) { 32 32 $this->markTestSkipped( 'HTTP timeout' ); 33 33 } … … 75 75 // 5 : 5 & 301 76 76 $res = wp_remote_request( $this->redirection_script . '?code=301&rt=' . 5, array( 'redirection' => 5 ) ); 77 78 $this->skipTestOnTimeout( $res ); 77 79 $this->assertNotWPError( $res ); 78 80 $this->assertEquals( 200, (int) $res['response']['code'] ); … … 82 84 // 5 : 5 & 302 83 85 $res = wp_remote_request( $this->redirection_script . '?code=302&rt=' . 5, array( 'redirection' => 5 ) ); 86 87 $this->skipTestOnTimeout( $res ); 84 88 $this->assertNotWPError( $res ); 85 89 $this->assertEquals( 200, (int) $res['response']['code'] ); … … 92 96 // 5 > 0 & 301 93 97 $res = wp_remote_request( $this->redirection_script . '?code=301&rt=' . 5, array( 'redirection' => 0 ) ); 98 99 $this->skipTestOnTimeout( $res ); 94 100 $this->assertNotWPError( $res ); 95 101 $this->assertEquals( 301, (int) $res['response']['code'] ); … … 102 108 // 5 > 0 & 302 103 109 $res = wp_remote_request( $this->redirection_script . '?code=302&rt=' . 5, array( 'redirection' => 0 ) ); 110 111 $this->skipTestOnTimeout( $res ); 104 112 $this->assertNotWPError( $res ); 105 113 $this->assertEquals( 302, (int) $res['response']['code'] ); … … 109 117 // 5 - 5 110 118 $res = wp_remote_request( $this->redirection_script . '?rt=' . 5, array( 'redirection' => 5 ) ); 119 120 $this->skipTestOnTimeout( $res ); 111 121 $this->assertNotWPError( $res ); 112 122 $this->assertEquals( 200, (int) $res['response']['code'] ); … … 116 126 // No redirections on HEAD request: 117 127 $res = wp_remote_request( $this->redirection_script . '?code=302&rt=' . 1, array( 'method' => 'HEAD' ) ); 128 129 $this->skipTestOnTimeout( $res ); 118 130 $this->assertNotWPError( $res ); 119 131 $this->assertEquals( 302, (int) $res['response']['code'] ); … … 131 143 ) 132 144 ); 145 146 $this->skipTestOnTimeout( $res ); 133 147 $this->assertNotWPError( $res ); 134 148 $this->assertEquals( 200, (int) $res['response']['code'] ); … … 138 152 // 10 > 5 139 153 $res = wp_remote_request( $this->redirection_script . '?rt=' . 10, array( 'redirection' => 5 ) ); 154 155 $this->skipTestOnTimeout( $res ); 140 156 $this->assertWPError( $res ); 141 157 } … … 144 160 // 6 > 5 (close edgecase) 145 161 $res = wp_remote_request( $this->redirection_script . '?rt=' . 6, array( 'redirection' => 5 ) ); 162 163 $this->skipTestOnTimeout( $res ); 146 164 $this->assertWPError( $res ); 147 165 } … … 150 168 // 4 < 5 (close edgecase) 151 169 $res = wp_remote_request( $this->redirection_script . '?rt=' . 4, array( 'redirection' => 5 ) ); 170 171 $this->skipTestOnTimeout( $res ); 152 172 $this->assertNotWPError( $res ); 153 173 } … … 159 179 // 0 redirections asked for, Should return the document? 160 180 $res = wp_remote_request( $this->redirection_script . '?code=302&rt=' . 5, array( 'redirection' => 0 ) ); 181 182 $this->skipTestOnTimeout( $res ); 161 183 $this->assertNotWPError( $res ); 162 184 $this->assertEquals( 302, (int) $res['response']['code'] ); … … 171 193 // Prints PASS on initial load, FAIL if the client follows the specified redirection 172 194 $res = wp_remote_request( $this->redirection_script . '?201-location=true' ); 195 196 $this->skipTestOnTimeout( $res ); 173 197 $this->assertNotWPError( $res ); 174 198 $this->assertEquals( 'PASS', $res['body'] ); … … 190 214 ) 191 215 ); 216 217 $this->skipTestOnTimeout( $res ); 192 218 $this->assertEquals( 'PASS', wp_remote_retrieve_body( $res ) ); 193 219 $this->assertTrue( ! empty( $res['headers']['location'] ) ); … … 206 232 $res = wp_remote_request( $this->redirection_script . '?header-check', array( 'headers' => $headers ) ); 207 233 234 $this->skipTestOnTimeout( $res ); 208 235 $this->assertNotWPError( $res ); 209 236 … … 242 269 243 270 $this->skipTestOnTimeout( $res ); 244 245 271 $this->assertNotWPError( $res ); 246 272 $this->assertEquals( '', $res['body'] ); // The body should be empty. … … 271 297 272 298 $this->skipTestOnTimeout( $res ); 273 274 299 $this->assertNotWPError( $res ); 275 300 $this->assertEquals( $size, $filesize ); // Check that the file is written to disk correctly without any extra characters … … 294 319 295 320 $this->skipTestOnTimeout( $res ); 296 297 321 $this->assertNotWPError( $res ); 298 322 $this->assertEquals( $size, strlen( $res['body'] ) ); … … 310 334 311 335 $res = wp_remote_post( add_query_arg( 'response_code', $response_code, $url ), array( 'timeout' => 30 ) ); 336 337 $this->skipTestOnTimeout( $res ); 312 338 $this->assertEquals( $method, wp_remote_retrieve_body( $res ) ); 313 339 } … … 355 381 356 382 $res = wp_remote_get( $url, $args ); 383 384 $this->skipTestOnTimeout( $res ); 357 385 $this->assertEquals( 'PASS', wp_remote_retrieve_body( $res ) ); 358 386 … … 376 404 remove_filter( 'http_request_args', array( $this, 'filter_http_request_args' ) ); 377 405 406 $this->skipTestOnTimeout( $res ); 378 407 $this->assertNotEmpty( $this->http_request_args['sslcertificates'] ); 379 408 $this->assertNotWPError( $res ); … … 389 418 $res = wp_remote_head( $url, array( 'timeout' => 30 ) ); 390 419 420 $this->skipTestOnTimeout( $res ); 391 421 $this->assertInternalType( 'array', wp_remote_retrieve_header( $res, 'location' ) ); 392 422 $this->assertCount( 2, wp_remote_retrieve_header( $res, 'location' ) ); 393 423 394 424 $res = wp_remote_get( $url, array( 'timeout' => 30 ) ); 425 426 $this->skipTestOnTimeout( $res ); 395 427 $this->assertEquals( 'PASS', wp_remote_retrieve_body( $res ) ); 396 428 … … 406 438 407 439 $res = wp_remote_get( $url ); 440 441 $this->skipTestOnTimeout( $res ); 408 442 $this->assertEquals( 'PASS', wp_remote_retrieve_body( $res ) ); 409 443 } … … 421 455 422 456 $res = wp_remote_get( 'https://wordpress.org/' ); 457 458 $this->skipTestOnTimeout( $res ); 423 459 $this->assertNotWPError( $res ); 424 460 } … … 434 470 435 471 $res = wp_remote_request( $url ); 472 473 $this->skipTestOnTimeout( $res ); 436 474 $this->assertNotWPError( $res ); 437 475 }
Note: See TracChangeset
for help on using the changeset viewer.