Skip to content

Commit 326e8d3

Browse files
committed
Enable HTTPS environment for profile sign-in tests.
This change ensures that the HTTPS environment is set up correctly for the profile sign-in tests, allowing the `Tag_Guard::can_activate()` method to function as intended. This prevents short-circuiting and ensures accurate test results.
1 parent 9a69bc2 commit 326e8d3

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

tests/phpunit/integration/Modules/Sign_In_With_GoogleTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,10 @@ public function test_render_profile_admin_notices__skips_outside_profile_pages()
481481
}
482482

483483
public function test_maybe_render_profile_signinwithgoogle__renders_when_profile_eligible() {
484+
// `Tag_Guard::can_activate()` rejects `wp_login_url()` when it's not
485+
// HTTPS, so `build_registrable_tag()` would return null otherwise and
486+
// the callback would short-circuit before rendering anything.
487+
$this->enable_https_login_env();
484488
$this->register_and_connect_module();
485489

486490
$user_id = $this->factory()->user->create( array( 'role' => 'editor' ) );
@@ -502,6 +506,10 @@ public function test_maybe_render_profile_signinwithgoogle__skips_when_show_user
502506
global $wp_actions;
503507
unset( $wp_actions['show_user_profile'] );
504508

509+
// HTTPS setup so `Tag_Guard::can_activate()` doesn't short-circuit
510+
// first - the `did_action` gate must be the only thing keeping the
511+
// connect script out (anti-vacuous).
512+
$this->enable_https_login_env();
505513
$this->register_and_connect_module();
506514

507515
$user_id = $this->factory()->user->create( array( 'role' => 'editor' ) );
@@ -513,6 +521,10 @@ public function test_maybe_render_profile_signinwithgoogle__skips_when_show_user
513521
}
514522

515523
public function test_maybe_render_profile_signinwithgoogle__skips_when_user_already_linked() {
524+
// HTTPS setup so `Tag_Guard::can_activate()` doesn't short-circuit
525+
// first - the `Hashed_User_ID` gate must be the only thing keeping
526+
// the connect script out (anti-vacuous).
527+
$this->enable_https_login_env();
516528
$this->register_and_connect_module();
517529

518530
$user_id = $this->factory()->user->create( array( 'role' => 'editor' ) );
@@ -527,6 +539,10 @@ public function test_maybe_render_profile_signinwithgoogle__skips_when_user_alre
527539
}
528540

529541
public function test_maybe_render_profile_signinwithgoogle__skips_when_module_not_connected() {
542+
// HTTPS setup so the `wp_login_url()` half of `Tag_Guard::can_activate()`
543+
// passes - the only thing keeping the connect script out should be
544+
// the missing `clientID` (anti-vacuous).
545+
$this->enable_https_login_env();
530546
$this->module->register();
531547
// Intentionally skip setting `clientID` so `build_registrable_tag()`
532548
// returns null and the connect script never gets a chance to render.

0 commit comments

Comments
 (0)