Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion tests/WP_Ultimo/SSO/SSO_Coverage_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -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));

Expand Down
18 changes: 13 additions & 5 deletions tests/WP_Ultimo/SSO/SSO_Extended_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

// ------------------------------------------------------------------
Expand Down
Loading