Changeset 29968 for trunk/tests/phpunit/tests/http/base.php
- Timestamp:
- 10/20/2014 07:31:45 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/http/base.php
r29120 r29968 185 185 $res = wp_remote_request( $url, array( 'stream' => true, 'timeout' => 30 ) ); //Auto generate the filename. 186 186 187 // Cleanup before we assert, as it'll return early. 188 if ( ! is_wp_error( $res ) ) { 189 $filesize = filesize( $res['filename'] ); 190 unlink( $res['filename'] ); 191 } 192 187 193 $this->assertFalse( is_wp_error( $res ) ); 188 194 $this->assertEquals( '', $res['body'] ); // The body should be empty. 189 195 $this->assertEquals( $size, $res['headers']['content-length'] ); // Check the headers are returned (and the size is the same..) 190 $this->assertEquals( $size, filesize($res['filename']) ); // Check that the file is written to disk correctly without any extra characters 191 192 unlink($res['filename']); // Remove the temporary file 196 $this->assertEquals( $size, $filesize ); // Check that the file is written to disk correctly without any extra characters 197 } 198 199 /** 200 * @ticket 26726 201 */ 202 function test_file_stream_limited_size() { 203 $url = 'http://unit-tests.svn.wordpress.org/trunk/data/images/2004-07-22-DSC_0007.jpg'; // we'll test against a file in the unit test data 204 $size = 10000; 205 $res = wp_remote_request( $url, array( 'stream' => true, 'timeout' => 30, 'limit_response_size' => $size ) ); //Auto generate the filename. 206 207 // Cleanup before we assert, as it'll return early. 208 if ( ! is_wp_error( $res ) ) { 209 $filesize = filesize( $res['filename'] ); 210 unlink( $res['filename'] ); 211 } 212 213 $this->assertFalse( is_wp_error( $res ) ); 214 $this->assertEquals( $size, $filesize ); // Check that the file is written to disk correctly without any extra characters 215 193 216 } 194 217
Note: See TracChangeset
for help on using the changeset viewer.