Ticket #13841: 13841.unitTest.diff
File 13841.unitTest.diff, 1.7 KB (added by , 13 years ago) |
---|
-
wp-testcase/test_http.php
4 4 // The WP_HTTP tests require a class-http.php file of r17550 or later. 5 5 class _WPHTTP extends WPTestCase { 6 6 var $redirection_script = 'http://tools.dd32.id.au/redirect/'; // You can use your own version here, You can find it in wp-testdata/WPHTTP-testcase-redirection-script.php 7 var $timeout_script = 'http://wp-http.dreamhosters.com/timeout/WPHTTP-testcase-timeout-script.php'; // You can use your own version here, You can find it in wp-testdata/WPHTTP-testcase-timeout-script.php 7 8 8 9 function SetUp() { 9 10 … … 143 144 144 145 unlink($res['filename']); // Remove the temporary file 145 146 } 147 148 function test_timeout() { 149 $this->knownWPBug(13841); 150 // Test that transports timeout within the amount of seconds specified. 151 $res = wp_remote_request( $this->timeout_script, array( 'timeout' => 6 ) ); 152 153 $this->assertTrue( is_wp_error( $res ), "Transfer timed-out within 6 seconds."); 154 $this->assertTrue( $res->get_error_code() == "http_request_failed", "Transfer failed with http_request_failed code." ); 155 } 146 156 } 147 157 148 158 // Stubs to test each transport -
wp-testdata/WPHTTP-testcase-timeout-script.php
1 <?php 2 3 $seconds_to_timeout = 10; 4 5 for ($i = 0; $i < $seconds_to_timeout; $i++ ) { 6 sleep( 1 ); 7 } 8 9 die("Request did not time out within $seconds_to_timeout seconds."); 10 11 ?> 12 No newline at end of file