Skip to content

Commit 3ae671b

Browse files
add and update tests
1 parent af9c602 commit 3ae671b

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

tests/test-theme-fonts.php

+15-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ public function test_copy_activated_fonts_to_theme() {
5151
$this->assertEquals( 'open-sans', $theme_data_after['typography']['fontFamilies']['theme'][1]['slug'] );
5252

5353
// Ensure that the URL was changed to a local file and that it was copied to where it should be
54-
$this->assertEquals( 'file:./assets/fonts/open-sans-normal-400.ttf', $theme_data_after['typography']['fontFamilies']['theme'][1]['fontFace'][0]['src'][0] );
55-
$this->assertTrue( file_exists( get_stylesheet_directory() . '/assets/fonts/open-sans-normal-400.ttf' ) );
54+
$this->assertEquals( 'file:./assets/fonts/open-sans-400-normal.ttf', $theme_data_after['typography']['fontFamilies']['theme'][1]['fontFace'][0]['src'][0] );
55+
$this->assertTrue( file_exists( get_stylesheet_directory() . '/assets/fonts/open-sans-400-normal.ttf' ) );
5656

5757
$this->uninstall_theme( $test_theme_slug );
5858

@@ -486,5 +486,18 @@ private function activate_font_in_theme_and_override_in_user() {
486486
CBT_Theme_JSON_Resolver::write_user_settings( $settings );
487487
}
488488

489+
public function test_make_filename_from_fontface() {
490+
$font_face = array(
491+
'fontFamily' => 'Open Sans',
492+
'fontWeight' => '400',
493+
'fontStyle' => 'normal',
494+
'unicodeRange' => 'U+0000-00FF',
495+
);
496+
$src = 'https://example.com/assets/fonts/open-sans-regular.ttf';
497+
$src_index = 0;
498+
$expected = 'open-sans-400-normal-u0000-00ff.ttf';
499+
$actual = CBT_Theme_Fonts::make_filename_from_fontface( $font_face, $src, $src_index );
500+
$this->assertEquals( $expected, $actual );
501+
}
489502
}
490503

0 commit comments

Comments
 (0)