Improve test coverage

This commit is contained in:
Matej Bačo
2026-04-20 16:11:22 +02:00
parent 848f09956e
commit dfec2b3cb7
3 changed files with 154 additions and 6 deletions
@@ -123,10 +123,6 @@ class Create extends Action
$secure = $smtp['secure'] ?? '';
}
if (empty($senderName)) {
throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'SMTP sender name must be configured on the project to send a test email.');
}
if (empty($senderEmail)) {
throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'SMTP sender email must be configured on the project to send a test email.');
}
@@ -115,7 +115,7 @@ class Update extends Action
}
// Validate SMTP credentials
if ($smtp['enabled'] === true) {
if (\is_null($smtp['enabled'] ?? null) || $smtp['enabled'] === true) {
$mail = new PHPMailer(true);
$mail->isSMTP();
@@ -150,7 +150,9 @@ class Update extends Action
$smtp['enabled'] = true;
}
} catch (Throwable $error) {
throw new Exception(Exception::PROJECT_SMTP_CONFIG_INVALID, $error->getMessage());
if (($smtp['enabled'] ?? null) === true) {
throw new Exception(Exception::PROJECT_SMTP_CONFIG_INVALID, $error->getMessage());
}
}
}