From eb100609e11ad11121736b1469bef03ca0864e37 Mon Sep 17 00:00:00 2001 From: Muhibul Haque Date: Sat, 7 Nov 2026 11:44:29 +0600 Subject: [PATCH 1/2] Tests: Cover translate_smiley(). See #65819. Props devmuhib009. --- .../tests/formatting/translateSmiley.php | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 tests/phpunit/tests/formatting/translateSmiley.php diff --git a/tests/phpunit/tests/formatting/translateSmiley.php b/tests/phpunit/tests/formatting/translateSmiley.php new file mode 100644 index 0000000000000..7621a57c3a591 --- /dev/null +++ b/tests/phpunit/tests/formatting/translateSmiley.php @@ -0,0 +1,72 @@ +assertSame( '', translate_smiley( array() ) ); + } + + /** + * Tests converting an image-based smiley into an img element. + * + * @ticket 65819 + */ + public function test_translate_smiley_converts_image_smiley() { + $actual = translate_smiley( array( ':mrgreen:' ) ); + + $this->assertStringStartsWith( 'assertStringContainsString( 'class="wp-smiley"', $actual ); + $this->assertStringContainsString( 'style="height: 1em; max-height: 1em;"', $actual ); + $this->assertStringContainsString( 'mrgreen.png', $actual ); + } + + /** + * Tests that smilies representing unicode emoji are returned as the emoji string. + * + * @ticket 65819 + */ + public function test_translate_smiley_returns_emoji_unmodified() { + $actual = translate_smiley( array( ':-)' ) ); + + $this->assertSame( "\xf0\x9f\x99\x82", $actual ); + } + + /** + * Tests that the smilies_src filter modifies the smiley image URL. + * + * @ticket 65819 + */ + public function test_translate_smiley_filter_smilies_src() { + add_filter( + 'smilies_src', + static function ( $src, $img ) { + return 'https://cdn.example.com/smilies/' . $img; + }, + 10, + 2 + ); + + $actual = translate_smiley( array( ':mrgreen:' ) ); + + $this->assertStringContainsString( 'src="https://cdn.example.com/smilies/mrgreen.png"', $actual ); + } +} From 0cbb0fc95aa1065adce20959ffe44d2a6238d9f2 Mon Sep 17 00:00:00 2001 From: Muhibul Haque Date: Sat, 7 Nov 2026 20:50:45 +0600 Subject: [PATCH 2/2] Tests: Cover translate_smiley(). See #66611. Props devmuhib009. --- tests/phpunit/tests/formatting/translateSmiley.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/tests/formatting/translateSmiley.php b/tests/phpunit/tests/formatting/translateSmiley.php index 7621a57c3a591..d53493d324132 100644 --- a/tests/phpunit/tests/formatting/translateSmiley.php +++ b/tests/phpunit/tests/formatting/translateSmiley.php @@ -18,7 +18,7 @@ public function set_up() { /** * Tests that empty matches return an empty string. * - * @ticket 65819 + * @ticket 66611 */ public function test_translate_smiley_empty_matches() { $this->assertSame( '', translate_smiley( array() ) ); @@ -27,7 +27,7 @@ public function test_translate_smiley_empty_matches() { /** * Tests converting an image-based smiley into an img element. * - * @ticket 65819 + * @ticket 66611 */ public function test_translate_smiley_converts_image_smiley() { $actual = translate_smiley( array( ':mrgreen:' ) ); @@ -42,7 +42,7 @@ public function test_translate_smiley_converts_image_smiley() { /** * Tests that smilies representing unicode emoji are returned as the emoji string. * - * @ticket 65819 + * @ticket 66611 */ public function test_translate_smiley_returns_emoji_unmodified() { $actual = translate_smiley( array( ':-)' ) ); @@ -53,7 +53,7 @@ public function test_translate_smiley_returns_emoji_unmodified() { /** * Tests that the smilies_src filter modifies the smiley image URL. * - * @ticket 65819 + * @ticket 66611 */ public function test_translate_smiley_filter_smilies_src() { add_filter(