diff --git a/phpunit/class-wp-webfonts-test.php b/phpunit/class-wp-webfonts-test.php index 484217c54b03c5..569f2bd3ea20ec 100644 --- a/phpunit/class-wp-webfonts-test.php +++ b/phpunit/class-wp-webfonts-test.php @@ -343,6 +343,51 @@ public function test_generate_styles() { $expected = <<assertContains( + $expected, + get_echo( 'wp_print_styles' ) + ); + } + + /** + * Test generate_and_enqueue_editor_styles outputs registered and enqueued webfonts. + * Both are necessary so the editor correctly loads webfonts picked while in the editor. + * + * @covers WP_Webfonts::generate_and_enqueue_editor_styles + */ + public function test_generate_and_enqueue_editor_styles() { + wp_register_webfont( + 'source-serif-pro-200-900-italic-local', + array( + 'provider' => 'local', + 'font-family' => 'Source Serif Pro', + 'font-style' => 'italic', + 'font-weight' => '200 900', + 'font-stretch' => 'normal', + 'src' => 'https://example.com/assets/fonts/source-serif-pro/SourceSerif4Variable-Italic.ttf.woff2', + 'font-display' => 'fallback', + ) + ); + + wp_enqueue_webfont( + 'source-serif-pro-200-900-normal-local', // This is different from the webfont registered above. + array( + 'provider' => 'local', + 'font-family' => 'Source Serif Pro', + 'font-style' => 'normal', + 'font-weight' => '200 900', + 'font-stretch' => 'normal', + 'src' => 'https://example.com/assets/fonts/source-serif-pro/SourceSerif4Variable-Roman.ttf.woff2', + 'font-display' => 'fallback', + ) + ); + + wp_webfonts()->generate_and_enqueue_editor_styles(); + + $expected = <<assertContains(