mirror of
git://develop.git.wordpress.org/
synced 2025-04-07 21:53:21 +02:00
Tests: Adjust the expected mime type for WOFF fonts on PHP 8.1.12+.
As of PHP 8.1.12, which includes libmagic/file update to version 5.42, the expected mime type for WOFF files has changed to `font/woff`, so the type needs to be adjusted accordingly in `wp_check_filetype_and_ext()` tests. References: * [https://github.com/php/php-src/issues/8805 php-src: #8805: finfo returns wrong mime type for woff/woff2 files] * [https://www.php.net/ChangeLog-8.php#8.1.12 PHP 8.1.12 changelog] Follow-up to [40124], [54508], [54509], [54724]. Props costdev, SergeyBiryukov. Merges [55462] to the 6.1 branch. Fixes #56817. git-svn-id: https://develop.svn.wordpress.org/branches/6.1@55463 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
7c965e781f
commit
5eefddf4af
@ -1391,11 +1391,15 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
'proper_filename' => false,
|
||||
);
|
||||
|
||||
add_filter( 'upload_mimes', array( $this, 'filter_mime_types_svg' ) );
|
||||
$this->assertSame( $expected, wp_check_filetype_and_ext( $file, $filename ) );
|
||||
add_filter(
|
||||
'upload_mimes',
|
||||
static function( $mimes ) {
|
||||
$mimes['svg'] = 'image/svg+xml';
|
||||
return $mimes;
|
||||
}
|
||||
);
|
||||
|
||||
// Cleanup.
|
||||
remove_filter( 'upload_mimes', array( $this, 'filter_mime_types_svg' ) );
|
||||
$this->assertSame( $expected, wp_check_filetype_and_ext( $file, $filename ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1404,40 +1408,36 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
* @requires extension fileinfo
|
||||
*/
|
||||
public function test_wp_check_filetype_and_ext_with_filtered_woff() {
|
||||
if ( PHP_VERSION_ID >= 80100 ) {
|
||||
/*
|
||||
* For the time being, this test is marked skipped on PHP 8.1+ as a recent change introduced
|
||||
* an inconsistency with how the mime-type for WOFF files are handled compared to older versions.
|
||||
*
|
||||
* See https://core.trac.wordpress.org/ticket/56817 for more details.
|
||||
*/
|
||||
$this->markTestSkipped( 'This test currently fails on PHP 8.1+ and requires further investigation.' );
|
||||
}
|
||||
|
||||
$file = DIR_TESTDATA . '/uploads/dashicons.woff';
|
||||
$filename = 'dashicons.woff';
|
||||
|
||||
$woff_mime_type = 'application/font-woff';
|
||||
|
||||
/*
|
||||
* As of PHP 8.1.12, which includes libmagic/file update to version 5.42,
|
||||
* the expected mime type for WOFF files is 'font/woff'.
|
||||
*
|
||||
* See https://github.com/php/php-src/issues/8805.
|
||||
*/
|
||||
if ( PHP_VERSION_ID >= 80112 ) {
|
||||
$woff_mime_type = 'font/woff';
|
||||
}
|
||||
|
||||
$expected = array(
|
||||
'ext' => 'woff',
|
||||
'type' => 'application/font-woff',
|
||||
'type' => $woff_mime_type,
|
||||
'proper_filename' => false,
|
||||
);
|
||||
|
||||
add_filter( 'upload_mimes', array( $this, 'filter_mime_types_woff' ) );
|
||||
add_filter(
|
||||
'upload_mimes',
|
||||
static function( $mimes ) use ( $woff_mime_type ) {
|
||||
$mimes['woff'] = $woff_mime_type;
|
||||
return $mimes;
|
||||
}
|
||||
);
|
||||
|
||||
$this->assertSame( $expected, wp_check_filetype_and_ext( $file, $filename ) );
|
||||
|
||||
// Cleanup.
|
||||
remove_filter( 'upload_mimes', array( $this, 'filter_mime_types_woff' ) );
|
||||
}
|
||||
|
||||
public function filter_mime_types_svg( $mimes ) {
|
||||
$mimes['svg'] = 'image/svg+xml';
|
||||
return $mimes;
|
||||
}
|
||||
|
||||
public function filter_mime_types_woff( $mimes ) {
|
||||
$mimes['woff'] = 'application/font-woff';
|
||||
return $mimes;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user