Skip to content

Commit cc6bf38

Browse files
committed
Add method test suite
1 parent dd9c108 commit cc6bf38

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
/**
3+
* Test WP_Font_Utils::normalize_css_font_face_font_family().
4+
*
5+
* @package WordPress
6+
* @subpackage Font Library
7+
*
8+
* @group fonts
9+
* @group font-library
10+
*
11+
* @covers WP_Font_Utils::normalize_css_font_face_font_family
12+
*/
13+
class Tests_Fonts_WpFontUtils_normalizeCssFontFaceFontFamily extends WP_UnitTestCase {
14+
/**
15+
* @ticket TBD
16+
*
17+
* @dataProvider data_provider
18+
*/
19+
public function test_normalize_css_font_face_font_family( string $input, ?string $expected ): void {
20+
$result = WP_Font_Utils::normalize_css_font_face_font_family( $input );
21+
$this->assertSame( $expected, $result );
22+
23+
// Idempotency check.
24+
if ( null !== $result ) {
25+
$this->assertSame( $result, WP_Font_Utils::normalize_css_font_face_font_family( $result ) );
26+
}
27+
}
28+
29+
/**
30+
* Data provider.
31+
*/
32+
public static function data_provider(): Generator {
33+
yield 'Already normalized' => array( '"Font"', '"Font"' );
34+
yield 'Unquoted' => array( 'Font', '"Font"' );
35+
yield 'Multiple idents' => array( 'Font Name', '"Font Name"' );
36+
yield 'Unitless number?' => array( 'Libre Barcode 128 Text', null );
37+
yield 'Unitful number?' => array( '10px Size', null );
38+
}
39+
}

0 commit comments

Comments
 (0)