@@ -63,7 +63,7 @@ public function setUp(): void {
6363
6464 // Set skipped users option
6565 update_option ( Highlight_MFA_Users::MFA_SKIP_USER_IDS_OPTION_KEY , [ $ this ->admin_user_mfa_skipped_id ] );
66-
66+ wp_set_current_user ( $ this -> admin_user_mfa_enabled_id );
6767 Highlight_MFA_Users::init ();
6868 }
6969
@@ -85,7 +85,7 @@ public function tearDown(): void {
8585 $ _GET = $ this ->original_get ;
8686 $ GLOBALS ['current_screen ' ] = $ this ->original_current_screen ;
8787 unset( $ GLOBALS ['current_screen ' ] ); // Ensure it's fully removed if it wasn't set before
88-
88+ wp_set_current_user ( 0 );
8989 parent ::tearDown ();
9090 }
9191
@@ -195,6 +195,22 @@ public function test_filter_users_by_mfa_status_does_nothing_on_wrong_page() {
195195 unset( $ _GET ['filter_mfa_disabled ' ] );
196196 }
197197
198+
199+ /**
200+ * Test that the admin notice is not displayed when we're an editor
201+ */
202+ public function test_display_mfa_disabled_notice_does_not_show_when_not_admin () {
203+ $ this ->set_admin_screen_users ();
204+ // Set a non-admin user
205+ wp_set_current_user ( $ this ->editor_user_id );
206+
207+ ob_start ();
208+ Highlight_MFA_Users::display_mfa_disabled_notice ();
209+ $ output = ob_get_clean ();
210+
211+ $ this ->assertEquals ( '' , $ output );
212+ }
213+
198214 /**
199215 * Test that the admin notice is displayed correctly when MFA-disabled admins exist.
200216 */
0 commit comments