當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ArrayInput::bind方法代碼示例

本文整理匯總了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);
             }
         }
     }
 }
開發者ID:mistymagich,項目名稱:gush,代碼行數:26,代碼來源:HelpCommand.php

示例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, '');
 }
開發者ID:inetprocess,項目名稱:sugarcli,代碼行數:11,代碼來源:AbstractInventoryCommandTest.php

示例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)));
 }
開發者ID:hongtien510,項目名稱:phalcon_dev_tool,代碼行數:8,代碼來源:ConfigurableTest.php

示例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;
 }
開發者ID:farukuzun,項目名稱:core-1,代碼行數:12,代碼來源:commandtest.php

示例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);
     }
 }
開發者ID:nike,項目名稱:beez,代碼行數:13,代碼來源:CompositeCommand.php

示例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');
     }
 }
開發者ID:yamildiego,項目名稱:JY,代碼行數:19,代碼來源:InputTest.php

示例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());
 }
開發者ID:TheTypoMaster,項目名稱:SPHERE-Framework,代碼行數:6,代碼來源:InputTest.php

示例8: buildInput

 /**
  * buildInput.
  *
  * @param $array
  *
  * @return InputInterface
  */
 protected function buildInput($array)
 {
     $input = new ArrayInput($array);
     $input->bind((new LicenserCommand())->getDefinition());
     return $input;
 }
開發者ID:rafrsr,項目名稱:licenser,代碼行數:13,代碼來源:ConfigFactoryTest.php

示例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);
 }
開發者ID:maartenstaa,項目名稱:phpta,代碼行數:17,代碼來源:CommandTest.php


注:本文中的Symfony\Component\Console\Input\ArrayInput::bind方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。