我想建立一个订单,让我明确:缓存测试模式,然后在测试模式下删除数据库,删除scheama,添加scheme,添加fixture。
class BaseCommand extends SymfonyComponentConsoleCommandCommand {
//put your code here
protected function configure()
{
$this
->setName('mycommand:test')
->setDescription('Launch test')
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$command_first_migration = $this->getApplication()->find('cache:clear');
$arguments_first_migration = array(
'command' => 'cache:clean',
'--env' => 'test'
);
$input_first_migration = new ArrayInput($arguments_first_migration);
try {
$returnCode = $command_first_migration->run($input_first_migration, $output);
} catch (DoctrineDBALMigrationsMigrationException $ex) {
echo "MigrationExcepion !!!! ";
}
}
}
但我得到了这样的结果:
clearing the case for the dev environment with debug true
如何在开发环境中通过测试?
感谢
您不能设置--env=test,因为在运行php-app/console mycommand:test时已经创建了内核和环境。
唯一的方法是在运行命令时指定env:
php app/console mycommand:test --env=test