本文整理汇总了PHP中Symfony\Component\Console\Input\ArrayInput::bind方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayInput::bind方法的具体用法?PHP ArrayInput::bind怎么用?PHP ArrayInput::bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Input\ArrayInput
的用法示例。
在下文中一共展示了ArrayInput::bind方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateCommandDefinition
private function updateCommandDefinition(Command $command, OutputInterface $output)
{
$eventDispatcher = $this->getApplication()->getDispatcher();
$input = new ArrayInput(['command' => $command->getName()]);
$event = new ConsoleCommandEvent($command, $input, $output);
$eventDispatcher->dispatch(GushEvents::DECORATE_DEFINITION, $event);
$command->getSynopsis(true);
$command->getSynopsis(false);
$command->mergeApplicationDefinition();
try {
$input->bind($command->getDefinition());
} catch (\Exception $e) {
$output->writeln('<error>Something went wrong: </error>' . $e->getMessage());
return;
}
$eventDispatcher->dispatch(GushEvents::INITIALIZE, $event);
// The options were set on the input but now we need to set them on the Command definition
if ($options = $input->getOptions()) {
foreach ($options as $name => $value) {
$option = $command->getDefinition()->getOption($name);
if ($option->acceptValue()) {
$option->setDefault($value);
}
}
}
}
示例2: testGetCustomFactsInvalid
/**
* @expectedException InvalidArgumentException
* @expectedExceptionMessage Invalid format for --custom-fact 'foobar'
*/
public function testGetCustomFactsInvalid()
{
$mock = $this->getMockForAbstractClass('SugarCli\\Console\\Command\\Inventory\\AbstractInventoryCommand', array('test'));
$input = new ArrayInput(array('--custom-fact' => array('foobar')));
$input->bind($mock->getDefinition());
$mock->getCustomFacts($input, '');
}
示例3: testGetConfig
public function testGetConfig()
{
file_put_contents('box.json', '{}');
$command = $this->app->get('test');
$input = new ArrayInput(array());
$input->bind($command->getDefinition());
$this->assertInstanceOf('KevinGH\\Box\\Configuration', $this->callMethod($command, 'getConfig', array($input)));
}
示例4: getInput
protected function getInput(Command $command, array $arguments = [], array $options = [])
{
$input = new ArrayInput([]);
$input->bind($command->getDefinition());
foreach ($arguments as $key => $value) {
$input->setArgument($key, $value);
}
foreach ($options as $key => $value) {
$input->setOption($key, $value);
}
return $input;
}
示例5: addCommandArray
protected function addCommandArray(array $args, OutputInterface $output)
{
$command = $this->getApplication()->find($args['command']);
if ($command instanceof CompositeCommand) {
unset($args['command']);
$input = new ArrayInput($args);
$input->bind($command->getDefinition());
$command->initialize($input, $output);
} else {
$input = new ArrayInput($args);
self::$commands[] = array('command' => $command, 'input' => $input);
}
}
示例6: testValidate
public function testValidate()
{
$input = new ArrayInput(array());
$input->bind(new InputDefinition(array(new InputArgument('name', InputArgument::REQUIRED))));
try {
$input->validate();
$this->fail('->validate() throws a \\RuntimeException if not enough arguments are given');
} catch (\Exception $e) {
$this->assertInstanceOf('\\RuntimeException', $e, '->validate() throws a \\RuntimeException if not enough arguments are given');
$this->assertEquals('Not enough arguments.', $e->getMessage());
}
$input = new ArrayInput(array('name' => 'foo'));
$input->bind(new InputDefinition(array(new InputArgument('name', InputArgument::REQUIRED))));
try {
$input->validate();
} catch (\RuntimeException $e) {
$this->fail('->validate() does not throw a \\RuntimeException if enough arguments are given');
}
}
示例7: testValidate
public function testValidate()
{
$input = new ArrayInput(array('name' => 'foo'));
$input->bind(new InputDefinition(array(new InputArgument('name', InputArgument::REQUIRED))));
$this->assertNull($input->validate());
}
示例8: buildInput
/**
* buildInput.
*
* @param $array
*
* @return InputInterface
*/
protected function buildInput($array)
{
$input = new ArrayInput($array);
$input->bind((new LicenserCommand())->getDefinition());
return $input;
}
示例9: testGetConfigurationFileDoesNotExist
/**
* @covers ::getConfiguration
* @expectedException InvalidArgumentException
* @expectedExceptionMessage The configuration file "foo.bar" could not be found.
*/
public function testGetConfigurationFileDoesNotExist()
{
$mock = $this->getMockBuilder('MaartenStaa\\PHPTA\\CLI\\Command')->setMethods(array('getFilesystem'))->getMock();
$fs = $this->getMockBuilder('Illuminate\\Filesystem\\Filesystem')->setMethods(array('isFile'))->getMock();
$mock->expects($this->once())->method('getFilesystem')->will($this->returnValue($fs));
$fs->expects($this->once())->method('isFile')->with('foo.bar')->will($this->returnValue(false));
$input = new ArrayInput(array());
$input->bind($mock->getDefinition());
$input->setOption('config', 'foo.bar');
$output = new StreamOutput(fopen('php://memory', 'w', false));
$mock->getConfiguration($input, $output);
}