File tree 1 file changed +32
-0
lines changed
1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -1556,6 +1556,38 @@ public function test_all_sessions_destroyed_when_enabling_2fa_by_admin() {
1556
1556
$ this ->assertCount ( 1 , $ admin_session_manager ->get_all (), 'No admin sessions are present first ' );
1557
1557
}
1558
1558
1559
+ public function test_can_filter_registered_providers_for_user () {
1560
+ $ user = self ::factory ()->user ->create_and_get ();
1561
+
1562
+ $ this ->assertEquals (
1563
+ Two_Factor_Core::get_providers (),
1564
+ Two_Factor_Core::get_supported_providers_for_user ( $ user ),
1565
+ 'All providers are available by default '
1566
+ );
1567
+
1568
+ add_filter (
1569
+ 'two_factor_providers_for_user ' ,
1570
+ function ( $ providers , $ user ) {
1571
+ $ this ->assertInstanceOf ( WP_User::class, $ user );
1572
+
1573
+ return array_diff_key ( $ providers , array ( 'Two_Factor_Email ' => null ) );
1574
+ },
1575
+ 10 ,
1576
+ 2
1577
+ );
1578
+
1579
+ $ providers = Two_Factor_Core::get_providers ();
1580
+ unset( $ providers ['Two_Factor_Email ' ] );
1581
+
1582
+ $ this ->assertEquals (
1583
+ $ providers ,
1584
+ Two_Factor_Core::get_supported_providers_for_user ( $ user ),
1585
+ 'Email provider can be disabled for a user '
1586
+ );
1587
+
1588
+ remove_all_filters ( 'two_factor_providers_for_user ' );
1589
+ }
1590
+
1559
1591
/**
1560
1592
* Plugin uninstall removes all user meta.
1561
1593
*
You can’t perform that action at this time.
0 commit comments