Skip to content

Commit 66bfcbf

Browse files
Tests: Improve admin email notification verification in user creation test
1 parent c91dcb6 commit 66bfcbf

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

tests/phpunit/tests/rest-api/rest-users-controller.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff 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
/**

0 commit comments

Comments
 (0)