admin()->create(); $otherAdmin = User::factory()->admin()->create(); try { $primaryAdmin->delete(); $this->fail('Primary admin deletion should be blocked.'); } catch (\RuntimeException $exception) { $this->assertDatabaseHas('users', [ 'id' => $primaryAdmin->id, ]); $this->assertSame('Primary admin account cannot be deleted.', $exception->getMessage()); } $otherAdmin->delete(); $this->assertDatabaseMissing('users', [ 'id' => $otherAdmin->id, ]); } }