toBeTrue(); }); it('returns false when disk does not exist in storage', function (): void { // GIVEN $disk = 'unknown_disk_xyz'; // WHEN $exists = Utils::diskExists($disk); // THEN expect($exists)->toBeFalse(); }); it('handles BackedEnum instances', function (): void { // GIVEN / WHEN $existsLocal = Utils::diskExists(TestUtilsBackedEnum::Local); $existsUnknown = Utils::diskExists(TestUtilsBackedEnum::Unknown); // THEN expect($existsLocal)->toBeTrue() ->and($existsUnknown)->toBeFalse(); }); it('handles UnitEnum instances', function (): void { // GIVEN / WHEN $existsLocal = Utils::diskExists(TestUtilsUnitEnum::local); $existsUnknown = Utils::diskExists(TestUtilsUnitEnum::unknown_disk); // THEN expect($existsLocal)->toBeTrue() ->and($existsUnknown)->toBeFalse(); }); }); describe('Utils isExtensionAllowed', function (): void { it('delegates to resolved StorageServiceConfig', function (): void { // GIVEN $config = new StorageServiceConfig( defaultDisk: 'local', eligibleDisks: ['local'], laravelExistingDisks: [(object) ['disk' => 'local', 'driver' => 'local']], allowedExtensions: ['pdf', 'txt'] ); app()->instance(StorageServiceConfig::class, $config); // WHEN $pdfAllowed = Utils::isExtensionAllowed('pdf'); $exeAllowed = Utils::isExtensionAllowed('exe'); // THEN expect($pdfAllowed)->toBeTrue() ->and($exeAllowed)->toBeFalse(); }); it('returns true as safe fallback when StorageServiceConfig resolution fails', function (): void { // GIVEN app()->forgetInstance(StorageServiceConfig::class); app()->bind(StorageServiceConfig::class, function () { throw new \RuntimeException('Config not bound'); }); // WHEN $fallback = Utils::isExtensionAllowed('any_ext'); // THEN expect($fallback)->toBeTrue(); }); });