v7.0.0-beta.5 release

This commit is contained in:
HeuJung committed 2026-05-12 17:58:34 +09:00
1 parent 1db039ff34
commit eb467aca79
159 files changed
+7599 -218

No files matched your search

@@ -1181,6 +1181,152 @@ MD;
}
}
/**
* targets 에 `templates/_bundled` 만 있고 source 의 `templates/` 디렉토리에 `_bundled`
* 만 있을 때, 활성 디렉토리(`templates/sirsoft-basic` 등) 가 자동 발견 폴백의
* removeOrphans 로 삭제되지 않아야 한다.
*
* 회귀 시나리오 (#347): beta.4 의 `isCoveredByApplied` 가 단방향 검사만 수행하여
* applied=['templates/_bundled'] 일 때 source 의 'templates' 자체를 신규 항목으로
* 오인 → `copyDirectory(removeOrphans:true)` 가 base 의 활성 sirsoft-* 서브디렉토리를
* orphan 으로 판정하여 삭제.
*/
public function test_apply_update_preserves_active_extension_dirs_when_source_only_has_bundled(): void
{
$sourcePath = storage_path('test_apply_preserve_src_'.uniqid());
$this->tempDirs[] = $sourcePath;
File::ensureDirectoryExists($sourcePath);
// source: templates/_bundled/{shared-id}/manifest.json 만 보유
File::ensureDirectoryExists($sourcePath.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR.'_bundled'.DIRECTORY_SEPARATOR.'sirsoft-basic');
File::put(
$sourcePath.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR.'_bundled'.DIRECTORY_SEPARATOR.'sirsoft-basic'.DIRECTORY_SEPARATOR.'manifest.json',
'{"identifier":"sirsoft-basic","version":"1.0.0"}'
);
// base: templates/_bundled/sirsoft-basic + templates/sirsoft-basic (활성 디렉토리)
$fakeBase = storage_path('test_apply_preserve_base_'.uniqid());
$this->tempDirs[] = $fakeBase;
File::ensureDirectoryExists($fakeBase);
$originalBasePath = base_path();
app()->setBasePath($fakeBase);
File::ensureDirectoryExists($fakeBase.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR.'_bundled'.DIRECTORY_SEPARATOR.'sirsoft-basic');
File::put(
$fakeBase.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR.'_bundled'.DIRECTORY_SEPARATOR.'sirsoft-basic'.DIRECTORY_SEPARATOR.'manifest.json',
'{"identifier":"sirsoft-basic","version":"0.9.0"}'
);
File::ensureDirectoryExists($fakeBase.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR.'sirsoft-basic');
File::put(
$fakeBase.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR.'sirsoft-basic'.DIRECTORY_SEPARATOR.'manifest.json',
'{"identifier":"sirsoft-basic","installed":true}'
);
try {
config([
'app.update.targets' => ['templates/_bundled'],
'app.update.excludes' => [],
'app.update.protected_paths' => ['.env', 'storage', 'vendor', 'node_modules', '.git'],
]);
$this->service->applyUpdate($sourcePath);
// _bundled 는 source 기준으로 정상 sync
$this->assertFileExists(
$fakeBase.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR.'_bundled'.DIRECTORY_SEPARATOR.'sirsoft-basic'.DIRECTORY_SEPARATOR.'manifest.json'
);
// 활성 디렉토리는 source 에 부재하지만 base 에 보존되어야 함 (회귀 차단)
$this->assertFileExists(
$fakeBase.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR.'sirsoft-basic'.DIRECTORY_SEPARATOR.'manifest.json',
'활성 templates/sirsoft-basic 이 자동 발견 폴백에 의해 삭제되어서는 안 된다 (#347 회귀)'
);
} finally {
app()->setBasePath($originalBasePath);
}
}
/**
* modules/, plugins/ 에도 동일 패턴 보존 확인 (#347 회귀).
*/
public function test_apply_update_preserves_active_module_and_plugin_dirs_same_pattern(): void
{
$sourcePath = storage_path('test_apply_preserve_mp_src_'.uniqid());
$this->tempDirs[] = $sourcePath;
File::ensureDirectoryExists($sourcePath);
// source: modules/_bundled, plugins/_bundled 만 보유
File::ensureDirectoryExists($sourcePath.DIRECTORY_SEPARATOR.'modules'.DIRECTORY_SEPARATOR.'_bundled'.DIRECTORY_SEPARATOR.'sirsoft-ecommerce');
File::put(
$sourcePath.DIRECTORY_SEPARATOR.'modules'.DIRECTORY_SEPARATOR.'_bundled'.DIRECTORY_SEPARATOR.'sirsoft-ecommerce'.DIRECTORY_SEPARATOR.'module.json',
'{"identifier":"sirsoft-ecommerce","version":"1.0.0"}'
);
File::ensureDirectoryExists($sourcePath.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.'_bundled'.DIRECTORY_SEPARATOR.'sirsoft-payment');
File::put(
$sourcePath.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.'_bundled'.DIRECTORY_SEPARATOR.'sirsoft-payment'.DIRECTORY_SEPARATOR.'plugin.json',
'{"identifier":"sirsoft-payment","version":"1.0.0"}'
);
$fakeBase = storage_path('test_apply_preserve_mp_base_'.uniqid());
$this->tempDirs[] = $fakeBase;
File::ensureDirectoryExists($fakeBase);
$originalBasePath = base_path();
app()->setBasePath($fakeBase);
// base 활성 디렉토리 + _bundled 모두 있는 상태
File::ensureDirectoryExists($fakeBase.DIRECTORY_SEPARATOR.'modules'.DIRECTORY_SEPARATOR.'_bundled'.DIRECTORY_SEPARATOR.'sirsoft-ecommerce');
File::put(
$fakeBase.DIRECTORY_SEPARATOR.'modules'.DIRECTORY_SEPARATOR.'_bundled'.DIRECTORY_SEPARATOR.'sirsoft-ecommerce'.DIRECTORY_SEPARATOR.'module.json',
'{"identifier":"sirsoft-ecommerce","version":"0.9.0"}'
);
File::ensureDirectoryExists($fakeBase.DIRECTORY_SEPARATOR.'modules'.DIRECTORY_SEPARATOR.'sirsoft-ecommerce');
File::put(
$fakeBase.DIRECTORY_SEPARATOR.'modules'.DIRECTORY_SEPARATOR.'sirsoft-ecommerce'.DIRECTORY_SEPARATOR.'module.json',
'{"installed":true}'
);
File::ensureDirectoryExists($fakeBase.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.'_bundled'.DIRECTORY_SEPARATOR.'sirsoft-payment');
File::put(
$fakeBase.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.'_bundled'.DIRECTORY_SEPARATOR.'sirsoft-payment'.DIRECTORY_SEPARATOR.'plugin.json',
'{"identifier":"sirsoft-payment","version":"0.9.0"}'
);
File::ensureDirectoryExists($fakeBase.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.'sirsoft-payment');
File::put(
$fakeBase.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.'sirsoft-payment'.DIRECTORY_SEPARATOR.'plugin.json',
'{"installed":true}'
);
try {
config([
'app.update.targets' => ['modules/_bundled', 'plugins/_bundled'],
'app.update.excludes' => [],
'app.update.protected_paths' => ['.env', 'storage', 'vendor', 'node_modules', '.git'],
]);
$this->service->applyUpdate($sourcePath);
// 활성 모듈/플러그인 디렉토리 보존
$this->assertFileExists(
$fakeBase.DIRECTORY_SEPARATOR.'modules'.DIRECTORY_SEPARATOR.'sirsoft-ecommerce'.DIRECTORY_SEPARATOR.'module.json',
'활성 modules/sirsoft-ecommerce 이 보존되어야 한다 (#347 회귀)'
);
$this->assertFileExists(
$fakeBase.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.'sirsoft-payment'.DIRECTORY_SEPARATOR.'plugin.json',
'활성 plugins/sirsoft-payment 이 보존되어야 한다 (#347 회귀)'
);
// _bundled sync 정상
$this->assertStringContainsString(
'"version":"1.0.0"',
File::get($fakeBase.DIRECTORY_SEPARATOR.'modules'.DIRECTORY_SEPARATOR.'_bundled'.DIRECTORY_SEPARATOR.'sirsoft-ecommerce'.DIRECTORY_SEPARATOR.'module.json')
);
} finally {
app()->setBasePath($originalBasePath);
}
}
/**
* 자동 발견 폴백이 protected_paths 와 user excludes 양쪽을 존중하는지 검증합니다.
*/
@@ -0,0 +1,129 @@
<?php
namespace Tests\Unit\Services;
use App\Contracts\Extension\IdentityVerificationInterface;
use App\Contracts\Repositories\IdentityPolicyRepositoryInterface;
use App\Contracts\Repositories\IdentityVerificationLogRepositoryInterface;
use App\Extension\IdentityVerification\IdentityVerificationManager;
use App\Models\IdentityPolicy;
use App\Services\IdentityPolicyService;
use Mockery;
use Tests\TestCase;
/**
* IdentityPolicyService::resolveRenderHint 의 fallback 분기 정합성 회귀 차단.
*
* 호출자 명시 인자(정책의 provider_id) 가 4계층(Service → Manager) 통과 중 silent drop
* 되던 결함을 cherry-pick 으로 가져온 4c723e154 가 Service::start 경로에서 수정했다.
* 본 테스트는 동일 패턴이 resolveRenderHint 의 fallback 분기에서도 회귀하지 않도록
* Manager::resolveForPurpose 호출 시 정책의 provider_id 가 두 번째 인자로 전달되는지를
* spy 로 직접 검증한다.
*
* 실질 동작 결과는 수정 전후 동일 (Manager 의 0번 우선순위는 미등록 provider 를 매치하지
* 않으므로 fallback chain 결과가 같음). 정합성 차원의 회귀 차단 목적.
*/
class IdentityPolicyServiceResolveRenderHintTest extends TestCase
{
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
public function test_fallback_branch_passes_policy_provider_id_to_manager(): void
{
$policyRepo = Mockery::mock(IdentityPolicyRepositoryInterface::class);
$logRepo = Mockery::mock(IdentityVerificationLogRepositoryInterface::class);
$resolvedProvider = Mockery::mock(IdentityVerificationInterface::class);
$resolvedProvider->shouldReceive('getRenderHint')->andReturn('text_code');
$manager = Mockery::mock(IdentityVerificationManager::class);
// 첫 분기: manager->has(provider) === false → fallback 진입 유도
$manager->shouldReceive('has')->with('plugin:disabled')->andReturn(false);
// 핵심 검증: fallback 분기에서 두 번째 인자로 정책의 provider_id 가 전달되어야 함
$manager->shouldReceive('resolveForPurpose')
->once()
->with('signup', 'plugin:disabled')
->andReturn($resolvedProvider);
$service = new IdentityPolicyService($policyRepo, $logRepo, $manager);
$policy = new IdentityPolicy([
'purpose' => 'signup',
'provider_id' => 'plugin:disabled',
]);
$hint = $this->invokeResolveRenderHint($service, $policy);
$this->assertSame('text_code', $hint);
}
public function test_fallback_branch_passes_null_when_policy_has_no_provider_id(): void
{
$policyRepo = Mockery::mock(IdentityPolicyRepositoryInterface::class);
$logRepo = Mockery::mock(IdentityVerificationLogRepositoryInterface::class);
$resolvedProvider = Mockery::mock(IdentityVerificationInterface::class);
$resolvedProvider->shouldReceive('getRenderHint')->andReturn('text_code');
$manager = Mockery::mock(IdentityVerificationManager::class);
// provider_id 가 falsy 면 첫 if 조건 자체에서 fallback 진입 (manager->has 미호출)
$manager->shouldReceive('resolveForPurpose')
->once()
->with('signup', null)
->andReturn($resolvedProvider);
$service = new IdentityPolicyService($policyRepo, $logRepo, $manager);
$policy = new IdentityPolicy([
'purpose' => 'signup',
'provider_id' => null,
]);
$hint = $this->invokeResolveRenderHint($service, $policy);
$this->assertSame('text_code', $hint);
}
public function test_first_branch_returns_provider_hint_without_fallback(): void
{
$policyRepo = Mockery::mock(IdentityPolicyRepositoryInterface::class);
$logRepo = Mockery::mock(IdentityVerificationLogRepositoryInterface::class);
$directProvider = Mockery::mock(IdentityVerificationInterface::class);
$directProvider->shouldReceive('getRenderHint')->andReturn('redirect_oauth');
$manager = Mockery::mock(IdentityVerificationManager::class);
$manager->shouldReceive('has')->with('plugin:active')->andReturn(true);
$manager->shouldReceive('get')->with('plugin:active')->andReturn($directProvider);
// 첫 분기 통과 시 resolveForPurpose 는 호출되어선 안 됨 (회귀 차단)
$manager->shouldNotReceive('resolveForPurpose');
$service = new IdentityPolicyService($policyRepo, $logRepo, $manager);
$policy = new IdentityPolicy([
'purpose' => 'signup',
'provider_id' => 'plugin:active',
]);
$hint = $this->invokeResolveRenderHint($service, $policy);
$this->assertSame('redirect_oauth', $hint);
}
/**
* protected resolveRenderHint 를 reflection 으로 직접 호출합니다.
*/
private function invokeResolveRenderHint(IdentityPolicyService $service, IdentityPolicy $policy): ?string
{
$reflection = new \ReflectionMethod(IdentityPolicyService::class, 'resolveRenderHint');
$reflection->setAccessible(true);
/** @var string|null $hint */
$hint = $reflection->invoke($service, $policy);
return $hint;
}
}
@@ -387,13 +387,19 @@ class LanguagePackServiceTest extends TestCase
$this->markTestSkipped('g7-core-ja 번들이 아직 빌드되지 않음 — build-language-pack-ja.cjs 실행 후 재시도');
}
// 번들 manifest 의 현재 버전을 기준으로 설치 결과 검증
// (코어 lang 변경 시 g7-core-ja 버전이 patch bump 되므로 하드코딩 회피)
$bundledManifest = json_decode(file_get_contents($bundledPath.'/language-pack.json'), true);
$bundledVersion = $bundledManifest['version'] ?? null;
$this->assertNotNull($bundledVersion, '번들 manifest 에 version 누락');
$pack = $this->service->installFromBundled('g7-core-ja', autoActivate: true);
$this->assertSame('g7-core-ja', $pack->identifier);
$this->assertSame(LanguagePackScope::Core->value, $pack->scope);
$this->assertNull($pack->target_identifier);
$this->assertSame('ja', $pack->locale);
$this->assertSame('1.0.0-beta.1', $pack->version);
$this->assertSame($bundledVersion, $pack->version);
$this->assertSame(LanguagePackStatus::Active->value, $pack->status);
$this->assertSame('bundled', $pack->source_type);
// is_protected 는 모든 install 흐름에서 항상 false (보호 행은 코어/번들 확장의 lang/ 디렉토리를 가상 행으로 합성하는 경로에서만 true)