Skip to content

Commit

Permalink
Test the filter impact to the new helper
Browse files Browse the repository at this point in the history
  • Loading branch information
kasparsd committed Feb 14, 2025
1 parent 5f7783d commit aa8cfda
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tests/class-two-factor-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -1558,13 +1558,16 @@ public function test_all_sessions_destroyed_when_enabling_2fa_by_admin() {

public function test_can_filter_registered_providers_for_user() {
$user = self::factory()->user->create_and_get();
$providers = Two_Factor_Core::get_providers();

$this->assertEquals(
Two_Factor_Core::get_providers(),
$providers,
Two_Factor_Core::get_supported_providers_for_user( $user ),
'All providers are available by default'
);

$this->assertTrue( $providers['Two_Factor_Email']::is_supported_for_user( $user ), 'Email provider is supported by default' );

add_filter(
'two_factor_providers_for_user',
function( $providers, $user ) {
Expand All @@ -1582,6 +1585,8 @@ function( $providers, $user ) {
'Email provider can be disabled for a user'
);

$this->assertFalse( $providers['Two_Factor_Email']::is_supported_for_user( $user ), 'Email provider is disabled if not supported' );

remove_all_filters( 'two_factor_providers_for_user' );
}

Expand Down

0 comments on commit aa8cfda

Please sign in to comment.