Changeset 343 in tests for wp-testcase/test_http.php
- Timestamp:
- 03/24/2011 04:48:35 AM (15 years ago)
- File:
-
- 1 edited
-
wp-testcase/test_http.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-testcase/test_http.php
r342 r343 1 1 <?php 2 2 // Note, When running these tests, remember that some things are done differently based on safe_mode 3 // You can run the test in safe_mode like such: php -d safe_mode=on wp-test.php 3 // You can run the test in safe_mode like such: php -d safe_mode=on wp-test.php - you may also need `-d safe_mode_gid=1` to relax the safe_mode checks to allow inclusion of PEAR. 4 // The WP_HTTP tests require a class-http.php file of r17550 or later. 4 5 class WPHTTP extends WPTestCase { 5 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 … … 8 9 if ( 'WPHTTP' == get_class($this) ) { 9 10 $this->markTestSkipped('The class WPHTTP must be extended in order to run. See the WPHTTP_exthttp, WPHTTP_curl, WPHTTP_streams & WPHTTP_fsockopen testcases.'); 11 return; 12 } 13 14 if ( is_callable( array('WP_HTTP', '_getTransport') ) ) { 15 $this->markTestSkipped('The WP_HTTP tests require a class-http.php file of r17550 or later.'); 10 16 return; 11 17 } … … 75 81 // 10 > 5 76 82 $res = wp_remote_request($this->redirection_script . '?rt=' . 10, array('redirection' => 5) ); 77 $this->assertTrue( is_wp_error($res) );83 $this->assertTrue( is_wp_error($res), print_r($res, true) ); 78 84 } 79 85 function test_redirections_greater_edgecase() { … … 88 94 } 89 95 function test_redirections_zero_redirections_specified() { 90 //$this->knownWPBug(16855); // enhancement not implemented96 $this->knownWPBug(16855); 91 97 // 0 redirections asked for, Should return the document? 92 //$res = wp_remote_request($this->redirection_script . '?code=302&rt=' . 5, array('redirection' => 0) );93 //$this->assertEquals( 302, (is_wp_error($res) ? 0 : (int)$res['response']['code']) );98 $res = wp_remote_request($this->redirection_script . '?code=302&rt=' . 5, array('redirection' => 0) ); 99 $this->assertEquals( 302, (is_wp_error($res) ? 0 : (int)$res['response']['code']) ); 94 100 } 95 101 96 102 function test_location_header_on_200() { 97 $this->knownWPBug(16889); 103 //$this->knownWPBug(16889); 104 // Is this valid? Streams, cURL and therefor, PHP Extension (ie. all PHP Internal) follow redirects on all status codes, currently all of WP_HTTP follows this template. 105 98 106 // Do not redirect on non 3xx status codes 99 $res = wp_remote_request( $this->redirection_script . '?200-location=true' ); // Prints PASS on initial load, FAIL if the client follows the specified redirection100 $this->assertEquals( 'PASS', $res['body']);107 //$res = wp_remote_request( $this->redirection_script . '?200-location=true' ); // Prints PASS on initial load, FAIL if the client follows the specified redirection 108 //$this->assertEquals( 'PASS', $res['body']); 101 109 } 102 110 … … 118 126 $this->assertTrue( isset($headers['test1']) && 'test' == $headers['test1'] ); 119 127 $this->assertTrue( isset($headers['test2']) && '0' === $headers['test2'] ); 120 $this->assertTrue( isset($headers['test3']) && '' === $headers['test3'] ); // cURL Note: It doesnt seem to send empty headers128 $this->assertTrue( isset($headers['test3']) && '' === $headers['test3'] ); // cURL (&HTTPExt w/ cURL Wrappers) Note: Will never pass, cURL does not pass headers with an empty value. 121 129 } 122 130 }
Note: See TracChangeset
for help on using the changeset viewer.