From 2ae276c44fed50eb80d6c6b11bc1f3aa621e57d8 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 16 Jul 2019 21:51:45 +0000 Subject: [PATCH] Media: Add a unit test for `wp_get_mime_types()`. Props pbearne. Fixes #47701. git-svn-id: https://develop.svn.wordpress.org/trunk@45646 602fd350-edb4-49c9-b593-d223f7449a82 --- .../tests/functions/wpGetMimeTypes.php | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/phpunit/tests/functions/wpGetMimeTypes.php diff --git a/tests/phpunit/tests/functions/wpGetMimeTypes.php b/tests/phpunit/tests/functions/wpGetMimeTypes.php new file mode 100644 index 0000000000..dec3ea73d6 --- /dev/null +++ b/tests/phpunit/tests/functions/wpGetMimeTypes.php @@ -0,0 +1,30 @@ +assertInternalType( 'array', $mime_types_start ); + $this->assertNotEmpty( $mime_types_start ); + + add_filter( 'mime_types', '__return_empty_array' ); + $mime_types_empty = wp_get_mime_types(); + $this->assertSame( array(), $mime_types_empty ); + + remove_filter( 'mime_types', '__return_empty_array' ); + $mime_types = wp_get_mime_types(); + $this->assertInternalType( 'array', $mime_types ); + $this->assertNotEmpty( $mime_types ); + // Did it revert to the original after filter remove? + $this->assertSame( $mime_types_start, $mime_types ); + } +}