public function testSetAliases() { $this->config->addAlias('alias1'); $this->config->setAliases(array('alias2', 'alias3')); $this->assertSame(array('alias2', 'alias3'), $this->config->getAliases()); }
/** * Creates a new command. * * @param CommandConfig $config The command configuration. * @param Application $application The console application. * @param Command $parentCommand The parent command. * * @throws LogicException If the name of the command configuration is not set. */ public function __construct(CommandConfig $config, Application $application = null, Command $parentCommand = null) { if (!$config->getName()) { throw new LogicException('The name of the command config must be set.'); } $this->name = $config->getName(); $this->shortName = $config instanceof OptionCommandConfig ? $config->getShortName() : null; $this->aliases = $config->getAliases(); $this->config = $config; $this->application = $application; $this->parentCommand = $parentCommand; $this->subCommands = new CommandCollection(); $this->namedSubCommands = new CommandCollection(); $this->defaultSubCommands = new CommandCollection(); $this->argsFormat = $config->buildArgsFormat($this->getBaseFormat()); $this->dispatcher = $application ? $application->getConfig()->getEventDispatcher() : null; foreach ($config->getSubCommandConfigs() as $subConfig) { $this->addSubCommand($subConfig); } }