Changeset 42773 for trunk/tests/phpunit/tests/admin/includesFile.php
- Timestamp:
- 03/04/2018 05:13:35 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/admin/includesFile.php
r42343 r42773 32 32 $_SERVER['SCRIPT_FILENAME'] = $sfn; 33 33 } 34 35 /** 36 * @ticket 43329 37 */ 38 public function test_download_url_non_200_response_code() { 39 add_filter( 'pre_http_request', array( $this, '_fake_download_url_non_200_response_code' ), 10, 3 ); 40 41 $error = download_url( 'test_download_url_non_200' ); 42 $this->assertWPError( $error ); 43 $this->assertEquals( array( 44 'code' => 418, 45 'body' => 'This is an unexpected error message from your favorite server.', 46 ), $error->get_error_data() ); 47 48 add_filter( 'download_url_error_max_body_size', array( $this, '__return_5' ) ); 49 50 $error = download_url( 'test_download_url_non_200' ); 51 $this->assertWPError( $error ); 52 $this->assertEquals( array( 53 'code' => 418, 54 'body' => 'This ', 55 ), $error->get_error_data() ); 56 57 remove_filter( 'download_url_error_max_body_size', array( $this, '__return_5' ) ); 58 remove_filter( 'pre_http_request', array( $this, '_fake_download_url_non_200_response_code' ) ); 59 } 60 61 public function _fake_download_url_non_200_response_code( $response, $args, $url ) { 62 file_put_contents( $args['filename'], 'This is an unexpected error message from your favorite server.' ); 63 return array( 64 'response' => array( 65 'code' => 418, 66 'message' => "I'm a teapot!", 67 ), 68 ); 69 } 70 71 public function __return_5() { 72 return 5; 73 } 34 74 }
Note: See TracChangeset
for help on using the changeset viewer.