From 7f2fd6690103be891d10372801c5b771b95b558c Mon Sep 17 00:00:00 2001 From: Paul Bearne Date: Fri, 19 Jan 2024 18:06:39 -0500 Subject: [PATCH 1/2] Add tests for print_emoji_detection_script function A new unit test file is created to ensure that the print_emoji_detection_script function works correctly. The tests check whether the final output contains the expected string and ensure no output when printing the emoji detection script again. --- .../formatting/printEmojiDetectionScript.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/phpunit/tests/formatting/printEmojiDetectionScript.php diff --git a/tests/phpunit/tests/formatting/printEmojiDetectionScript.php b/tests/phpunit/tests/formatting/printEmojiDetectionScript.php new file mode 100644 index 0000000000000..be33339fb1787 --- /dev/null +++ b/tests/phpunit/tests/formatting/printEmojiDetectionScript.php @@ -0,0 +1,25 @@ +assertStringContainsString( wp_json_encode( $png_cdn ), $output ); + + $this->assertEmpty( get_echo( 'print_emoji_detection_script' ) ); + } +} From 410a7bf8fb58d0f63a768eee8fc657b0823856db Mon Sep 17 00:00:00 2001 From: Paul Bearne Date: Wed, 28 Feb 2024 12:36:14 -0500 Subject: [PATCH 2/2] Rename Emoji detection script test to enqueue Emoji styles test Renamed the PHPUnit test file from focusing on the Emoji detection script to instead focus on the enqueueing of Emoji styles. The changes include adjusting test class and function names, and modifying asserted outputs to align with the new focus. --- .../formatting/printEmojiDetectionScript.php | 25 ----------------- .../tests/formatting/wpEnqueueEmojiStyles.php | 27 +++++++++++++++++++ 2 files changed, 27 insertions(+), 25 deletions(-) delete mode 100644 tests/phpunit/tests/formatting/printEmojiDetectionScript.php create mode 100644 tests/phpunit/tests/formatting/wpEnqueueEmojiStyles.php diff --git a/tests/phpunit/tests/formatting/printEmojiDetectionScript.php b/tests/phpunit/tests/formatting/printEmojiDetectionScript.php deleted file mode 100644 index be33339fb1787..0000000000000 --- a/tests/phpunit/tests/formatting/printEmojiDetectionScript.php +++ /dev/null @@ -1,25 +0,0 @@ -assertStringContainsString( wp_json_encode( $png_cdn ), $output ); - - $this->assertEmpty( get_echo( 'print_emoji_detection_script' ) ); - } -} diff --git a/tests/phpunit/tests/formatting/wpEnqueueEmojiStyles.php b/tests/phpunit/tests/formatting/wpEnqueueEmojiStyles.php new file mode 100644 index 0000000000000..92b7303af294b --- /dev/null +++ b/tests/phpunit/tests/formatting/wpEnqueueEmojiStyles.php @@ -0,0 +1,27 @@ +assertSame( 10, has_action( 'wp_print_styles', 'print_emoji_styles' ) ); + + wp_enqueue_emoji_styles(); + + $this->assertFalse( has_action( 'wp_print_styles', 'print_emoji_styles' ) ); + + $styles = get_echo( 'wp_print_styles' ); + $this->assertStringContainsString( 'wp-emoji-styles-inline-css', $styles ); + $this->assertStringContainsString( 'img.wp-smiley, img.emoji', $styles ); + } +}