getVirtualBuiltInPacks(); $modulePacks = $packs->filter( fn (LanguagePack $p) => $p->scope === LanguagePackScope::Module->value && $p->source_type === LanguagePackSourceType::BuiltIn->value ); $this->assertNotEmpty($modulePacks, '번들 모듈의 내장 언어팩이 하나 이상 합성되어야 합니다.'); foreach ($modulePacks as $pack) { $this->assertMatchesRegularExpression( '#^modules/_bundled/[^/]+/src/lang/(ko|en)$#', (string) $pack->source_url, "모듈 내장 언어팩 경로는 런타임이 로드하는 src/lang 이어야 합니다: {$pack->target_identifier} ({$pack->locale}) → {$pack->source_url}" ); } } /** * 번들 모듈이 런타임 미로드 경로에 백엔드 다국어 파일을 두지 않았는지 검증합니다. * * `resources/lang/{locale}/*.php` 는 프런트엔드용 `resources/lang/{locale}.json` · * `resources/lang/partial/{locale}/` 와 달리 아무도 읽지 않는다. 거기 문구를 고치면 * 고쳐지지 않고, 그 사실이 드러나지 않는다. */ #[Test] public function bundled_modules_have_no_backend_lang_outside_runtime_path(): void { $root = base_path('modules/_bundled'); if (! File::isDirectory($root)) { $this->markTestSkipped('번들 모듈 디렉토리가 없습니다.'); } $stray = []; foreach (File::directories($root) as $moduleDir) { foreach (['ko', 'en'] as $locale) { $wrong = $moduleDir.'/resources/lang/'.$locale; if (! File::isDirectory($wrong)) { continue; } $php = array_map( fn ($f) => basename($moduleDir).'/resources/lang/'.$locale.'/'.basename($f), File::glob($wrong.'/*.php') ?: [] ); $stray = array_merge($stray, $php); } } $this->assertSame( [], $stray, "런타임이 읽지 않는 경로의 백엔드 다국어 파일이 있습니다(모듈은 src/lang 만 로드):\n ".implode("\n ", $stray) ); } }