cache = new CoreCacheDriver('array'); $this->app->instance(CacheInterface::class, $this->cache); } protected function tearDown(): void { Cache::flush(); parent::tearDown(); } /** * G-1-1: 모듈 키 픽스처 다건 put→forget 왕복 (드라이버 동작 검증 — 커맨드 미호출). */ #[Test] public function g_1_1_module_cache_clear_removes_per_module_keys(): void { $identifier = 'sirsoft-ecommerce'; $keys = [ "module.config.{$identifier}", "module.info.{$identifier}", "module.routes.{$identifier}", "module.permissions.{$identifier}", "module.menus.{$identifier}", ]; foreach ($keys as $k) { $this->cache->put($k, 'data'); } // CacheInterface.forget 다건 호출 (드라이버 동작 검증) foreach ($keys as $k) { $this->cache->forget($k); } foreach ($keys as $k) { $this->assertFalse($this->cache->has($k), "Key {$k} should be cleared"); } } /** * G-1-2: 플러그인 키 픽스처 다건 put→forget 왕복 (드라이버 동작 검증 — 커맨드 미호출). */ #[Test] public function g_1_2_plugin_cache_clear_removes_per_plugin_keys(): void { $identifier = 'sirsoft-payment'; $keys = [ "plugin.config.{$identifier}", "plugin.info.{$identifier}", "plugin.routes.{$identifier}", "plugin.permissions.{$identifier}", ]; foreach ($keys as $k) { $this->cache->put($k, 'data'); } foreach ($keys as $k) { $this->cache->forget($k); } foreach ($keys as $k) { $this->assertFalse($this->cache->has($k)); } } /** * G-1-3: 템플릿/레이아웃 키 픽스처 다건 put→forget 왕복 (드라이버 동작 검증 — 커맨드 미호출). */ #[Test] public function g_1_3_template_cache_clear_removes_template_layout_routes(): void { $identifier = 'sirsoft-admin_basic'; $keys = [ "layout.{$identifier}.dashboard", "layout.{$identifier}.users", "template.routes.{$identifier}", "template.language.{$identifier}.ko", "template.language.{$identifier}.en", 'templates.active.admin', 'templates.active.user', ]; foreach ($keys as $k) { $this->cache->put($k, 'data'); } foreach ($keys as $k) { $this->cache->forget($k); } foreach ($keys as $k) { $this->assertFalse($this->cache->has($k)); } } /** * G-1-4: 전역 + 개별 키 혼합 다건 put→forget 왕복 (드라이버 동작 검증 — 커맨드 미호출). */ #[Test] public function g_1_4_clear_without_args_clears_all(): void { // 전역 키 $this->cache->put('modules.all', 'global'); $this->cache->put('modules.active', 'global'); $this->cache->put('modules.installed', 'global'); // 개별 모듈 키 foreach (['mod-a', 'mod-b'] as $id) { $this->cache->put("module.config.{$id}", 'data'); $this->cache->put("module.info.{$id}", 'data'); } // 전역 + 개별 모두 forget (드라이버 동작 검증) $globalKeys = ['modules.all', 'modules.active', 'modules.installed']; foreach ($globalKeys as $k) { $this->cache->forget($k); } foreach (['mod-a', 'mod-b'] as $id) { $this->cache->forget("module.config.{$id}"); $this->cache->forget("module.info.{$id}"); } foreach ($globalKeys as $k) { $this->assertFalse($this->cache->has($k)); } foreach (['mod-a', 'mod-b'] as $id) { $this->assertFalse($this->cache->has("module.config.{$id}")); $this->assertFalse($this->cache->has("module.info.{$id}")); } } }