diff --git tests/phpunit/tests/admin/includesFile.php tests/phpunit/tests/admin/includesFile.php
index a3af5da2d1..94549354fb 100644
|
|
class Tests_Admin_includesFile extends WP_UnitTestCase { |
77 | 77 | public function __return_5() { |
78 | 78 | return 5; |
79 | 79 | } |
| 80 | |
| 81 | /** |
| 82 | * @ticket 38231 |
| 83 | */ |
| 84 | public function test_download_url_filename_from_content_disposition_header() { |
| 85 | add_filter( 'pre_http_request', array( $this, '_fake_download_url_with_content_disposition_header' ), 10, 3 ); |
| 86 | |
| 87 | $filename = download_url( 'url_with_content_disposition_header' ); |
| 88 | |
| 89 | $this->assertContains( 'filename-from-content-disposition-header', $filename ); |
| 90 | $this->assertFileExists( $filename ); |
| 91 | |
| 92 | $this->unlink( $filename ); |
| 93 | |
| 94 | remove_filter( 'pre_http_request', array( $this, '_fake_download_url_with_content_disposition_header' ) ); |
| 95 | } |
| 96 | |
| 97 | public function _fake_download_url_with_content_disposition_header( $response, $args, $url ) { |
| 98 | return array( |
| 99 | 'response' => array( |
| 100 | 'code' => 200, |
| 101 | ), |
| 102 | 'headers' => array( |
| 103 | 'Content-Disposition' => 'filename="filename-from-content-disposition-header.txt"', |
| 104 | ), |
| 105 | ); |
| 106 | } |
80 | 107 | } |