Make WordPress Core

Changeset 65164


Ignore:
Timestamp:
11/01/2026 05:26:55 PM (7 days ago)
Author:
lancewillett
Message:

Tests: Expand MIME type and extension assertions.

Add literal extension-to-type and MIME-to-extension expectations to the existing tests for wp_ext2type() and wp_get_default_extension_for_mime_type().

Developed in: ​https://github.com/WordPress/wordpress-develop/pull/15278, ​https://github.com/WordPress/wordpress-develop/pull/15279

Props shailu25.
See #65819.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/functions.php

    r64745 r65164  
    11481148        /**
    11491149         * @ticket 35987
     1150         * @ticket 65819
     1151         * @covers ::wp_ext2type
    11501152         */
    11511153        public function test_wp_ext2type() {
    … …  
    11531155
    11541156                $this->assertNotEmpty( $extensions );
     1157
     1158                // Literal mappings stay independent of the current registry contents.
     1159                $this->assertSame( 'image', wp_ext2type( 'jpg' ) );
     1160                $this->assertSame( 'image', wp_ext2type( 'PNG' ) );
     1161                $this->assertSame( 'audio', wp_ext2type( 'mp3' ) );
     1162                $this->assertSame( 'video', wp_ext2type( 'mp4' ) );
     1163                $this->assertSame( 'document', wp_ext2type( 'pdf' ) );
    11551164
    11561165                foreach ( $extensions as $type => $extension_list ) {
    … …  
    22662275        /**
    22672276         * @ticket 53668
     2277         * @ticket 65819
     2278         * @covers ::wp_get_default_extension_for_mime_type
    22682279         */
    22692280        public function test_wp_get_default_extension_for_mime_type() {
    … …  
    22712282                $this->assertNotSame( 'jpeg', wp_get_default_extension_for_mime_type( 'image/jpeg' ), 'jpeg should not be returned as default extension for "image/jpeg"' );
    22722283                $this->assertSame( 'png', wp_get_default_extension_for_mime_type( 'image/png' ), 'png not returned as default extension for "image/png"' );
     2284                $this->assertSame( 'pdf', wp_get_default_extension_for_mime_type( 'application/pdf' ), 'pdf not returned as default extension for "application/pdf"' );
     2285                $this->assertSame( 'mp3', wp_get_default_extension_for_mime_type( 'audio/mpeg' ), 'mp3 not returned as default extension for "audio/mpeg"' );
    22732286                $this->assertFalse( wp_get_default_extension_for_mime_type( 'wibble/wobble' ), 'false not returned for unrecognized mime type' );
    22742287                $this->assertFalse( wp_get_default_extension_for_mime_type( '' ), 'false not returned when empty string as mime type supplied' );
Note: See TracChangeset for help on using the changeset viewer.