$message['body'][]=t('Drupal core failed to update automatically from @previous_version to @target_version. The following error was logged:',[
'@previous_version'=>$params['previous_version'],
'@target_version'=>$params['target_version'],
],$options);
$message['body'][]=$params['error_message'];
break;
}
// If this email was related to an unattended update, explicitly state that
// this isn't supported yet.
if(str_starts_with($key,'cron_')){
$message['body'][]=t('This e-mail was sent by the Automatic Updates module. Unattended updates are not yet fully supported.',[],$options);
$message['body'][]=t('If you are using this feature in production, it is strongly recommended for you to visit your site and ensure that everything still looks good.',[],$options);
$this->assertCorrectMessageSent($email,$message,$message['langcode'],"Congratulations!\n\nDrupal core was automatically updated from 9.8.0 to 9.8.1.\n");
}
}
/**
* Data provider for ::testEmailOnFailure().
*
* @return string[][]
* The test cases.
*/
publicfunctionproviderEmailOnFailure():array{
return[
'pre-create'=>[
PreCreateEvent::class,
],
'pre-require'=>[
PreRequireEvent::class,
],
'pre-apply'=>[
PreApplyEvent::class,
],
];
}
$this->config('update.settings')
->set('notification.emails',$recipients)
->save();
/**
* Tests that email is sent when an unattended update fails.
*
* @param string $event_class
* The event class that should trigger the failure.
$this->assertCorrectMessageSent($email,$message,$message['langcode'],"Drupal core failed to update automatically from 9.8.0 to 9.8.1. The following\nerror was logged:\n\n".$exception->getMessage());
}
}
/**
* Asserts correct message sent to correct recipient.
*
* @param string $expected_recipient
* The email address that should have received the message.
* @param array $sent_message
* The sent message, as processed by hook_mail().
* @param string $expected_language_code
* The language code that the recipient should have been emailed in.
* @param string $expected_body_text
* The expected message that the email body should contain.