Skip to content

Commit e6c93ae

Browse files
committed
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: #15278, #15279 Props shailu25. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@65164 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 613a754 commit e6c93ae

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎tests/phpunit/tests/functions.php‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,12 +1147,21 @@ public function test_wp_get_ext_types() {
11471147

11481148
/**
11491149
* @ticket 35987
1150+
* @ticket 65819
1151+
* @covers ::wp_ext2type
11501152
*/
11511153
public function test_wp_ext2type() {
11521154
$extensions = wp_get_ext_types();
11531155

11541156
$this->assertNotEmpty( $extensions );
11551157

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' ) );
1164+
11561165
foreach ( $extensions as $type => $extension_list ) {
11571166
foreach ( $extension_list as $extension ) {
11581167
$this->assertSame( $type, wp_ext2type( $extension ) );
@@ -2265,11 +2274,15 @@ public static function data_wp_is_json_media_type() {
22652274

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() {
22702281
$this->assertSame( 'jpg', wp_get_default_extension_for_mime_type( 'image/jpeg' ), 'jpg not returned as default extension for "image/jpeg"' );
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' );
22752288
$this->assertFalse( wp_get_default_extension_for_mime_type( ' ' ), 'false not returned when empty string as mime type supplied' );

0 commit comments

Comments
 (0)