$application = new Application(); $application->add(new MyCommand()); $command = $application->find('my:command'); $commandTester = new CommandTester($command); $commandTester->execute([ 'argument' => 'value', ]); $status = $commandTester->getStatusCode();
$kernel = new AppKernel('test', true); $application = new Application($kernel); $command = $application->find('my:command'); $commandTester = new CommandTester($command); $commandTester->execute([ 'argument' => 'value', ]); $status = $commandTester->getStatusCode();In this example, we create a new Symfony kernel, instantiate the console application with the kernel, and execute the command with some arguments. The package/library for this class is Symfony\Component\Console\Tester.