Skip to content

Commit

Permalink
Test the uninstall
Browse files Browse the repository at this point in the history
  • Loading branch information
kasparsd committed Sep 18, 2024
1 parent f4d463d commit 72ee3e0
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/class-two-factor-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -1555,4 +1555,30 @@ public function test_all_sessions_destroyed_when_enabling_2fa_by_admin() {
// Validate that the Admin still has a session.
$this->assertCount( 1, $admin_session_manager->get_all(), 'No admin sessions are present first' );
}

/**
* Plugin uninstall removes all user meta.
*
* @covers Two_Factor_Core::uninstall
*/
public function test_uninstall_removes_user_meta() {
$user = self::factory()->user->create_and_get();

// Enable a provider for the user.
Two_Factor_Core::enable_provider_for_user( $user->ID, 'Two_Factor_Totp' );

$this->assertContains(
'Two_Factor_Totp',
Two_Factor_Core::get_enabled_providers_for_user( $user->ID ),
'Sample provider was enabled'
);

Two_Factor_Core::uninstall();

$this->assertNotContains(
'Two_Factor_Totp',
Two_Factor_Core::get_enabled_providers_for_user( $user->ID ),
'Provider was disabled due to uninstall'
);
}
}

0 comments on commit 72ee3e0

Please sign in to comment.