find('app:doctors:purge') ); } public function testDryRunRunsInTestEnv(): void { $tester = $this->tester(); $tester->execute([]); $tester->assertCommandIsSuccessful(); $this->assertStringContainsString('dry-run', $tester->getDisplay()); } public function testRefusesOnProdWithNoEscapeHatch(): void { self::bootKernel(); $original = $_ENV['APP_ENV'] ?? null; $_ENV['APP_ENV'] = 'prod'; try { $tester = new CommandTester( (new Application(self::$kernel))->find('app:doctors:purge') ); $tester->execute(['--force' => true]); $this->assertSame(Command::FAILURE, $tester->getStatusCode()); $this->assertStringContainsString('فقط در محیط dev', $tester->getDisplay()); } finally { if ($original === null) { unset($_ENV['APP_ENV']); } else { $_ENV['APP_ENV'] = $original; } } } }