diff --git a/tests/WP_Ultimo/SSO/SSO_Coverage_Test.php b/tests/WP_Ultimo/SSO/SSO_Coverage_Test.php index 9cf8821d..e13293e9 100644 --- a/tests/WP_Ultimo/SSO/SSO_Coverage_Test.php +++ b/tests/WP_Ultimo/SSO/SSO_Coverage_Test.php @@ -33,6 +33,16 @@ protected function setUp(): void { add_filter('wu_sso_enabled', '__return_true'); + /* + * This test class removes temporary redirect-host filters after each test. + * Re-register the production mapping callback because its singleton can + * already exist when a subsequent test starts. + */ + if (class_exists('\WP_Ultimo\Domain_Mapping')) { + $domain_mapping = \WP_Ultimo\Domain_Mapping::get_instance(); + add_filter('allowed_redirect_hosts', [$domain_mapping, 'allow_network_redirect_hosts'], 20, 2); + } + add_filter( 'wu_sso_salt', function () { @@ -2239,7 +2249,7 @@ public function test_startup_loads_domain_mapping_redirect_host_filter(): void { wp_cache_delete('domain:www.' . $domain_name, 'domain_mappings'); try { - $sso->startup(); + $sso->init(); $result = apply_filters('allowed_redirect_hosts', ['mygratis.site'], strtoupper($domain_name)); diff --git a/tests/WP_Ultimo/SSO/SSO_Extended_Test.php b/tests/WP_Ultimo/SSO/SSO_Extended_Test.php index 84970add..9ac28ec8 100644 --- a/tests/WP_Ultimo/SSO/SSO_Extended_Test.php +++ b/tests/WP_Ultimo/SSO/SSO_Extended_Test.php @@ -1644,12 +1644,20 @@ public function test_is_enabled_source_uses_apply_filters_deprecated_for_mercato * Test get_setting returns true for enable_sso when set. */ public function test_get_setting_returns_true_for_enable_sso(): void { - $sso = SSO::get_instance(); - $result = $sso->get_setting('enable_sso', true); + $previous_enable_sso = wu_get_setting('enable_sso', false); + + wu_save_setting('enable_sso', true); - // WordPress stores checkbox-like settings as scalars such as '1'; - // SSO treats enable_sso via normal option truthiness. - $this->assertTrue(wu_string_to_bool($result)); + try { + $sso = SSO::get_instance(); + $result = $sso->get_setting('enable_sso'); + + // WordPress stores checkbox-like settings as scalars such as '1'; + // SSO treats enable_sso via normal option truthiness. + $this->assertTrue(wu_string_to_bool($result)); + } finally { + wu_save_setting('enable_sso', $previous_enable_sso); + } } // ------------------------------------------------------------------