add tests batch 20

This commit is contained in:
root
2026-06-09 01:03:53 -04:00
parent 95efb9652e
commit 6be4875c5e
1502 changed files with 13797 additions and 11313 deletions
@@ -11,7 +11,6 @@ class BroadcastEmailComposerService
$html = preg_replace('#<(script|iframe)[^>]*>.*?</\\1>#is', '', $html);
$html = preg_replace('/\\son\\w+="[^"]*"/i', '', $html);
$html = preg_replace("/\\son\\w+='[^']*'/i", '', $html);
return $html ?? '';
}
@@ -27,7 +26,7 @@ class BroadcastEmailComposerService
): string {
$content = $personalize ? str_replace('{{name}}', $recipientName, $body) : $body;
if (! $wrapLayout) {
if (!$wrapLayout) {
return $content;
}
@@ -7,7 +7,6 @@ use App\Services\EmailService;
class BroadcastEmailDispatchService
{
private EmailService $mailer;
private BroadcastEmailComposerService $composer;
public function __construct(EmailService $mailer, BroadcastEmailComposerService $composer)
@@ -31,7 +30,7 @@ class BroadcastEmailDispatchService
$ok = $this->mailer->send(
$payload['test_email'],
'[TEST] '.$payload['subject'],
'[TEST] ' . $payload['subject'],
$html,
$payload['from_key']
);
@@ -26,7 +26,7 @@ class BroadcastEmailImageService
}
$mime = strtolower((string) $file->getMimeType());
if (! isset($this->allowedTypes[$mime])) {
if (!isset($this->allowedTypes[$mime])) {
return [
'ok' => false,
'status' => 415,
@@ -43,17 +43,17 @@ class BroadcastEmailImageService
}
$targetDir = public_path('uploads/email');
if (! is_dir($targetDir)) {
if (!is_dir($targetDir)) {
@mkdir($targetDir, 0755, true);
}
$ext = $this->allowedTypes[$mime];
$newName = 'em_'.bin2hex(random_bytes(16)).'.'.$ext;
$newName = 'em_' . bin2hex(random_bytes(16)) . '.' . $ext;
$file->move($targetDir, $newName);
return [
'ok' => true,
'url' => asset('uploads/email/'.$newName),
'url' => asset('uploads/email/' . $newName),
];
}
}
@@ -13,7 +13,6 @@ class BroadcastEmailRecipientService
return array_values(array_filter($parents, static function ($parent) {
$email = $parent['email'] ?? '';
return is_string($email) && trim($email) !== '';
}));
}
@@ -9,13 +9,12 @@ class BroadcastEmailSenderOptionsService
$json = getenv('MAIL_SENDERS') ?: env('MAIL_SENDERS', '{}');
$arr = json_decode($json, true);
if (! is_array($arr) || empty($arr)) {
if (!is_array($arr) || empty($arr)) {
$smtpUser = getenv('SMTP_USER') ?: '';
$name = 'Al Rahma Sunday School';
return [[
'key' => 'general',
'label' => $name.($smtpUser ? " <{$smtpUser}>" : ''),
'label' => $name . ($smtpUser ? " <{$smtpUser}>" : ''),
]];
}
@@ -25,7 +24,7 @@ class BroadcastEmailSenderOptionsService
$email = $info['email'] ?? '';
$out[] = [
'key' => (string) $key,
'label' => trim($name.($email ? " <{$email}>" : '')),
'label' => trim($name . ($email ? " <{$email}>" : '')),
];
}