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]);