비즈뿌리오 알림톡 UX 개편 후속: - 코어/게시판/이커머스 알림 템플릿 [편집] 모달에 확장 채널 편집 영역 (extension_point 2종 + hidden_template_editor 채널 메타)을 신설하고, 알림톡 템플릿·문자(SMS)·수신자 규칙을 한 창에서 통합 저장하도록 개정 (행 하단은 상태 요약 전용, 승인 여부 2단 배지) - 검수 신청에 검수자 전달 의견(comment) 동봉 — kapi request 로만 전달, 행에는 저장하지 않음 (FormRequest 신설 + API 문서 백필) - 관리 탭 모바일 카드뷰·도구줄 코어 관례 통일, 사이트맵 알림 정의 다국어 라벨 결측 수정 + 코어 정의 라벨 패리티 테스트 신설 언어팩 번역 소실·보존 결함군 (보완 실측 → 커밋 전 점검에서 연쇄 확정, 전부 실패 테스트 선행 후 수정): - [기본값 복원]이 활성 언어팩 번역(ja)을 영구 소실 → 복원 기본값에 시딩과 같은 주입기(SSoT)로 팩 로케일 병합 (notification·identity) - 코어 알림/본인인증 시더의 언어팩 주입 전면 불능 → 주입기가 연관/리스트 양형태 수용 + identity 시더의 config 복합 키 보존 - 실패한 언어팩 업데이트가 active 팩을 installed 로 방치 → 상태 복원 확장 - 병합·제거의 사용자 수정 보존 판정 사문(연관 전제 isset) → dot-path 판정 교정, 팩 주입 저장의 user_overrides 오염 차단(시딩 바인딩), 템플릿 2모델 translatableTrackableFields 선언(beta.4 설계 누락), 같은 프로세스 활성화 시 시더 번역 필터 stale(캡처 인스턴스 캐시) 교정 - 7.0.9 업그레이드 스텝 신설 — 활성 팩 seed 재동기화로 기설치본의 소실 번역 자동 복구 (멱등·운영자 수정 보존·팩별 실패 격리)
196 lines
8.2 KiB
PHP
196 lines
8.2 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\LanguagePack;
|
|
|
|
use App\Enums\LanguagePackScope;
|
|
use App\Enums\LanguagePackStatus;
|
|
use App\Extension\HookManager;
|
|
use App\Models\IdentityMessageDefinition;
|
|
use App\Models\IdentityMessageTemplate;
|
|
use App\Models\LanguagePack;
|
|
use App\Services\IdentityMessageTemplateService;
|
|
use App\Services\LanguagePack\LanguagePackRegistry;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\File;
|
|
use Tests\TestCase;
|
|
|
|
/**
|
|
* IdentityMessageDefinitionSeeder 와 활성 코어 언어팩의 seed/identity_messages.json 통합 검증.
|
|
*
|
|
* 시더 → applyFilters('seed.identity_messages.translations', ...) → 활성 ja 패키지의 seed JSON
|
|
* 으로 다국어 키 보강 → DB 동기화의 end-to-end 흐름 검증.
|
|
*
|
|
* 본 테스트는 시더 호출 자체를 검증하지 않고 (helper 가 DB 작성 — 이미 다른 곳에서 검증),
|
|
* **applyFilters 통과 후 정의 배열에 ja 키가 추가되는지** 만 검증한다 (lang pack 인프라 통합 가드).
|
|
*/
|
|
class IdentitySeedInjectionTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
private string $packRoot;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
$this->packRoot = base_path('lang-packs/test-feature-idv-ja');
|
|
File::ensureDirectoryExists($this->packRoot.'/seed');
|
|
}
|
|
|
|
protected function tearDown(): void
|
|
{
|
|
File::deleteDirectory($this->packRoot);
|
|
parent::tearDown();
|
|
}
|
|
|
|
/**
|
|
* @scenario domain=identity, entry=seeder_filter
|
|
*
|
|
* @effects seeder_filter_injects_active_pack_locales
|
|
*/
|
|
public function test_apply_filters_injects_ja_translation_when_active_pack_has_seed(): void
|
|
{
|
|
File::put($this->packRoot.'/seed/identity_messages.json', json_encode([
|
|
'mail.purpose.signup' => [
|
|
'definition' => ['name' => '会員登録認証', 'description' => ''],
|
|
'templates' => ['mail' => ['subject' => '[アプリ] 認証コード', 'body' => '<p>{code}</p>']],
|
|
],
|
|
]));
|
|
|
|
LanguagePack::query()->create([
|
|
'identifier' => 'test-feature-idv-ja',
|
|
'vendor' => 'test',
|
|
'scope' => LanguagePackScope::Core->value,
|
|
'target_identifier' => null,
|
|
'locale' => 'ja',
|
|
'locale_name' => 'Japanese',
|
|
'locale_native_name' => '日本語',
|
|
'text_direction' => 'ltr',
|
|
'version' => '1.0.0',
|
|
'status' => LanguagePackStatus::Active->value,
|
|
'is_protected' => false,
|
|
'manifest' => [],
|
|
'source_type' => 'zip',
|
|
]);
|
|
// ServiceProvider 의 필터 closure 가 캡처한 LanguagePackSeedInjector → Registry cache 무효화.
|
|
$this->app->make(LanguagePackRegistry::class)->invalidate();
|
|
|
|
// config/core.php 와 동일 형태의 string-keyed array
|
|
$definitions = [
|
|
'mail.purpose.signup' => [
|
|
'provider_id' => 'g7:core.mail',
|
|
'scope_type' => 'purpose',
|
|
'scope_value' => 'signup',
|
|
'name' => ['ko' => '회원가입 인증', 'en' => 'Signup Verification'],
|
|
'description' => ['ko' => '회원가입 인증', 'en' => ''],
|
|
'templates' => [
|
|
[
|
|
'channel' => 'mail',
|
|
'subject' => ['ko' => '[앱] 인증 코드', 'en' => '[App] Code'],
|
|
'body' => ['ko' => '<p>{code}</p>', 'en' => '<p>{code}</p>'],
|
|
],
|
|
],
|
|
],
|
|
];
|
|
|
|
$result = HookManager::applyFilters('seed.identity_messages.translations', $definitions);
|
|
|
|
$this->assertSame('会員登録認証', $result['mail.purpose.signup']['name']['ja']);
|
|
$this->assertSame('[アプリ] 認証コード', $result['mail.purpose.signup']['templates'][0]['subject']['ja']);
|
|
$this->assertSame('<p>{code}</p>', $result['mail.purpose.signup']['templates'][0]['body']['ja']);
|
|
// ko/en 보존 검증
|
|
$this->assertSame('회원가입 인증', $result['mail.purpose.signup']['name']['ko']);
|
|
$this->assertSame('Signup Verification', $result['mail.purpose.signup']['name']['en']);
|
|
}
|
|
|
|
public function test_apply_filters_passthrough_when_no_active_pack(): void
|
|
{
|
|
$definitions = [
|
|
'mail.purpose.signup' => [
|
|
'provider_id' => 'g7:core.mail',
|
|
'scope_type' => 'purpose',
|
|
'scope_value' => 'signup',
|
|
'name' => ['ko' => '회원가입', 'en' => 'Signup'],
|
|
'templates' => [],
|
|
],
|
|
];
|
|
|
|
$result = HookManager::applyFilters('seed.identity_messages.translations', $definitions);
|
|
|
|
// 활성 ja 팩 없음 → 입력 그대로 반환
|
|
$this->assertSame($definitions, $result);
|
|
}
|
|
|
|
/**
|
|
* [기본값 복원] 경로 회귀 — IdentityMessageTemplateService::resetToDefault 는
|
|
* core.identity.filter_default_message_definitions 필터의 기본값(ko/en)으로
|
|
* subject/body 를 대체하므로, 언어팩 주입에 참여하지 않으면 팩이 주입해 둔
|
|
* 로케일(ja)이 복원 시 영구 소실된다 (notification 쪽 실사례의 동형 — #597 보완 실측).
|
|
*
|
|
* @scenario domain=identity, entry=reset_default
|
|
*
|
|
* @effects identity_reset_default_preserves_lang_pack_locales
|
|
*/
|
|
public function test_reset_to_default_preserves_lang_pack_locales(): void
|
|
{
|
|
File::put($this->packRoot.'/seed/identity_messages.json', json_encode([
|
|
'mail.purpose.signup' => [
|
|
'definition' => ['name' => '会員登録認証', 'description' => ''],
|
|
'templates' => ['mail' => ['subject' => '[アプリ] 認証コード', 'body' => '<p>{code}</p>']],
|
|
],
|
|
]));
|
|
|
|
LanguagePack::query()->create([
|
|
'identifier' => 'test-feature-idv-ja',
|
|
'vendor' => 'test',
|
|
'scope' => LanguagePackScope::Core->value,
|
|
'target_identifier' => null,
|
|
'locale' => 'ja',
|
|
'locale_name' => 'Japanese',
|
|
'locale_native_name' => '日本語',
|
|
'text_direction' => 'ltr',
|
|
'version' => '1.0.0',
|
|
'status' => LanguagePackStatus::Active->value,
|
|
'is_protected' => false,
|
|
'manifest' => [],
|
|
'source_type' => 'zip',
|
|
]);
|
|
$this->app->make(LanguagePackRegistry::class)->invalidate();
|
|
|
|
// config/core.php 실항목을 그대로 픽스처로 사용 — 복원 매칭(provider/scope) 정합 보장.
|
|
$cfg = config('core.identity_messages')['mail.purpose.signup'];
|
|
|
|
$definition = IdentityMessageDefinition::query()->create([
|
|
'extension_type' => 'core',
|
|
'extension_identifier' => 'core',
|
|
'provider_id' => $cfg['provider_id'],
|
|
'scope_type' => $cfg['scope_type'],
|
|
'scope_value' => $cfg['scope_value'],
|
|
'name' => $cfg['name'],
|
|
'description' => $cfg['description'] ?? null,
|
|
'channels' => $cfg['channels'] ?? ['mail'],
|
|
'variables' => [],
|
|
'is_active' => true,
|
|
'is_default' => true,
|
|
]);
|
|
|
|
$template = IdentityMessageTemplate::query()->create([
|
|
'definition_id' => $definition->id,
|
|
'channel' => 'mail',
|
|
'subject' => ['ko' => '운영자가 바꾼 제목'],
|
|
'body' => ['ko' => '운영자가 바꾼 본문 {code}'],
|
|
'is_active' => true,
|
|
'is_default' => false,
|
|
]);
|
|
|
|
$updated = $this->app->make(IdentityMessageTemplateService::class)
|
|
->resetToDefault($template);
|
|
|
|
$this->assertTrue((bool) $updated->is_default, '복원 후 is_default 가 참이어야 한다');
|
|
$this->assertSame('[アプリ] 認証コード', $updated->subject['ja'] ?? null,
|
|
'복원 기본값에 활성 팩 seed 의 ja subject 가 병합되어야 한다 — 없으면 복원이 팩 번역을 지운다');
|
|
$this->assertSame('<p>{code}</p>', $updated->body['ja'] ?? null,
|
|
'복원 기본값에 활성 팩 seed 의 ja body 가 병합되어야 한다');
|
|
$this->assertArrayHasKey('ko', $updated->subject, 'ko 는 config 원본에서 보존');
|
|
}
|
|
}
|