mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Improve testability and coverage of wp_ext2type().
* Following pattern of `wp_get_mime_types()`, introduce `wp_get_ext_types()` function. New function returns a filtered list of file types with their extensions. * Use this function in new tests for `wp_ext2type()`. Props borgesbruno. Fixes #35987. git-svn-id: https://develop.svn.wordpress.org/trunk@37189 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -813,4 +813,39 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
array( '2016-03-02T19:13:00', '16-03-02 19:13' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 35987
|
||||
*/
|
||||
public function test_wp_get_ext_types() {
|
||||
$extensions = wp_get_ext_types();
|
||||
|
||||
$this->assertInternalType( 'array', $extensions );
|
||||
$this->assertNotEmpty( $extensions );
|
||||
|
||||
add_filter( 'ext2type', '__return_empty_array' );
|
||||
$extensions = wp_get_ext_types();
|
||||
$this->assertSame( array(), $extensions );
|
||||
|
||||
remove_filter( 'ext2type', '__return_empty_array' );
|
||||
$extensions = wp_get_ext_types();
|
||||
$this->assertInternalType( 'array', $extensions );
|
||||
$this->assertNotEmpty( $extensions );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 35987
|
||||
*/
|
||||
public function test_wp_ext2type() {
|
||||
$extensions = wp_get_ext_types();
|
||||
|
||||
foreach ( $extensions as $type => $extensionList ) {
|
||||
foreach ( $extensionList as $extension ) {
|
||||
$this->assertEquals( $type, wp_ext2type( $extension ) );
|
||||
$this->assertEquals( $type, wp_ext2type( strtoupper( $extension ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertNull( wp_ext2type( 'unknown_format' ) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user