packRoot = base_path('lang-packs/test-feature-notif-ja'); File::ensureDirectoryExists($this->packRoot.'/seed'); } protected function tearDown(): void { File::deleteDirectory($this->packRoot); parent::tearDown(); } public function test_apply_filters_injects_ja_translation_when_active_pack_has_seed(): void { File::put($this->packRoot.'/seed/notifications.json', json_encode([ 'welcome' => [ 'definition' => ['name' => 'ようこそ通知', 'description' => '新規会員へのウェルカム'], 'templates' => ['mail' => ['subject' => 'ようこそ', 'body' => '

{user_name}

']], ], ])); LanguagePack::query()->create([ 'identifier' => 'test-feature-notif-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(); // injectNotifications 는 `type` 필드를 lookup key 로 사용 (config/core.php notification_definitions 형태) $definitions = [ [ 'type' => 'welcome', 'name' => ['ko' => '회원가입 환영', 'en' => 'Welcome'], 'description' => ['ko' => '신규 회원 환영', 'en' => 'New member welcome'], 'templates' => [ [ 'channel' => 'mail', 'subject' => ['ko' => '환영합니다', 'en' => 'Welcome'], 'body' => ['ko' => '

{user_name}

', 'en' => '

{user_name}

'], ], ], ], ]; $result = HookManager::applyFilters('seed.notifications.translations', $definitions); $this->assertSame('ようこそ通知', $result[0]['name']['ja']); $this->assertSame('新規会員へのウェルカム', $result[0]['description']['ja']); $this->assertSame('ようこそ', $result[0]['templates'][0]['subject']['ja']); $this->assertSame('

{user_name}

', $result[0]['templates'][0]['body']['ja']); // ko/en 보존 $this->assertSame('회원가입 환영', $result[0]['name']['ko']); $this->assertSame('Welcome', $result[0]['name']['en']); } public function test_apply_filters_passthrough_when_no_active_pack(): void { $definitions = [ [ 'type' => 'welcome', 'name' => ['ko' => '환영', 'en' => 'Welcome'], 'templates' => [], ], ]; $result = HookManager::applyFilters('seed.notifications.translations', $definitions); $this->assertSame($definitions, $result); } }