seed(IdentityPolicySeeder::class); $expectedKeys = [ 'core.auth.signup_before_submit', 'core.auth.signup_after_create', 'core.auth.password_reset', 'core.profile.password_change', 'core.profile.contact_change', 'core.account.withdraw', 'core.admin.app_key_regenerate', 'core.admin.user_delete', 'core.admin.extension_uninstall', ]; foreach ($expectedKeys as $key) { $this->assertDatabaseHas('identity_policies', [ 'key' => $key, 'source_type' => 'core', ]); } } public function test_seeder_is_idempotent(): void { $this->seed(IdentityPolicySeeder::class); $firstCount = IdentityPolicy::count(); $this->seed(IdentityPolicySeeder::class); $secondCount = IdentityPolicy::count(); $this->assertSame($firstCount, $secondCount, 'Seeder 재실행 시 중복 생성되지 않아야 합니다'); } public function test_default_enabled_policies_are_active(): void { $this->seed(IdentityPolicySeeder::class); foreach ([ 'core.profile.password_change', 'core.profile.contact_change', 'core.account.withdraw', ] as $key) { $policy = IdentityPolicy::where('key', $key)->first(); $this->assertNotNull($policy); $this->assertTrue((bool) $policy->enabled, "{$key} should be enabled by default"); } } public function test_default_disabled_policies_are_inactive(): void { $this->seed(IdentityPolicySeeder::class); foreach ([ 'core.auth.signup_before_submit', 'core.auth.signup_after_create', 'core.auth.password_reset', 'core.admin.app_key_regenerate', 'core.admin.user_delete', 'core.admin.extension_uninstall', ] as $key) { $policy = IdentityPolicy::where('key', $key)->first(); $this->assertNotNull($policy); $this->assertFalse((bool) $policy->enabled, "{$key} should be disabled by default (운영자 opt-in)"); } } }