runCommand($command, $args); foreach ((array) $strings as $string) { $this->assertStringContainsString( $string, $output, \sprintf( 'Console command [%s] with args [%s] does not contain string [%s]', $command, json_encode($args, JSON_THROW_ON_ERROR), $string, ), ); } } public function assertCommandRegistered(string $name): void { $this->assertTrue( $this->getConsole()->getApplication()->has($name), \sprintf('Command [%s] is not registered.', $name), ); } final public function runCommand( string $command, array $args = [], ?OutputInterface $output = null, ?int $verbosityLevel = null, ): string { $input = new ArrayInput($args); $input->setInteractive(false); $output = $output ?? new BufferedOutput(); /** @psalm-suppress ArgumentTypeCoercion */ $output->setVerbosity($verbosityLevel ?? $this->defaultVerbosityLevel); $this->getConsole()->run($command, $input, $output); return $output->fetch(); } final public function getConsole(): Console { return $this->getContainer()->get(Console::class); } }