snapshotHookManager(); } /** * tearDown 에 HookManager 상태 복원. * * @return void */ protected function tearDown(): void { $this->restoreHookManager(); parent::tearDown(); } /** * HookManager static $hooks / $filters / $dispatching 를 스냅샷. * * @return void */ private function snapshotHookManager(): void { $ref = new \ReflectionClass(\App\Extension\HookManager::class); $this->hookSnapshot = [ 'hooks' => $ref->getProperty('hooks')->getValue(), 'filters' => $ref->getProperty('filters')->getValue(), 'dispatching' => $ref->getProperty('dispatching')->getValue(), ]; } /** * 스냅샷 시점으로 HookManager 복원. * * @return void */ private function restoreHookManager(): void { if ($this->hookSnapshot === null) { return; } $ref = new \ReflectionClass(\App\Extension\HookManager::class); $ref->getProperty('hooks')->setValue(null, $this->hookSnapshot['hooks']); $ref->getProperty('filters')->setValue(null, $this->hookSnapshot['filters']); $ref->getProperty('dispatching')->setValue(null, $this->hookSnapshot['dispatching']); $this->hookSnapshot = null; } /** * 마이그레이션 경로를 반환합니다. * * RefreshDatabase 의 migrate:fresh 명령에 코어 + 번들 확장 마이그레이션 경로를 전달합니다. * * @return array */ protected function migrateFreshUsing(): array { $paths = ['database/migrations']; foreach (glob(base_path('modules/_bundled/*/database/migrations'), GLOB_ONLYDIR) as $p) { $paths[] = str_replace(base_path().DIRECTORY_SEPARATOR, '', $p); } foreach (glob(base_path('plugins/_bundled/*/database/migrations'), GLOB_ONLYDIR) as $p) { $paths[] = str_replace(base_path().DIRECTORY_SEPARATOR, '', $p); } return [ '--drop-views' => $this->shouldDropViews(), '--drop-types' => $this->shouldDropTypes(), '--seed' => false, '--path' => $paths, ]; } }