File tree Expand file tree Collapse file tree
tests/phpunit/tests/connectors Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88 */
99class Tests_Connectors_WpRegisterDefaultConnectorSettings extends WP_UnitTestCase {
1010
11- const CONNECTOR_ID = 'wp_test_non_ai_connector ' ;
12- const SETTING_NAME = 'connectors_test_non_ai_api_key ' ;
11+ const CONNECTOR_ID = 'wp_test_non_ai_connector ' ;
12+ const SETTING_NAME = 'connectors_test_non_ai_api_key ' ;
1313
1414 /**
15- * Removes the test connector and setting after each test.
15+ * Snapshot of registered settings before each test.
16+ *
17+ * @var array
18+ */
19+ private array $ original_registered_settings = array ();
20+
21+ /**
22+ * Snapshots the registered settings before each test.
23+ */
24+ public function set_up (): void {
25+ parent ::set_up ();
26+
27+ global $ wp_registered_settings ;
28+ $ this ->original_registered_settings = $ wp_registered_settings ;
29+ }
30+
31+ /**
32+ * Removes the test connector and restores registered settings.
1633 */
1734 public function tear_down (): void {
1835 $ registry = WP_Connector_Registry::get_instance ();
1936 if ( null !== $ registry && $ registry ->is_registered ( self ::CONNECTOR_ID ) ) {
2037 $ registry ->unregister ( self ::CONNECTOR_ID );
2138 }
2239
23- unregister_setting ( 'connectors ' , self ::SETTING_NAME );
40+ global $ wp_registered_settings ;
41+ $ wp_registered_settings = $ this ->original_registered_settings ;
2442
2543 parent ::tear_down ();
2644 }
You can’t perform that action at this time.
0 commit comments