-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move mime-type collection generation to a function that can be tested… (
#54844) * Move mime-type collection generation to a function that can be tested. Refactored to use that function. * linting changes * Add unit tests to mime type getter * Fixed linting errors * test the entire output array and replace assertTrue by assertEquals * fixing docs --------- Co-authored-by: Matias Benedetto <[email protected]>
- Loading branch information
Showing
4 changed files
with
116 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
phpunit/tests/fonts/font-library/wpFontLibrary/getMimeTypes.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php | ||
/** | ||
* Test WP_Font_Family_Utils::get_expected_font_mime_types_per_php_version(). | ||
* | ||
* @package WordPress | ||
* @subpackage Font Library | ||
* | ||
* @group fonts | ||
* @group font-library | ||
* | ||
* @covers WP_Font_Family_Utils::get_expected_font_mime_types_per_php_version | ||
*/ | ||
class Tests_Fonts_WpFontsFamilyUtils_GetMimeTypes extends WP_UnitTestCase { | ||
|
||
/** | ||
* | ||
* @dataProvider data_should_supply_correct_mime_type_for_php_version | ||
* | ||
* @param array $php_version_id PHP_VERSION_ID value. | ||
* @param array $expected Expected mime types. | ||
*/ | ||
public function test_should_supply_correct_mime_type_for_php_version( $php_version_id, $expected ) { | ||
$mimes = WP_Font_Library::get_expected_font_mime_types_per_php_version( $php_version_id ); | ||
$this->assertEquals( $mimes, $expected ); | ||
} | ||
|
||
/** | ||
* Data provider. | ||
* | ||
* @return array[] | ||
*/ | ||
public function data_should_supply_correct_mime_type_for_php_version() { | ||
return array( | ||
'version 7.2' => array( | ||
'php_version_id' => 70200, | ||
'expected' => array( | ||
'otf' => 'font/otf', | ||
'ttf' => 'application/x-font-ttf', | ||
'woff' => 'application/font-woff', | ||
'woff2' => 'application/font-woff2', | ||
), | ||
), | ||
'version 7.3' => array( | ||
'php_version_id' => 70300, | ||
'expected' => array( | ||
'otf' => 'font/otf', | ||
'ttf' => 'application/font-sfnt', | ||
'woff' => 'application/font-woff', | ||
'woff2' => 'application/font-woff2', | ||
), | ||
), | ||
'version 7.4' => array( | ||
'php_version_id' => 70400, | ||
'expected' => array( | ||
'otf' => 'font/otf', | ||
'ttf' => 'font/sfnt', | ||
'woff' => 'application/font-woff', | ||
'woff2' => 'application/font-woff2', | ||
), | ||
), | ||
'version 8.0' => array( | ||
'php_version_id' => 80000, | ||
'expected' => array( | ||
'otf' => 'font/otf', | ||
'ttf' => 'font/sfnt', | ||
'woff' => 'application/font-woff', | ||
'woff2' => 'application/font-woff2', | ||
), | ||
), | ||
'version 8.1' => array( | ||
'php_version_id' => 80100, | ||
'expected' => array( | ||
'otf' => 'font/otf', | ||
'ttf' => 'font/sfnt', | ||
'woff' => 'font/woff', | ||
'woff2' => 'font/woff2', | ||
), | ||
), | ||
'version 8.2' => array( | ||
'php_version_id' => 80200, | ||
'expected' => array( | ||
'otf' => 'font/otf', | ||
'ttf' => 'font/sfnt', | ||
'woff' => 'font/woff', | ||
'woff2' => 'font/woff2', | ||
), | ||
), | ||
); | ||
} | ||
} |