Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -463,20 +463,7 @@ function ( $font_dir ) {
*/
public function test_create_item_with_multiple_font_files() {
wp_set_current_user( self::$admin_id );

$formats = array( 'ttf', 'otf', 'woff', 'woff2' );

/*
* Some libmagic versions cannot detect TrueType fonts and report them as
* application/octet-stream, which causes the upload to be rejected.
*
* @link https://github.com/php/php-src/issues/25051
*/
if ( 'application/octet-stream' === finfo_file( finfo_open( FILEINFO_MIME_TYPE ), DIR_TESTDATA . '/fonts/OpenSans-Regular.ttf' ) ) {
$formats = array_diff( $formats, array( 'ttf' ) );
}

$files = $this->setup_font_file_upload( $formats );
$files = $this->setup_font_file_upload( array( 'ttf', 'otf', 'woff', 'woff2' ) );

$request = new WP_REST_Request( 'POST', '/wp/v2/font-families/' . self::$font_family_id . '/font-faces' );
$request->set_param( 'theme_json_version', WP_REST_Font_Faces_Controller::LATEST_THEME_JSON_VERSION_SUPPORTED );
Expand All @@ -501,7 +488,7 @@ public function test_create_item_with_multiple_font_files() {
$this->check_file_meta( $data['id'], $data['font_face_settings']['src'] );

$settings = $data['font_face_settings'];
$this->assertCount( count( $files ), $settings['src'], 'There should be one item in the font_face_settings::src data for each uploaded file.' );
$this->assertCount( 4, $settings['src'], 'There should be 4 items in the font_face_settings::src data.' );
}

/**
Expand Down
5 changes: 0 additions & 5 deletions tests/phpunit/tests/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1910,11 +1910,6 @@ public function test_wp_check_filetype_and_ext_accepts_either_ttf_mime_type( $mi
$file = DIR_TESTDATA . '/fonts/OpenSans-Regular.ttf';
$filename = 'OpenSans-Regular.ttf';

$detected_type = finfo_file( finfo_open( FILEINFO_MIME_TYPE ), $file );
if ( ! in_array( $detected_type, array( 'font/ttf', 'font/sfnt' ), true ) ) {
$this->markTestSkipped( "This version of libmagic detects TrueType fonts as {$detected_type}." );
}

$filter = static function ( $mimes ) use ( $mime_type ) {
$mimes['ttf'] = $mime_type;
return $mimes;
Expand Down
Loading