From eb31455e606f8e0b965b6b3cd83d4e2c9de34df5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Falc=C3=B3n?= Date: Fri, 3 Jul 2026 09:27:43 +0200 Subject: [PATCH] fix: skip demo reset when demo account is disabled (#626) ## What `demo:reset` now bails out early with an info message when `config('app.demo.enabled')` is falsy, instead of rebuilding the demo account regardless of the `DEMO_ENABLED` flag. ## Why The `DEMO_ENABLED` config existed but the command ignored it, so a scheduled reset would recreate demo data on environments where the demo account is turned off. --- app/Console/Commands/ResetDemoAccountCommand.php | 8 ++++++++ tests/Feature/Console/ResetDemoAccountCommandTest.php | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/app/Console/Commands/ResetDemoAccountCommand.php b/app/Console/Commands/ResetDemoAccountCommand.php index 8506575d..cba3bd34 100644 --- a/app/Console/Commands/ResetDemoAccountCommand.php +++ b/app/Console/Commands/ResetDemoAccountCommand.php @@ -40,6 +40,14 @@ class ResetDemoAccountCommand extends Command public function handle(): int { + $demoEnabled = config('app.demo.enabled'); + + if (! $demoEnabled) { + $this->info('Demo account is not enabled'); + + return self::SUCCESS; + } + $demoEmail = config('app.demo.email'); $demoPassword = config('app.demo.password'); diff --git a/tests/Feature/Console/ResetDemoAccountCommandTest.php b/tests/Feature/Console/ResetDemoAccountCommandTest.php index 4ec80126..bb94eca0 100644 --- a/tests/Feature/Console/ResetDemoAccountCommandTest.php +++ b/tests/Feature/Console/ResetDemoAccountCommandTest.php @@ -4,11 +4,20 @@ use App\Models\User; beforeEach(function () { config(['app.demo' => [ + 'enabled' => true, 'email' => 'demo@whisper.money', 'password' => 'demo', ]]); }); +test('demo:reset does nothing when the demo account is disabled', function () { + config(['app.demo.enabled' => false]); + + $this->artisan('demo:reset')->assertSuccessful(); + + expect(User::where('email', 'demo@whisper.money')->exists())->toBeFalse(); +}); + test('demo:reset fails if demo email is not configured', function () { config(['app.demo.email' => null]);