Skip to content

Commit

Permalink
Remove test temporarily
Browse files Browse the repository at this point in the history
Because `WP_Font_Face_Resolver` already exists in Core release code, this update cannot be tested in CI without migrating the code into a temporary `_Gutenberg` resolver, which will complicate syncing back to Core.

Test will be added to a follow-up PR, to merge once this update is synced to Core.

Note that this test does succeed when run locally against WP `trunk` (currently 6.4-alpha).
  • Loading branch information
ironprogrammer committed Sep 22, 2023
1 parent 084e83d commit 29df9f8
Showing 1 changed file with 0 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,108 +101,4 @@ public function data_should_replace_src_file_placeholder() {
),
);
}

/**
* @dataProvider data_should_get_font_family_name
*
* @param array $fonts Fonts to test.
* @param string $expected_name Expected font-family name.
*/
public function test_should_get_font_family_name( $fonts, $expected_name ) {
switch_theme( static::FONTS_THEME );

$replace_fonts = static function ( $theme_json_data ) use ( $fonts ) {
$data = $theme_json_data->get_data();

// Replace typography.fontFamilies.
$data['settings']['typography']['fontFamilies']['theme'] = $fonts;

return new WP_Theme_JSON_Data_Gutenberg( $data );
};
add_filter( 'wp_theme_json_data_theme', $replace_fonts );
$fonts = WP_Font_Face_Resolver::get_fonts_from_theme_json();
remove_filter( 'wp_theme_json_data_theme', $replace_fonts );

$this->assertArrayHasKey( $expected_name, $fonts );
}

/**
* Data provider.
*
* @return array
*/
public function data_should_get_font_family_name() {
$font_face = array(
array(
'fontFamily' => 'DM Sans',
'fontStretch' => 'normal',
'fontStyle' => 'normal',
'fontWeight' => '400',
'src' => array(
'file:./assets/fonts/dm-sans/DMSans-Regular.woff2',
),
),
array(
'fontFamily' => 'DM Sans',
'fontStretch' => 'normal',
'fontStyle' => 'italic',
'fontWeight' => '400',
'src' => array(
'file:./assets/fonts/dm-sans/DMSans-Regular-Italic.woff2',
),
),
array(
'fontFamily' => 'DM Sans',
'fontStretch' => 'normal',
'fontStyle' => 'italic',
'fontWeight' => '700',
'src' => array(
'file:./assets/fonts/dm-sans/DMSans-Bold.woff2',
),
),
array(
'fontFamily' => 'DM Sans',
'fontStretch' => 'normal',
'fontStyle' => 'italic',
'fontWeight' => '700',
'src' => array(
'file:./assets/fonts/dm-sans/DMSans-Bold-Italic.woff2',
),
),
);

return array(
'name declared' => array(
'fonts' => array(
array(
'fontFamily' => 'DM Sans',
'name' => 'DM Sans Family',
'slug' => 'dm-sans',
'fontFace' => $font_face,
),
),
'expected_name' => 'DM Sans',
),
'name not declared' => array(
'fonts' => array(
array(
'fontFamily' => 'DM Sans',
'slug' => 'dm-sans',
'fontFace' => $font_face,
),
),
'expected_name' => 'DM Sans',
),
'fontFamily comma-separated list' => array(
'fonts' => array(
array(
'fontFamily' => '"DM Sans", sans-serif',
'slug' => 'dm-sans',
'fontFace' => $font_face,
),
),
'expected_name' => 'DM Sans',
),
);
}
}

0 comments on commit 29df9f8

Please sign in to comment.