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
@@ -12,7 +12,8 @@ class ReimbursementFileService
{
public function __construct(
private ApplicationUrlService $urls
) {}
) {
}
public function receiptUrl(?string $filename): ?string
{
@@ -31,7 +32,7 @@ class ReimbursementFileService
public function storeReceipt(?UploadedFile $file): ?string
{
if (! $file || ! $file->isValid()) {
if (!$file || !$file->isValid()) {
return null;
}
@@ -41,10 +42,10 @@ class ReimbursementFileService
$dir = $this->ensureUploadDir();
$extension = $file->getClientOriginalExtension();
$extension = $extension !== '' ? '.'.strtolower($extension) : '';
$filename = 'reimb_'.date('Ymd_His').'_'.Str::random(8).$extension;
$extension = $extension !== '' ? '.' . strtolower($extension) : '';
$filename = 'reimb_' . date('Ymd_His') . '_' . Str::random(8) . $extension;
if (! $file->move($dir, $filename)) {
if (!$file->move($dir, $filename)) {
throw new RuntimeException('Unable to save uploaded file.');
}
@@ -55,10 +56,10 @@ class ReimbursementFileService
{
$dir = $this->ensureUploadDir();
$extension = $file->getClientOriginalExtension();
$extension = $extension !== '' ? '.'.strtolower($extension) : '';
$filename = 'batch_check_'.date('Ymd_His').'_'.Str::random(8).$extension;
$extension = $extension !== '' ? '.' . strtolower($extension) : '';
$filename = 'batch_check_' . date('Ymd_His') . '_' . Str::random(8) . $extension;
if (! $file->move($dir, $filename)) {
if (!$file->move($dir, $filename)) {
throw new RuntimeException('Unable to save uploaded file.');
}
@@ -67,8 +68,8 @@ class ReimbursementFileService
->where('admin_id', $adminId)
->first();
if ($existing && ! empty($existing->filename)) {
$oldPath = $dir.DIRECTORY_SEPARATOR.$existing->filename;
if ($existing && !empty($existing->filename)) {
$oldPath = $dir . DIRECTORY_SEPARATOR . $existing->filename;
if (is_file($oldPath)) {
@unlink($oldPath);
}
@@ -101,13 +102,13 @@ class ReimbursementFileService
{
$dir = storage_path('uploads/reimbursements');
if (! is_dir($dir)) {
if (! @mkdir($dir, 0755, true) && ! is_dir($dir)) {
if (!is_dir($dir)) {
if (!@mkdir($dir, 0755, true) && !is_dir($dir)) {
throw new RuntimeException('Upload directory is not available.');
}
}
if (! is_writable($dir)) {
if (!is_writable($dir)) {
throw new RuntimeException('Upload directory is not writable.');
}