From 73bc928b64afd87de089644b74561b72a986723e Mon Sep 17 00:00:00 2001 From: Shail Mehta Date: Wed, 25 Nov 2026 16:11:27 +0530 Subject: [PATCH 1/4] Tests: Cover `wp_enqueue_code_editor()` when syntax highlighting is disabled --- .../phpunit/tests/general/wpEnqueueCodeEditor | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/phpunit/tests/general/wpEnqueueCodeEditor diff --git a/tests/phpunit/tests/general/wpEnqueueCodeEditor b/tests/phpunit/tests/general/wpEnqueueCodeEditor new file mode 100644 index 0000000000000..c7a6f9fb3176c --- /dev/null +++ b/tests/phpunit/tests/general/wpEnqueueCodeEditor @@ -0,0 +1,33 @@ +user->create(); + wp_set_current_user( $user_id ); + wp_get_current_user()->syntax_highlighting = 'false'; + + $this->assertFalse( + wp_enqueue_code_editor( + array( + 'type' => 'text/css', + ) + ) + ); + $this->assertFalse( wp_script_is( 'code-editor', 'enqueued' ) ); + $this->assertFalse( wp_style_is( 'code-editor', 'enqueued' ) ); + } +} From 1b6ea9fa2b2ca2a35fb45ebc2f87708427cf9687 Mon Sep 17 00:00:00 2001 From: Shail Mehta Date: Wed, 25 Nov 2026 16:22:04 +0530 Subject: [PATCH 2/4] Rename wpEnqueueCodeEditor to wpEnqueueCodeEditor.php --- .../general/{wpEnqueueCodeEditor => wpEnqueueCodeEditor.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/phpunit/tests/general/{wpEnqueueCodeEditor => wpEnqueueCodeEditor.php} (100%) diff --git a/tests/phpunit/tests/general/wpEnqueueCodeEditor b/tests/phpunit/tests/general/wpEnqueueCodeEditor.php similarity index 100% rename from tests/phpunit/tests/general/wpEnqueueCodeEditor rename to tests/phpunit/tests/general/wpEnqueueCodeEditor.php From 6d18e081f110d5dce31dc5b85ecd3187809ef115 Mon Sep 17 00:00:00 2001 From: Shail Mehta Date: Wed, 25 Nov 2026 16:28:53 +0530 Subject: [PATCH 3/4] Apply Feedback Changes Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../tests/general/wpEnqueueCodeEditor.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/phpunit/tests/general/wpEnqueueCodeEditor.php b/tests/phpunit/tests/general/wpEnqueueCodeEditor.php index c7a6f9fb3176c..ce570ec5c8b8f 100644 --- a/tests/phpunit/tests/general/wpEnqueueCodeEditor.php +++ b/tests/phpunit/tests/general/wpEnqueueCodeEditor.php @@ -10,6 +10,28 @@ */ class Tests_General_WpEnqueueCodeEditor extends WP_UnitTestCase { + protected ?WP_Scripts $old_wp_scripts = null; + + protected ?WP_Styles $old_wp_styles = null; + + public function set_up() { + parent::set_up(); + $old_wp_scripts = $GLOBALS['wp_scripts'] ?? null; + $old_wp_styles = $GLOBALS['wp_styles'] ?? null; + $this->old_wp_scripts = $old_wp_scripts instanceof WP_Scripts ? $old_wp_scripts : null; + $this->old_wp_styles = $old_wp_styles instanceof WP_Styles ? $old_wp_styles : null; + + $GLOBALS['wp_scripts'] = new WP_Scripts(); + $GLOBALS['wp_styles'] = new WP_Styles(); + } + + public function tear_down() { + $GLOBALS['wp_scripts'] = $this->old_wp_scripts; + $GLOBALS['wp_styles'] = $this->old_wp_styles; + parent::tear_down(); + } + + /** * Tests that a logged-in user with syntax highlighting disabled gets false. * From 4f6ffbe6589cca93c7af8b73f9073e0444f58b4d Mon Sep 17 00:00:00 2001 From: Shail Mehta Date: Thu, 26 Nov 2026 09:51:35 +0530 Subject: [PATCH 4/4] Refactor wpEnqueueCodeEditor test setup --- .../tests/general/wpEnqueueCodeEditor.php | 26 +------------------ 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/tests/phpunit/tests/general/wpEnqueueCodeEditor.php b/tests/phpunit/tests/general/wpEnqueueCodeEditor.php index ce570ec5c8b8f..055fb7be16c8f 100644 --- a/tests/phpunit/tests/general/wpEnqueueCodeEditor.php +++ b/tests/phpunit/tests/general/wpEnqueueCodeEditor.php @@ -10,32 +10,10 @@ */ class Tests_General_WpEnqueueCodeEditor extends WP_UnitTestCase { - protected ?WP_Scripts $old_wp_scripts = null; - - protected ?WP_Styles $old_wp_styles = null; - - public function set_up() { - parent::set_up(); - $old_wp_scripts = $GLOBALS['wp_scripts'] ?? null; - $old_wp_styles = $GLOBALS['wp_styles'] ?? null; - $this->old_wp_scripts = $old_wp_scripts instanceof WP_Scripts ? $old_wp_scripts : null; - $this->old_wp_styles = $old_wp_styles instanceof WP_Styles ? $old_wp_styles : null; - - $GLOBALS['wp_scripts'] = new WP_Scripts(); - $GLOBALS['wp_styles'] = new WP_Styles(); - } - - public function tear_down() { - $GLOBALS['wp_scripts'] = $this->old_wp_scripts; - $GLOBALS['wp_styles'] = $this->old_wp_styles; - parent::tear_down(); - } - - /** * Tests that a logged-in user with syntax highlighting disabled gets false. * - * @ticket 66757 + * @ticket 66828 */ public function test_wp_enqueue_code_editor_returns_false_when_syntax_highlighting_disabled() { $user_id = self::factory()->user->create(); @@ -49,7 +27,5 @@ public function test_wp_enqueue_code_editor_returns_false_when_syntax_highlighti ) ) ); - $this->assertFalse( wp_script_is( 'code-editor', 'enqueued' ) ); - $this->assertFalse( wp_style_is( 'code-editor', 'enqueued' ) ); } }