-
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.
Font Faces endpoint: prevent creating font faces with duplicate setti…
…ngs (#57903)
- Loading branch information
1 parent
13b5640
commit 3e37968
Showing
6 changed files
with
247 additions
and
27 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
81 changes: 81 additions & 0 deletions
81
phpunit/tests/fonts/font-library/wpFontFamilyUtils/getFontFaceSlug.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,81 @@ | ||
<?php | ||
/** | ||
* Test WP_Font_Family_Utils::get_font_face_slug(). | ||
* | ||
* @package WordPress | ||
* @subpackage Font Library | ||
* * | ||
* @covers WP_Font_Family_Utils::get_font_face_slug | ||
*/ | ||
class Tests_Fonts_WpFontsFamilyUtils_GetFontFamilySlug extends WP_UnitTestCase { | ||
/** | ||
* @dataProvider data_get_font_face_slug_normalizes_values | ||
*/ | ||
public function test_get_font_face_slug_normalizes_values( $settings, $expected_slug ) { | ||
$slug = WP_Font_Family_Utils::get_font_face_slug( $settings ); | ||
|
||
$this->assertSame( $expected_slug, $slug ); | ||
} | ||
|
||
public function data_get_font_face_slug_normalizes_values() { | ||
return array( | ||
'Sets defaults' => array( | ||
'settings' => array( | ||
'fontFamily' => 'Open Sans', | ||
), | ||
'expected_slug' => 'open sans;normal;400;100%;U+0-10FFFF', | ||
), | ||
'Converts normal weight to 400' => array( | ||
'settings' => array( | ||
'fontFamily' => 'Open Sans', | ||
'fontWeight' => 'normal', | ||
), | ||
'expected_slug' => 'open sans;normal;400;100%;U+0-10FFFF', | ||
), | ||
'Converts bold weight to 700' => array( | ||
'settings' => array( | ||
'fontFamily' => 'Open Sans', | ||
'fontWeight' => 'bold', | ||
), | ||
'expected_slug' => 'open sans;normal;700;100%;U+0-10FFFF', | ||
), | ||
'Converts normal font-stretch to 100%' => array( | ||
'settings' => array( | ||
'fontFamily' => 'Open Sans', | ||
'fontStretch' => 'normal', | ||
), | ||
'expected_slug' => 'open sans;normal;400;100%;U+0-10FFFF', | ||
), | ||
'Removes double quotes from fontFamilies' => array( | ||
'settings' => array( | ||
'fontFamily' => '"Open Sans"', | ||
), | ||
'expected_slug' => 'open sans;normal;400;100%;U+0-10FFFF', | ||
), | ||
'Removes single quotes from fontFamilies' => array( | ||
'settings' => array( | ||
'fontFamily' => "'Open Sans'", | ||
), | ||
'expected_slug' => 'open sans;normal;400;100%;U+0-10FFFF', | ||
), | ||
'Removes spaces between comma separated font families' => array( | ||
'settings' => array( | ||
'fontFamily' => 'Open Sans, serif', | ||
), | ||
'expected_slug' => 'open sans,serif;normal;400;100%;U+0-10FFFF', | ||
), | ||
'Removes tabs between comma separated font families' => array( | ||
'settings' => array( | ||
'fontFamily' => "Open Sans,\tserif", | ||
), | ||
'expected_slug' => 'open sans,serif;normal;400;100%;U+0-10FFFF', | ||
), | ||
'Removes new lines between comma separated font families' => array( | ||
'settings' => array( | ||
'fontFamily' => "Open Sans,\nserif", | ||
), | ||
'expected_slug' => 'open sans,serif;normal;400;100%;U+0-10FFFF', | ||
), | ||
); | ||
} | ||
} |
Oops, something went wrong.