Skip to content

Commit c250512

Browse files
committed
Update comments for clarity in Sign_In_With_Google tests.
Refine comments in the Sign_In_With_GoogleTest and Web_TagTest classes to enhance readability and understanding of the test logic. This improves maintainability and helps future developers grasp the purpose of the tests more easily.
1 parent 326e8d3 commit c250512

2 files changed

Lines changed: 15 additions & 21 deletions

File tree

tests/phpunit/integration/Modules/Sign_In_With_Google/Web_TagTest.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -237,18 +237,17 @@ public function test_render_tag__emits_connect_markers_only_when_flag_on() {
237237
$user_id = $this->factory()->user->create( array( 'role' => 'editor' ) );
238238
wp_set_current_user( $user_id );
239239

240-
// With the flag on, the rendered script tags the request as the
241-
// connect-existing-profile flow and includes the matching nonce.
240+
// With the flag on, the rendered script tags the request as the connect-existing-profile
241+
// flow and includes the matching nonce.
242242
$this->web_tag->set_is_connect_existing_profile( true );
243243
$output = $this->capture_render_tag_output();
244244
$this->assertStringContainsString( "response.integration='connect_existing_profile'", $output, 'Rendered script should set the connect_existing_profile integration when the flag is on.' );
245245
$this->assertStringContainsString( 'response.connect_nonce=', $output, 'Rendered script should include the connect nonce assignment when the flag is on.' );
246246
$this->assertStringContainsString( wp_create_nonce( Authenticator::CONNECT_NONCE_ACTION ), $output, 'Rendered nonce should match wp_create_nonce for CONNECT_NONCE_ACTION.' );
247247

248-
// Toggle the flag off on the same instance to guard against a vacuous
249-
// pass if the marker strings ever change. The positive phase above
250-
// fails first when that happens, signalling the negative assertions
251-
// below need updating too.
248+
// Toggling the flag off on the same instance guards against a vacuous pass if the marker
249+
// strings ever change. The positive phase above fails first when that happens, signalling
250+
// that the negative assertions below need updating too.
252251
$this->web_tag->set_is_connect_existing_profile( false );
253252
$output = $this->capture_render_tag_output();
254253
$this->assertStringNotContainsString( "response.integration='connect_existing_profile'", $output, 'Rendered script should not include the connect integration when the flag is off.' );
@@ -263,9 +262,8 @@ public function test_render_tag__forces_button_render_loop_on_connect_flow_even_
263262

264263
$output = $this->capture_render_tag_output();
265264

266-
// Logged-in users normally skip the button render loop; the connect
267-
// flow flips that gate so the placeholder div on the profile page
268-
// can still be wired up.
265+
// Logged-in users normally skip the button render loop. The connect flow flips that gate
266+
// so the placeholder div on the profile page can still be wired up.
269267
$this->assertStringContainsString( 'google.accounts.id.renderButton', $output, 'Connect flow should force the button render loop even when the user is logged in.' );
270268
$this->assertStringContainsString( 'googlesitekit-sign-in-with-google__frontend-output-button', $output, 'Render loop should target the SiwG placeholder class.' );
271269
}

tests/phpunit/integration/Modules/Sign_In_With_GoogleTest.php

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -506,9 +506,8 @@ public function test_maybe_render_profile_signinwithgoogle__skips_when_show_user
506506
global $wp_actions;
507507
unset( $wp_actions['show_user_profile'] );
508508

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).
509+
// HTTPS setup keeps `Tag_Guard::can_activate()` from short-circuiting first, so the
510+
// `did_action` gate is the only thing left to keep the connect script out (anti-vacuous).
512511
$this->enable_https_login_env();
513512
$this->register_and_connect_module();
514513

@@ -521,9 +520,8 @@ public function test_maybe_render_profile_signinwithgoogle__skips_when_show_user
521520
}
522521

523522
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).
523+
// HTTPS setup keeps `Tag_Guard::can_activate()` from short-circuiting first, so the
524+
// `Hashed_User_ID` gate is the only thing left to keep the connect script out (anti-vacuous).
527525
$this->enable_https_login_env();
528526
$this->register_and_connect_module();
529527

@@ -539,9 +537,8 @@ public function test_maybe_render_profile_signinwithgoogle__skips_when_user_alre
539537
}
540538

541539
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).
540+
// HTTPS setup keeps the `wp_login_url()` half of `Tag_Guard::can_activate()` passing, so
541+
// the missing `clientID` is the only thing left to keep the connect script out (anti-vacuous).
545542
$this->enable_https_login_env();
546543
$this->module->register();
547544
// Intentionally skip setting `clientID` so `build_registrable_tag()`
@@ -579,9 +576,8 @@ public function test_resolve_authenticator_class__returns_profile_authenticator_
579576
public function test_resolve_authenticator_class__falls_back_to_base_for_connect_when_logged_out() {
580577
wp_set_current_user( 0 );
581578

582-
// AC4: a `connect_existing_profile` request without an authenticated
583-
// session must fall back to the base `Authenticator` so `wp-login.php`
584-
// behaves like a fresh sign-in.
579+
// A `connect_existing_profile` request without an authenticated session must fall back
580+
// to the base `Authenticator` so `wp-login.php` behaves like a fresh sign-in (AC4).
585581
$this->assertSame(
586582
Authenticator::class,
587583
$this->call_resolve_authenticator_class( 'connect_existing_profile' ),

0 commit comments

Comments
 (0)