Repository navigation
Conversation
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.
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
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.
…nto 60306-wp_enqueue_emoji_styles
There was a problem hiding this comment.
🟡 Changes recommended
The tests leave shared $wp_styles state mutated, risking order-dependent failures, and omit coverage of the promised emoji detection-script behavior.
2 open issues
What changed in this PR
Adds a PHPUnit test to WordPress’s formatting suite for emoji stylesheet enqueueing.
Changes:
- Checks that enqueueing removes the legacy
print_emoji_stylescallback. - Verifies that printed styles contain the expected inline-style identifier and emoji selectors.
| File | Description |
|---|---|
tests/phpunit/tests/formatting/wpEnqueueEmojiStyles.php |
Adds coverage for wp_enqueue_emoji_styles() hook removal and CSS output. |
Review effort: Balanced
|
|
||
| $this->assertSame( 10, has_action( 'wp_print_styles', 'print_emoji_styles' ) ); | ||
|
|
||
| wp_enqueue_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 ); |
lancewillett
left a comment
There was a problem hiding this comment.
The style-enqueue check passed alone (one test, four assertions) and alongside existing emoji/style tests. The multisite group passed 99 tests and 226 assertions. The single-site group’s only failure was in the separate widget-menu proposal, #5830.
Please correct the copied title/docblock to describe style enqueuing; do not add detection-script tests, which current trunk already covers. Copilot’s shared-style-state observation is worth following up if an existing test/order exposes it. These local runs did not demonstrate an affected consumer, so additional isolation benefit remains unproven. This older head has no current CI checks; run CI before landing.
AI review · gpt-6
| public function test_wp_enqueue_emoji_styles() { | ||
|
|
||
| $this->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 ); | ||
| } |
| public function test_wp_enqueue_emoji_styles() { | ||
|
|
||
| $this->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 ); | ||
| } |
Check that `wp_enqueue_emoji_styles()` removes the legacy style-printing callback and emits the expected inline emoji styles. Developed in: #5912 Props pbearne. See #60301. git-svn-id: https://develop.svn.wordpress.org/trunk@65144 602fd350-edb4-49c9-b593-d223f7449a82
Check that `wp_enqueue_emoji_styles()` removes the legacy style-printing callback and emits the expected inline emoji styles. Developed in: WordPress/wordpress-develop#5912 Props pbearne. See #60301. Built from https://develop.svn.wordpress.org/trunk@65144 git-svn-id: http://core.svn.wordpress.org/trunk@64293 1a063a9b-81f0-0310-95a4-ce76da25c4cd
|
PR #5912 landed in https://core.trac.wordpress.org/changeset/65144 |

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.
Trac ticket: https://core.trac.wordpress.org/ticket/60301