Make WordPress Core

Changeset 55497


Ignore:
Timestamp:
03/09/2023 02:04:12 PM (16 months ago)
Author:
SergeyBiryukov
Message:

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:

Follow-up to [40124], [54508], [54509], [54724].

Props desrosj, jrf, costdev, SergeyBiryukov.
Merges [55462] to the 6.0 branch.
Fixes #56817.

Location:
branches/6.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.0

  • branches/6.0/tests/phpunit/tests/functions.php

    r53129 r55497  
    14761476        );
    14771477
    1478         add_filter( 'upload_mimes', array( $this, 'filter_mime_types_svg' ) );
     1478        add_filter(
     1479            'upload_mimes',
     1480            static function( $mimes ) {
     1481                $mimes['svg'] = 'image/svg+xml';
     1482                return $mimes;
     1483            }
     1484        );
     1485
    14791486        $this->assertSame( $expected, wp_check_filetype_and_ext( $file, $filename ) );
    1480 
    1481         // Cleanup.
    1482         remove_filter( 'upload_mimes', array( $this, 'filter_mime_types_svg' ) );
    14831487    }
    14841488
     
    14921496        $filename = 'dashicons.woff';
    14931497
     1498        $woff_mime_type = 'application/font-woff';
     1499
     1500        /*
     1501         * As of PHP 8.1.12, which includes libmagic/file update to version 5.42,
     1502         * the expected mime type for WOFF files is 'font/woff'.
     1503         *
     1504         * See https://github.com/php/php-src/issues/8805.
     1505         */
     1506        if ( PHP_VERSION_ID >= 80112 ) {
     1507            $woff_mime_type = 'font/woff';
     1508        }
     1509
    14941510        $expected = array(
    14951511            'ext'             => 'woff',
    1496             'type'            => 'application/font-woff',
     1512            'type'            => $woff_mime_type,
    14971513            'proper_filename' => false,
    14981514        );
    14991515
    1500         add_filter( 'upload_mimes', array( $this, 'filter_mime_types_woff' ) );
     1516        add_filter(
     1517            'upload_mimes',
     1518            static function( $mimes ) use ( $woff_mime_type ) {
     1519                $mimes['woff'] = $woff_mime_type;
     1520                return $mimes;
     1521            }
     1522        );
     1523
    15011524        $this->assertSame( $expected, wp_check_filetype_and_ext( $file, $filename ) );
    1502 
    1503         // Cleanup.
    1504         remove_filter( 'upload_mimes', array( $this, 'filter_mime_types_woff' ) );
    1505     }
    1506 
    1507     public function filter_mime_types_svg( $mimes ) {
    1508         $mimes['svg'] = 'image/svg+xml';
    1509         return $mimes;
    1510     }
    1511 
    1512     public function filter_mime_types_woff( $mimes ) {
    1513         $mimes['woff'] = 'application/font-woff';
    1514         return $mimes;
    15151525    }
    15161526
Note: See TracChangeset for help on using the changeset viewer.