Skip to content

Commit

Permalink
Test the new provider resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
kasparsd committed Feb 14, 2025
1 parent 5422ba1 commit 5f7783d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/class-two-factor-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -1586,7 +1586,13 @@ function( $providers, $user ) {
}

public function test_can_disable_default_providers() {
$this->assertContains( 'Two_Factor_Email', array_keys( Two_Factor_Core::get_providers() ), 'Email provider is enabled by default' );
$user = self::factory()->user->create_and_get();
$providers = Two_Factor_Core::get_providers();
$default_provider = current( $providers );

$this->assertContains( 'Two_Factor_Email', array_keys( $providers ), 'Email provider is enabled by default' );

$this->assertTrue( $default_provider::is_supported_for_user( $user ), 'Available provider is supported by default' );

add_filter(
'two_factor_providers',
Expand All @@ -1597,6 +1603,8 @@ function ( $providers ) {

$this->assertNotContains( 'Two_Factor_Email', array_keys( Two_Factor_Core::get_providers() ), 'Default provider can be disabled via a filter' );

$this->assertFalse( $default_provider::is_supported_for_user( $user ), 'Disabled provider is not supported for user' );

remove_all_filters( 'two_factor_providers' );
}

Expand Down

0 comments on commit 5f7783d

Please sign in to comment.