diff --git a/tests/phpunit/tests/post/attachments.php b/tests/phpunit/tests/post/attachments.php index 6c922b9747..f33e7cd816 100644 --- a/tests/phpunit/tests/post/attachments.php +++ b/tests/phpunit/tests/post/attachments.php @@ -500,8 +500,30 @@ class Tests_Post_Attachments extends WP_UnitTestCase { } } + public function test_upload_mimes_filter_is_applied() { + $filename = DIR_TESTDATA . '/images/test-image.jpg'; + $contents = file_get_contents( $filename ); + + $upload = wp_upload_bits( basename( $filename ), null, $contents ); + + $this->assertFalse( $upload['error'] ); + + add_filter( 'upload_mimes', array( $this, 'blacklist_jpg_mime_type' ) ); + + $upload = wp_upload_bits( basename( $filename ), null, $contents ); + + $this->assertNotEmpty( $upload['error'] ); + + remove_filter( 'upload_mimes', array( $this, 'blacklist_jpg_mime_type' ) ); + } + public function whitelist_psd_mime_type( $mimes ) { $mimes['psd'] = 'application/octet-stream'; return $mimes; } + + public function blacklist_jpg_mime_type( $mimes ) { + unset( $mimes['jpg|jpeg|jpe'] ); + return $mimes; + } }