我配置了一个如下的Symfony控制台命令:
protected function configure()
{
$this
->setName('crmpiccobundle:list:sync')
->setDescription('Sync users to the list')
->addOption(
'filepath',
null,
InputOption::VALUE_OPTIONAL,
'The path to the file',
null
)
;
}
我有一个关于IT技术的问题需要翻译,以下是需要翻译的内容:
...而且我有一个PHPUnit测试,如下所示:
public function testExecuteWhenFileIsEmpty()
{
self::bootKernel();
$application = new Application(self::$kernel);
$application->add(new Sync());
$command = $application->find('crmpiccobundle:list:sync');
$commandTester = new CommandTester($command);
$commandTester->execute([
'command' => $command->getName(),
'filepath' => '/tmp/crmpicco.co.uk.csv'
]);
}
当我运行它时,出现以下错误:
InvalidArgumentException: "filepath"参数不存在。
我的问题是 - 我如何将一个选项传递给CommandTester?传递参数很好,但我找不到有关如何为选项做到这一点的文档。
'--filepath' => '/tmp/crmpicco.co.uk.csv'
吗? - Matteo