public function testCreateWithArguments() { $applicationConfig = new ApplicationConfig(); $parentConfig = new CommandConfig('command', $applicationConfig); $config = new SubCommandConfig('sub-command', $parentConfig, $applicationConfig); $this->assertSame($parentConfig, $config->getParentConfig()); $this->assertSame($applicationConfig, $config->getApplicationConfig()); $this->assertSame('sub-command', $config->getName()); }
private function validateSubCommandName(SubCommandConfig $config) { $name = $config->getName(); if (!$name) { throw CannotAddCommandException::nameEmpty(); } if ($this->subCommands->contains($name)) { throw CannotAddCommandException::nameExists($name); } if ($config instanceof OptionCommandConfig) { if ($this->argsFormat->hasOption($name)) { throw CannotAddCommandException::optionExists($name); } if ($shortName = $config->getShortName()) { if ($this->subCommands->contains($shortName)) { throw CannotAddCommandException::nameExists($name); } if ($this->argsFormat->hasOption($shortName)) { throw CannotAddCommandException::optionExists($shortName); } } } }