Skip to content

Commit 20ca4e7

Browse files
gzioloclaude
andcommitted
Tests: Unhook connector registration to prevent duplicate settings on re-init.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent c6dd336 commit 20ca4e7

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

tests/phpunit/includes/functions.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,18 @@ function _unhook_font_registration() {
375375
}
376376
tests_add_filter( 'init', '_unhook_font_registration', 1000 );
377377

378+
/**
379+
* After the init action has been run once, trying to re-register connector settings can cause
380+
* duplicate registrations. To avoid this, unhook the connector registration functions.
381+
*
382+
* @since 7.0.0
383+
*/
384+
function _unhook_connector_registration() {
385+
remove_action( 'init', '_wp_register_default_connector_settings', 20 );
386+
remove_action( 'init', '_wp_connectors_pass_default_keys_to_ai_client', 20 );
387+
}
388+
tests_add_filter( 'init', '_unhook_connector_registration', 1000 );
389+
378390
/**
379391
* Before the abilities API categories init action runs, unhook the core ability
380392
* categories registration function to prevent core categories from being registered

0 commit comments

Comments
 (0)