File tree Expand file tree Collapse file tree
tests/phpunit/tests/rest-api Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1397,7 +1397,20 @@ public function test_create_user_sends_admin_notification() {
13971397
13981398 $ mailer = tests_retrieve_phpmailer_instance ();
13991399 $ this ->assertNotEmpty ( $ mailer ->mock_sent , 'No emails were sent ' );
1400- $ this ->assertSame ( get_option ( 'admin_email ' ), $ mailer ->mock_sent [0 ]['to ' ][0 ][0 ] );
1400+
1401+ // Check that at least one email was sent to the admin.
1402+ $ admin_email = get_option ( 'admin_email ' );
1403+ $ recipients = array_column ( $ mailer ->mock_sent , 'to ' );
1404+ $ admin_notified = false ;
1405+
1406+ foreach ( $ recipients as $ recipient_list ) {
1407+ if ( isset ( $ recipient_list [0 ][0 ] ) && $ recipient_list [0 ][0 ] === $ admin_email ) {
1408+ $ admin_notified = true ;
1409+ break ;
1410+ }
1411+ }
1412+
1413+ $ this ->assertTrue ( $ admin_notified , 'Admin email notification was not sent ' );
14011414 }
14021415
14031416 /**
You can’t perform that action at this time.
0 commit comments