From ce999afbb362f8a527ab5f6723af9cf8c25d2789 Mon Sep 17 00:00:00 2001 From: Jeppe B <2jepp9350@gmail.com> Date: Wed, 10 Jun 2026 18:22:53 +0200 Subject: [PATCH] Fix MinIO local test storage fallback --- .../Storage/MinioLocalTestStorageTest.php | 38 +++++++++++++++++++ services/nginx/app/traits/minio_t.php | 6 +-- 2 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 services/nginx/app/tests/Unit/Storage/MinioLocalTestStorageTest.php diff --git a/services/nginx/app/tests/Unit/Storage/MinioLocalTestStorageTest.php b/services/nginx/app/tests/Unit/Storage/MinioLocalTestStorageTest.php new file mode 100644 index 00000000..93d7d4a9 --- /dev/null +++ b/services/nginx/app/tests/Unit/Storage/MinioLocalTestStorageTest.php @@ -0,0 +1,38 @@ + null, + 'access_key' => null, + 'secret_key' => null, + ]; + + try { + $file = 'minio-local-test-' . bin2hex(random_bytes(4)) . '.pdf'; + $store = new pdf_store(); + + expect($store->createObject($file, 'local-pdf-content'))->toBeTrue(); + + $path = $store->download($file); + + expect(is_file($path))->toBeTrue() + ->and(file_get_contents($path))->toBe('local-pdf-content'); + } finally { + if (isset($path) && is_file($path)) { + unlink($path); + } + if ($previousRunApiTests === false) { + putenv('RUN_API_TESTS'); + } else { + putenv('RUN_API_TESTS=' . $previousRunApiTests); + } + $MINIO = $previousMinio; + } +}); diff --git a/services/nginx/app/traits/minio_t.php b/services/nginx/app/traits/minio_t.php index c9197c5d..57f461d1 100644 --- a/services/nginx/app/traits/minio_t.php +++ b/services/nginx/app/traits/minio_t.php @@ -76,7 +76,7 @@ trait minio_t public function getEndpoint(): string { global $MINIO; - return $MINIO['endpoint']; + return is_array($MINIO ?? null) ? (string)($MINIO['endpoint'] ?? '') : ''; } /** @@ -86,7 +86,7 @@ trait minio_t public function getAccessKey(): string { global $MINIO; - return $MINIO['access_key']; + return is_array($MINIO ?? null) ? (string)($MINIO['access_key'] ?? '') : ''; } /** @@ -96,7 +96,7 @@ trait minio_t public function getSecretKey(): string { global $MINIO; - return $MINIO['secret_key']; + return is_array($MINIO ?? null) ? (string)($MINIO['secret_key'] ?? '') : ''; } /**