fix(core): 레이아웃 첨부 URL 이 항상 프록시로 발급되던 결함 수정
공개 자산 스토리지를 설정해도 레이아웃 배경 이미지가 매번 오리진 PHP 를 거쳐 서빙되던 결함을 고친다 (https://github.com/gnuboard/g7/issues/134). 판정 기준은 운영자가 명시 선언한 core.storage.public_asset_disk 와 행 disk 의 일치다 — 디스크의 url 설정 유무로 판정하면 비공개 버킷에 공개 URL 이 설정된 구성에서 발급된 주소가 403 이 되어 그 이미지가 전부 깨진다. 전수조사에서 함께 처리한 것: 게시판 첨부 응답 url 칸(항상 null → 게이트가 살아 있는 서빙 URL), 페이지의 미배선 메서드 삭제, 확장 카테고리별 저장소 URL·경로 조회 교정, 그리고 이번 변경이 새로 만드는 고아 disk 위험 방어 (무인증 공개 서빙 라우트가 500 이 되는 것을 404 로 degrade). 문서화 하네스도 함께 보강한다. 실측을 수행하고도 이력 문서에는 판정만 남기면 대화 로그가 사라진 뒤 아무에게도 도달하지 않는데, 그 강제가 보고 형식에만 있었다.
This commit is contained in:
1 parent
e160a86f0d
commit
5c2e42c133
42 files changed
+1427
-83
No files matched your search
@@ -83,6 +83,11 @@ class StorageCategoryDiskTest extends TestCase
|
||||
{
|
||||
return ['ko' => '테스트', 'en' => 'Test'];
|
||||
}
|
||||
|
||||
public function exposedResolvePublicAssetDisk(?string $override = null): ?string
|
||||
{
|
||||
return $this->resolvePublicAssetDisk($override);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -209,4 +214,83 @@ class StorageCategoryDiskTest extends TestCase
|
||||
$this->assertNull($module->exposedResolvePublicAssetDisk());
|
||||
$this->assertNull($module->exposedResolvePublicAssetDisk('vanished_plugin_disk'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 플러그인 사본도 모듈과 동일한 해석 규칙을 따라야 합니다.
|
||||
*
|
||||
* 위임 이관(공개 #134) 전까지 플러그인 사본은 직접 테스트가 0건이라 오타가 나도
|
||||
* 아무도 잡지 못하는 자리였다. 모듈과 같은 4축을 플러그인 더블에도 돌린다.
|
||||
*
|
||||
* @effects none_override_forces_streaming_over_global, orphan_disk_falls_back_to_streaming
|
||||
*/
|
||||
#[Test]
|
||||
public function plugin_resolve_public_asset_disk_matches_module_rules(): void
|
||||
{
|
||||
$plugin = $this->makePlugin();
|
||||
|
||||
// 미설정 → 스트리밍
|
||||
$this->assertNull($plugin->exposedResolvePublicAssetDisk());
|
||||
|
||||
// 전역 설정 → 그 값
|
||||
Config::set('core.storage.public_asset_disk', 'fake_cdn');
|
||||
$this->assertSame('fake_cdn', $plugin->exposedResolvePublicAssetDisk());
|
||||
$this->assertSame('fake_cdn', $plugin->exposedResolvePublicAssetDisk(''));
|
||||
|
||||
// override 우선
|
||||
$this->assertSame('public', $plugin->exposedResolvePublicAssetDisk('public'));
|
||||
|
||||
// 'none' override → 스트리밍 강제
|
||||
$this->assertNull($plugin->exposedResolvePublicAssetDisk('none'));
|
||||
|
||||
// 고아 디스크 → 스트리밍 폴백
|
||||
Config::set('core.storage.public_asset_disk', 'vanished_plugin_disk');
|
||||
$this->assertNull($plugin->exposedResolvePublicAssetDisk());
|
||||
}
|
||||
|
||||
/**
|
||||
* getStorageUrl()/getStorageBasePath() 가 카테고리에 배선된 디스크를 따라야 합니다.
|
||||
*
|
||||
* 기본 디스크를 보던 시절에는 images 를 공개 자산 디스크로 옮긴 확장이 이 API 로
|
||||
* 항상 null 을 받았다 (공개 #134 전수조사 F4·F7).
|
||||
*
|
||||
* @effects url_returned_for_public_and_url_configured_disk
|
||||
*/
|
||||
#[Test]
|
||||
public function storage_url_and_base_path_follow_category_disk(): void
|
||||
{
|
||||
$module = new class extends AbstractModule
|
||||
{
|
||||
public function getName(): array
|
||||
{
|
||||
return ['ko' => '테스트', 'en' => 'Test'];
|
||||
}
|
||||
|
||||
public function getVersion(): string
|
||||
{
|
||||
return '1.0.0';
|
||||
}
|
||||
|
||||
public function getDescription(): array
|
||||
{
|
||||
return ['ko' => '테스트', 'en' => 'Test'];
|
||||
}
|
||||
|
||||
public function getStorageDiskFor(string $category): string
|
||||
{
|
||||
return $category === 'images' ? 'fake_cdn' : $this->getStorageDisk();
|
||||
}
|
||||
};
|
||||
|
||||
// 배선된 카테고리 → fake_cdn 의 url 설정을 따라 직접 URL
|
||||
$url = $module->getStorageUrl('images', 'a/b.png');
|
||||
$this->assertNotNull($url);
|
||||
$this->assertStringStartsWith('https://cdn.test/assets', $url);
|
||||
|
||||
// 미배선 카테고리는 기본 디스크(직접 URL 불가) → null
|
||||
$this->assertNull($module->getStorageUrl('settings', 'a/b.json'));
|
||||
|
||||
// 기본 경로도 배선된 디스크 기준
|
||||
$this->assertStringContainsString('fake_cdn', $module->getStorageBasePath('images'));
|
||||
$this->assertStringNotContainsString('fake_cdn', $module->getStorageBasePath('settings'));
|
||||
}
|
||||
}
|
||||
@@ -121,4 +121,35 @@ class TemplateLayoutAttachmentServingTest extends TestCase
|
||||
|
||||
$this->assertNull($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 고아 disk 행은 withDisk 없이 주입 스토리지로 서빙돼야 합니다 (500 회귀 가드).
|
||||
*
|
||||
* 공개 자산 디스크가 플러그인 등록 디스크일 수 있으므로, 그 플러그인이 비활성화되면
|
||||
* 행의 disk 가 config 에서 사라진다. 미등록 disk 로 withDisk 를 만들면 이후
|
||||
* response() 가 InvalidArgumentException 을 던져 **무인증 공개 서빙 라우트가 500**
|
||||
* 이 된다. 파일 도달 불가는 404 로 끝나는 것이 정상 degradation 이다.
|
||||
*
|
||||
* @scenario public_asset_disk=ghost_disk,row_disk=attachments,filter_url_hook=absent
|
||||
*
|
||||
* @effects orphan_row_disk_serves_without_exception, proxy_url_otherwise
|
||||
*/
|
||||
public function test_orphan_row_disk_falls_back_to_injected_storage(): void
|
||||
{
|
||||
$template = new Template;
|
||||
$template->id = 7;
|
||||
$this->templateRepository->shouldReceive('findByIdentifier')
|
||||
->with('sirsoft-basic')->andReturn($template);
|
||||
|
||||
// 고아 disk 로는 withDisk 가 불려서는 안 된다
|
||||
$this->storage->shouldNotReceive('withDisk');
|
||||
$this->storage->shouldReceive('response')->once()->andReturnNull();
|
||||
|
||||
$result = $this->service->getServableResponse(
|
||||
'sirsoft-basic',
|
||||
$this->makeAttachment(7, 'vanished_plugin_disk')
|
||||
);
|
||||
|
||||
$this->assertNull($result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,258 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Services;
|
||||
|
||||
use App\Contracts\Extension\StorageInterface;
|
||||
use App\Contracts\Repositories\TemplateLayoutAttachmentRepositoryInterface;
|
||||
use App\Contracts\Repositories\TemplateRepositoryInterface;
|
||||
use App\Models\Template;
|
||||
use App\Models\TemplateLayoutAttachment;
|
||||
use App\Services\TemplateLayoutAttachmentService;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Mockery;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* 레이아웃 첨부 URL 발급 모드 테스트 (공개 #134)
|
||||
*
|
||||
* 직접 URL 은 운영자가 `core.storage.public_asset_disk` 로 "이 저장소는 공개다" 라고
|
||||
* 명시 선언하고 **행 disk 가 그 값과 일치할 때만** 발급된다. `filesystems.disks.{disk}.url`
|
||||
* 설정 유무는 "URL 을 만들 수 있는가" 일 뿐 "익명 읽기가 되는가" 가 아니므로 판정 근거가
|
||||
* 될 수 없다 (비공개 버킷 + s3_url 설정 조합에서 직접 URL 은 403).
|
||||
*/
|
||||
class TemplateLayoutAttachmentUrlResolutionTest extends TestCase
|
||||
{
|
||||
private TemplateLayoutAttachmentService $service;
|
||||
|
||||
private $storage;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->storage = Mockery::mock(StorageInterface::class);
|
||||
|
||||
$this->service = new TemplateLayoutAttachmentService(
|
||||
Mockery::mock(TemplateLayoutAttachmentRepositoryInterface::class),
|
||||
Mockery::mock(TemplateRepositoryInterface::class),
|
||||
$this->storage
|
||||
);
|
||||
}
|
||||
|
||||
/** 템플릿 관계가 로드된 첨부를 만듭니다 (DB 미저장). */
|
||||
private function makeAttachment(string $disk): TemplateLayoutAttachment
|
||||
{
|
||||
$template = new Template;
|
||||
$template->id = 7;
|
||||
$template->identifier = 'sirsoft-basic';
|
||||
|
||||
$attachment = new TemplateLayoutAttachment([
|
||||
'layout_name' => 'home',
|
||||
'disk' => $disk,
|
||||
'path' => 'sirsoft-basic/2026/09/08/bg.png',
|
||||
'original_name' => 'bg.png',
|
||||
'mime_type' => 'image/png',
|
||||
'size' => 178,
|
||||
]);
|
||||
$attachment->id = 1;
|
||||
$attachment->template_id = 7;
|
||||
$attachment->setRelation('template', $template);
|
||||
|
||||
return $attachment;
|
||||
}
|
||||
|
||||
/** 프록시(공개 서빙 라우트) URL 인지 단언합니다. */
|
||||
private function assertProxyUrl(string $url): void
|
||||
{
|
||||
$this->assertStringContainsString('/layout-attachments/1/file', $url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 공개 자산 디스크 미설정 — 기본 설치. 프록시 URL 이어야 합니다.
|
||||
*
|
||||
* @scenario public_asset_disk=unset,row_disk=attachments,filter_url_hook=absent
|
||||
*
|
||||
* @effects proxy_url_otherwise
|
||||
*/
|
||||
public function test_unset_public_asset_disk_returns_proxy_url(): void
|
||||
{
|
||||
Config::set('core.storage.public_asset_disk', '');
|
||||
$this->storage->shouldNotReceive('withDisk');
|
||||
|
||||
$this->assertProxyUrl($this->service->resolveUrl($this->makeAttachment('attachments')));
|
||||
}
|
||||
|
||||
/**
|
||||
* 공개 자산 디스크 미설정 + 행 disk 가 s3 + s3.url 설정 — 프록시여야 합니다.
|
||||
*
|
||||
* 이 케이스가 §1 의 함정이다. `url()` non-null 이면 우선한다는 규칙을 문자
|
||||
* 그대로 적용하면, 비공개 버킷 + `AWS_URL` 설정 환경에서 발급된 직접 URL 이
|
||||
* 403 이 되어 배경 이미지가 전부 깨진다. 회귀 방지 축으로 가장 중요하다.
|
||||
*
|
||||
* @scenario public_asset_disk=unset,row_disk=s3,filter_url_hook=absent
|
||||
*
|
||||
* @effects proxy_url_otherwise
|
||||
*/
|
||||
public function test_private_s3_row_with_url_config_still_returns_proxy_url(): void
|
||||
{
|
||||
Config::set('core.storage.public_asset_disk', '');
|
||||
Config::set('attachment.disk', 's3');
|
||||
Config::set('filesystems.disks.s3.url', 'https://bucket.s3.ap-northeast-2.amazonaws.com');
|
||||
$this->storage->shouldNotReceive('withDisk');
|
||||
|
||||
$this->assertProxyUrl($this->service->resolveUrl($this->makeAttachment('s3')));
|
||||
}
|
||||
|
||||
/**
|
||||
* 공개 자산 디스크 설정 + 행 disk 일치 — 직접 URL 이어야 합니다.
|
||||
*
|
||||
* @scenario public_asset_disk=public,row_disk=public,filter_url_hook=absent
|
||||
*
|
||||
* @effects direct_url_when_row_matches_public_disk
|
||||
*/
|
||||
public function test_matching_public_asset_disk_returns_direct_url(): void
|
||||
{
|
||||
Config::set('core.storage.public_asset_disk', 'public');
|
||||
|
||||
$this->storage->shouldReceive('withDisk')->once()->with('public')->andReturnSelf();
|
||||
$this->storage->shouldReceive('url')->once()
|
||||
->with('template-layout-attachments', 'sirsoft-basic/2026/09/08/bg.png')
|
||||
->andReturn('https://cdn.example.test/template-layout-attachments/sirsoft-basic/2026/09/08/bg.png');
|
||||
|
||||
$this->assertSame(
|
||||
'https://cdn.example.test/template-layout-attachments/sirsoft-basic/2026/09/08/bg.png',
|
||||
$this->service->resolveUrl($this->makeAttachment('public'))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 공개 자산 디스크 설정 + 행 disk 불일치(설정 이전 업로드분) — 프록시여야 합니다.
|
||||
*
|
||||
* @scenario public_asset_disk=public,row_disk=attachments,filter_url_hook=absent
|
||||
*
|
||||
* @effects proxy_url_otherwise
|
||||
*/
|
||||
public function test_legacy_row_on_other_disk_returns_proxy_url(): void
|
||||
{
|
||||
Config::set('core.storage.public_asset_disk', 'public');
|
||||
$this->storage->shouldNotReceive('withDisk');
|
||||
|
||||
$this->assertProxyUrl($this->service->resolveUrl($this->makeAttachment('attachments')));
|
||||
}
|
||||
|
||||
/**
|
||||
* 설정된 공개 자산 디스크가 config 에 없으면(고아) 프록시여야 합니다.
|
||||
*
|
||||
* @scenario public_asset_disk=ghost_disk,row_disk=attachments,filter_url_hook=absent
|
||||
*
|
||||
* @effects proxy_url_otherwise
|
||||
*/
|
||||
public function test_orphan_public_asset_disk_returns_proxy_url(): void
|
||||
{
|
||||
Config::set('core.storage.public_asset_disk', 'vanished_plugin_disk');
|
||||
$this->storage->shouldNotReceive('withDisk');
|
||||
|
||||
$this->assertProxyUrl($this->service->resolveUrl($this->makeAttachment('vanished_plugin_disk')));
|
||||
}
|
||||
|
||||
/**
|
||||
* `core.storage.filter_url` 훅이 URL 을 차단해 url() 이 null 이면 프록시로 폴백해야 합니다.
|
||||
*
|
||||
* @scenario public_asset_disk=public,row_disk=public,filter_url_hook=blocks
|
||||
*
|
||||
* @effects proxy_url_otherwise
|
||||
*/
|
||||
public function test_blocked_url_hook_falls_back_to_proxy_url(): void
|
||||
{
|
||||
Config::set('core.storage.public_asset_disk', 'public');
|
||||
|
||||
$this->storage->shouldReceive('withDisk')->once()->with('public')->andReturnSelf();
|
||||
$this->storage->shouldReceive('url')->once()->andReturnNull();
|
||||
|
||||
$this->assertProxyUrl($this->service->resolveUrl($this->makeAttachment('public')));
|
||||
}
|
||||
|
||||
/**
|
||||
* 공개 자산 디스크가 s3(비공개 버킷)이고 행 disk 도 s3 — 직접 URL 이 발급돼야 합니다.
|
||||
*
|
||||
* 운영자가 "이 저장소는 공개다" 라고 **선언한** 결과이므로 시스템은 그 선언을 따른다.
|
||||
* 버킷이 실제로는 비공개여서 그 주소가 403 이 되는 것은 설정 책임이며, 문서의
|
||||
* "버킷/CDN 쪽 요구사항" 이 그 조건을 명시한다. 선언하지 않은 상태(unset)에서
|
||||
* 같은 행이 프록시로 남는 것과 대비되는 축이다.
|
||||
*
|
||||
* @scenario public_asset_disk=s3_private,row_disk=s3,filter_url_hook=absent
|
||||
*
|
||||
* @effects direct_url_when_row_matches_public_disk
|
||||
*/
|
||||
public function test_declared_s3_disk_with_matching_row_returns_direct_url(): void
|
||||
{
|
||||
Config::set('core.storage.public_asset_disk', 's3');
|
||||
Config::set('filesystems.disks.s3.url', 'https://bucket.s3.ap-northeast-2.amazonaws.com');
|
||||
|
||||
$this->storage->shouldReceive('withDisk')->once()->with('s3')->andReturnSelf();
|
||||
$this->storage->shouldReceive('url')->once()
|
||||
->andReturn('https://bucket.s3.ap-northeast-2.amazonaws.com/template-layout-attachments/sirsoft-basic/2026/09/08/bg.png');
|
||||
|
||||
$this->assertSame(
|
||||
'https://bucket.s3.ap-northeast-2.amazonaws.com/template-layout-attachments/sirsoft-basic/2026/09/08/bg.png',
|
||||
$this->service->resolveUrl($this->makeAttachment('s3'))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 공개 자산 디스크가 s3 인데 행 disk 가 public — 불일치이므로 프록시여야 합니다.
|
||||
*
|
||||
* 공개 자산 디스크를 public → s3 로 재구성한 뒤 남은 과거 행의 상황이다.
|
||||
* 파일은 public 에 그대로 있고 프록시가 행 disk 로 서빙하므로 화면은 정상이다.
|
||||
*
|
||||
* @scenario public_asset_disk=s3_private,row_disk=public,filter_url_hook=absent
|
||||
*
|
||||
* @effects proxy_url_otherwise
|
||||
*/
|
||||
public function test_reconfigured_public_asset_disk_demotes_old_rows_to_proxy(): void
|
||||
{
|
||||
Config::set('core.storage.public_asset_disk', 's3');
|
||||
Config::set('filesystems.disks.s3.url', 'https://bucket.s3.ap-northeast-2.amazonaws.com');
|
||||
$this->storage->shouldNotReceive('withDisk');
|
||||
|
||||
$this->assertProxyUrl($this->service->resolveUrl($this->makeAttachment('public')));
|
||||
}
|
||||
|
||||
/**
|
||||
* 공개 자산 디스크가 public 인데 행 disk 가 s3 — 불일치이므로 프록시여야 합니다.
|
||||
*
|
||||
* 첨부 디스크(s3)와 공개 자산 디스크(public)를 다르게 둔 이상적 혼재 구성에서,
|
||||
* 설정 이전에 s3 로 올라간 행이 직접 URL 로 승격되지 않아야 한다.
|
||||
*
|
||||
* @scenario public_asset_disk=public,row_disk=s3,filter_url_hook=absent
|
||||
*
|
||||
* @effects proxy_url_otherwise
|
||||
*/
|
||||
public function test_mixed_disks_keep_old_s3_rows_on_proxy(): void
|
||||
{
|
||||
Config::set('core.storage.public_asset_disk', 'public');
|
||||
Config::set('attachment.disk', 's3');
|
||||
Config::set('filesystems.disks.s3.url', 'https://bucket.s3.ap-northeast-2.amazonaws.com');
|
||||
$this->storage->shouldNotReceive('withDisk');
|
||||
|
||||
$this->assertProxyUrl($this->service->resolveUrl($this->makeAttachment('s3')));
|
||||
}
|
||||
|
||||
/**
|
||||
* 훅이 차단하는데 행 disk 가 공개 자산 디스크와 불일치 — 훅이 발화하지도 않고 프록시여야 합니다.
|
||||
*
|
||||
* 게이트가 url() 호출 앞에 있으므로 훅은 개입할 기회조차 얻지 못한다.
|
||||
*
|
||||
* @scenario public_asset_disk=public,row_disk=s3,filter_url_hook=blocks
|
||||
*
|
||||
* @effects proxy_url_otherwise
|
||||
*/
|
||||
public function test_hook_never_fires_when_row_disk_does_not_match(): void
|
||||
{
|
||||
Config::set('core.storage.public_asset_disk', 'public');
|
||||
$this->storage->shouldNotReceive('withDisk');
|
||||
$this->storage->shouldNotReceive('url');
|
||||
|
||||
$this->assertProxyUrl($this->service->resolveUrl($this->makeAttachment('s3')));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Support;
|
||||
|
||||
use App\Support\PublicAssetDisk;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* 공개 자산 디스크 해석기 단위 테스트 (공개 #134)
|
||||
*
|
||||
* `AbstractModule`/`AbstractPlugin` 에 사본으로 있던 판정식을 코어 공통 장소로
|
||||
* 추출한 것이므로, 판정 규칙(미설정/'none'/고아 디스크/override 우선순위)이
|
||||
* 한 글자도 바뀌지 않았음을 고정한다.
|
||||
*/
|
||||
class PublicAssetDiskTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* 미설정('')이면 null 이어야 합니다 (호출측이 기존 디스크로 폴백).
|
||||
*
|
||||
* @scenario public_asset_disk=unset
|
||||
*
|
||||
* @effects proxy_url_otherwise
|
||||
*/
|
||||
public function test_unset_resolves_to_null(): void
|
||||
{
|
||||
Config::set('core.storage.public_asset_disk', '');
|
||||
|
||||
$this->assertNull(PublicAssetDisk::resolve());
|
||||
}
|
||||
|
||||
/**
|
||||
* 'none' 은 명시적 스트리밍 유지 선언이므로 null 이어야 합니다.
|
||||
*/
|
||||
public function test_none_resolves_to_null(): void
|
||||
{
|
||||
Config::set('core.storage.public_asset_disk', 'none');
|
||||
|
||||
$this->assertNull(PublicAssetDisk::resolve());
|
||||
}
|
||||
|
||||
/**
|
||||
* config 에 존재하지 않는 디스크(고아 플러그인 디스크)는 null 이어야 합니다.
|
||||
*
|
||||
* @scenario public_asset_disk=ghost_disk
|
||||
*
|
||||
* @effects proxy_url_otherwise
|
||||
*/
|
||||
public function test_orphan_disk_resolves_to_null(): void
|
||||
{
|
||||
Config::set('core.storage.public_asset_disk', 'vanished_plugin_disk');
|
||||
|
||||
$this->assertNull(PublicAssetDisk::resolve());
|
||||
}
|
||||
|
||||
/**
|
||||
* config 에 존재하는 디스크는 그대로 돌려주어야 합니다.
|
||||
*/
|
||||
public function test_existing_disk_resolves_to_itself(): void
|
||||
{
|
||||
Config::set('core.storage.public_asset_disk', 'public');
|
||||
|
||||
$this->assertSame('public', PublicAssetDisk::resolve());
|
||||
}
|
||||
|
||||
/**
|
||||
* override 가 비어 있지 않으면 코어 전역 설정보다 우선해야 합니다.
|
||||
*/
|
||||
public function test_override_takes_precedence_over_global(): void
|
||||
{
|
||||
Config::set('core.storage.public_asset_disk', 'public');
|
||||
|
||||
$this->assertSame('local', PublicAssetDisk::resolve('local'));
|
||||
}
|
||||
|
||||
/**
|
||||
* override 가 ''/null 이면 코어 전역 설정을 사용해야 합니다.
|
||||
*/
|
||||
public function test_blank_override_falls_back_to_global(): void
|
||||
{
|
||||
Config::set('core.storage.public_asset_disk', 'public');
|
||||
|
||||
$this->assertSame('public', PublicAssetDisk::resolve(''));
|
||||
$this->assertSame('public', PublicAssetDisk::resolve(null));
|
||||
}
|
||||
|
||||
/**
|
||||
* override 로 'none' 을 주면 전역 설정이 있어도 스트리밍을 강제해야 합니다.
|
||||
*/
|
||||
public function test_none_override_forces_streaming_over_global(): void
|
||||
{
|
||||
Config::set('core.storage.public_asset_disk', 'public');
|
||||
|
||||
$this->assertNull(PublicAssetDisk::resolve('none'));
|
||||
}
|
||||
|
||||
/**
|
||||
* isCurrent() 는 resolve() 를 경유하므로 ''/'none'/고아 디스크가
|
||||
* 등가 비교로 통과하지 않아야 합니다.
|
||||
*/
|
||||
public function test_is_current_never_matches_blank_none_or_orphan(): void
|
||||
{
|
||||
Config::set('core.storage.public_asset_disk', '');
|
||||
$this->assertFalse(PublicAssetDisk::isCurrent(''));
|
||||
|
||||
Config::set('core.storage.public_asset_disk', 'none');
|
||||
$this->assertFalse(PublicAssetDisk::isCurrent('none'));
|
||||
|
||||
Config::set('core.storage.public_asset_disk', 'vanished_plugin_disk');
|
||||
$this->assertFalse(PublicAssetDisk::isCurrent('vanished_plugin_disk'));
|
||||
|
||||
Config::set('core.storage.public_asset_disk', 'public');
|
||||
$this->assertTrue(PublicAssetDisk::isCurrent('public'));
|
||||
$this->assertFalse(PublicAssetDisk::isCurrent('attachments'));
|
||||
$this->assertFalse(PublicAssetDisk::isCurrent(null));
|
||||
}
|
||||
|
||||
/**
|
||||
* memoize 금지 — 런타임 Config::set 변경이 즉시 반영되어야 합니다.
|
||||
*/
|
||||
public function test_resolution_is_not_memoized(): void
|
||||
{
|
||||
Config::set('core.storage.public_asset_disk', 'public');
|
||||
$this->assertSame('public', PublicAssetDisk::resolve());
|
||||
|
||||
Config::set('core.storage.public_asset_disk', '');
|
||||
$this->assertNull(PublicAssetDisk::resolve());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user