From 10adf73189ea6062a6004b278b35bd4bb9ece6db Mon Sep 17 00:00:00 2001 From: Kamran Abdul Aziz Date: Sat, 21 Nov 2026 19:41:32 +0530 Subject: [PATCH] Tests: Register the default script modules in the core entity actions test. See #66755. --- .../registerCoreEntityActions.php | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/tests/entity-actions/registerCoreEntityActions.php b/tests/phpunit/tests/entity-actions/registerCoreEntityActions.php index b52fe5eab5abf..664e6ea73af2f 100644 --- a/tests/phpunit/tests/entity-actions/registerCoreEntityActions.php +++ b/tests/phpunit/tests/entity-actions/registerCoreEntityActions.php @@ -483,12 +483,31 @@ public function test_the_rest_route_serves_the_core_actions() { * @ticket 66343 */ public function test_the_script_modules_of_the_core_actions_are_registered() { + global $wp_script_modules, $wp_interactivity; + wp_set_current_user( self::$admin_id ); - foreach ( wp_get_all_registered_entity_action_modules()['postType'] as $post_type => $modules ) { - foreach ( $modules as $module ) { - $this->assertNotNull( wp_script_modules()->get_registered( $module ), "The $module module of $post_type is registered." ); + /* + * Register the default script modules in fresh instances, so the test neither + * depends on nor changes the shared ones. Registering them also marks the + * block library modules in the Interactivity API. + */ + $original_script_modules = $wp_script_modules; + $original_interactivity = $wp_interactivity; + $wp_script_modules = null; + $wp_interactivity = null; + + try { + wp_default_script_modules(); + + foreach ( wp_get_all_registered_entity_action_modules()['postType'] as $post_type => $modules ) { + foreach ( $modules as $module ) { + $this->assertNotNull( wp_script_modules()->get_registered( $module ), "The $module module of $post_type is registered." ); + } } + } finally { + $wp_script_modules = $original_script_modules; + $wp_interactivity = $original_interactivity; } }