-
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.
- Loading branch information
1 parent
b153978
commit b9d87ad
Showing
3 changed files
with
176 additions
and
137 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
phpunit/fonts-library/wpFonFamilyUtils/getFilenameFromFontFace-test.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,64 @@ | ||
<?php | ||
/** | ||
* Test WP_Font_Family_Utils::get_filename_from_font_face(). | ||
* | ||
* @package WordPress | ||
* @subpackage Fonts Library | ||
* | ||
* @group fonts | ||
* @group fonts-library | ||
* | ||
* @covers WP_Font_Family_Utils::get_filename_from_font_face | ||
*/ | ||
class Tests_Fonts_WpFontsFamilyUtils_GetFilenameFromFontFace extends WP_UnitTestCase { | ||
|
||
/** | ||
* @dataProvider data_should_get_filename | ||
* | ||
* @param string $slug Font slug. | ||
* @param array $font_face Font face data in theme.json format. | ||
* @param string $suffix Suffix added to the resulting filename. | ||
* @param string $expected Expected filename. | ||
*/ | ||
public function test_should_get_filename( $slug, $font_face, $suffix, $expected ) { | ||
$this->assertSame( | ||
$expected, | ||
WP_Font_Family_Utils::get_filename_from_font_face( | ||
$slug, | ||
$font_face, | ||
$font_face['src'], | ||
$suffix | ||
) | ||
); | ||
} | ||
|
||
/** | ||
* Data provider. | ||
* | ||
* @return array[] | ||
*/ | ||
public function data_should_get_filename() { | ||
return array( | ||
'piazzolla' => array( | ||
'slug' => 'piazzolla', | ||
'font_face' => array( | ||
'fontStyle' => 'italic', | ||
'fontWeight' => '400', | ||
'src' => 'http://example.com/fonts/font_file.ttf', | ||
), | ||
'suffix' => '', | ||
'expected_file_name' => 'piazzolla_italic_400.ttf', | ||
), | ||
'inter' => array( | ||
'slug' => 'inter', | ||
'font_face' => array( | ||
'fontStyle' => 'normal', | ||
'fontWeight' => '600', | ||
'src' => 'http://example.com/fonts/font_file.otf', | ||
), | ||
'suffix' => '', | ||
'expected_file_name' => 'inter_normal_600.otf', | ||
), | ||
); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
phpunit/fonts-library/wpFonFamilyUtils/hasFontMimeType-test.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,61 @@ | ||
<?php | ||
/** | ||
* Test WP_Font_Family_Utils::has_font_mime_type(). | ||
* | ||
* @package WordPress | ||
* @subpackage Fonts Library | ||
* | ||
* @group fonts | ||
* @group fonts-library | ||
* | ||
* @covers WP_Font_Family_Utils::has_font_mime_type | ||
*/ | ||
class Tests_Fonts_WpFontsFamilyUtils_HasFontMimeType extends WP_UnitTestCase { | ||
|
||
/** | ||
* @dataProvider data_should_succeed_when_has_mime_type | ||
* | ||
* @param string $font_file Font file path. | ||
*/ | ||
public function test_should_succeed_when_has_mime_type( $font_file ) { | ||
$this->assertTrue( WP_Font_Family_Utils::has_font_mime_type( $font_file ) ); | ||
} | ||
|
||
/** | ||
* Data provider. | ||
* | ||
* @return array[] | ||
*/ | ||
public function data_should_succeed_when_has_mime_type() { | ||
return array( | ||
'ttf' => array( '/temp/piazzolla_400_italic.ttf' ), | ||
'otf' => array( '/temp/piazzolla_400_italic.otf' ), | ||
'woff' => array( '/temp/piazzolla_400_italic.woff' ), | ||
'woff2' => array( '/temp/piazzolla_400_italic.woff2' ), | ||
); | ||
} | ||
|
||
/** | ||
* @dataProvider data_should_fail_when_mime_not_supported | ||
* | ||
* @param string $font_file Font file path. | ||
*/ | ||
public function test_should_fail_when_mime_not_supported( $font_file ) { | ||
$this->assertFalse( WP_Font_Family_Utils::has_font_mime_type( $font_file ) ); | ||
} | ||
|
||
/** | ||
* Data provider. | ||
* | ||
* @return array[] | ||
*/ | ||
public function data_should_fail_when_mime_not_supported() { | ||
return array( | ||
'exe' => array( '/temp/test.exe' ), | ||
'md' => array( '/temp/license.md' ), | ||
'php' => array( '/temp/test.php' ), | ||
'txt' => array( '/temp/test.txt' ), | ||
'zip' => array( '/temp/lato.zip' ), | ||
); | ||
} | ||
} |
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