Skip to content

Tests: Cover translate_smiley() - #15789

Open
devmuhib009 wants to merge 2 commits into
WordPress:trunkfrom
devmuhib009:test/cover-translate-smiley
Open

devmuhib009 wants to merge 2 commits into
WordPress:trunkfrom
devmuhib009:test/cover-translate-smiley

Conversation

@devmuhib009

@devmuhib009 devmuhib009 commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

Description

Adds unit tests for the translate_smiley() function in src/wp-includes/formatting.php.

The tests cover:

  • Handling empty match arrays returning an empty string.
  • Converting image-based smilies into an <img> element with proper attributes (class="wp-smiley", alt, style, and src).
  • Smilies that map to Unicode characters (emoji) returning the unmodified character string.
  • Filtering the generated image URL with the smilies_src filter.

Test-only change.

Testing Instructions

npm run test:php -- --filter Tests_Formatting_TranslateSmiley
npm run test:php -- -c tests/phpunit/multisite.xml --filter Tests_Formatting_TranslateSmiley
vendor/bin/phpcs tests/phpunit/tests/formatting/translateSmiley.php

Trac ticket: https://core.trac.wordpress.org/ticket/66611

See #65819.
Props devmuhib009.
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

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:

Props devmuhib, huzaifaalmesbah.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@huzaifaalmesbah huzaifaalmesbah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this, @devmuhib009! Clean coverage for translate_smiley() and smiley replacement markup.

Per #65819 comment 1521, test-only changes now need their own Trac ticket by component instead of #65819.

For translate_smiley() in src/wp-includes/formatting.php, the component is Formatting.

Could you please:

  1. Open a new Trac ticket under Formatting with the has-patch and has-unit-tests keywords and link this PR.
  2. Update the Trac ticket: reference in this PR's description.
  3. Update the @ticket 65819 annotations in translateSmiley.php with the new ticket number.

AI Review: Gemini 3.8 Flash

See #66611.
Props devmuhib009.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants