当前位置: 首页>>代码示例>>PHP>>正文


PHP ArgvInput::setOption方法代码示例

本文整理汇总了PHP中Symfony\Component\Console\Input\ArgvInput::setOption方法的典型用法代码示例。如果您正苦于以下问题:PHP ArgvInput::setOption方法的具体用法?PHP ArgvInput::setOption怎么用?PHP ArgvInput::setOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Console\Input\ArgvInput的用法示例。


在下文中一共展示了ArgvInput::setOption方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testExecute_SpecificEntity_Association

 /**
  * @see FixturesExportCommand::execute
  */
 public function testExecute_SpecificEntity_Association()
 {
     $directoryPath = sys_get_temp_dir();
     $dumper = $this->getMockBuilder('\\Cosma\\Bundle\\TestingBundle\\Fixture\\Dumper')->disableOriginalConstructor()->setMethods(['dumpToYaml', 'setAssociation', 'setClassMetadataInfo'])->getMock();
     $dumper->expects($this->once())->method('dumpToYaml')->with($directoryPath)->will($this->returnValue($directoryPath . '/table.yml'));
     $dumper->expects($this->once())->method('setAssociation')->with(true)->will($this->returnValue(null));
     $classMetaDataInfo = $this->getMockBuilder('\\Doctrine\\ORM\\Mapping\\ClassMetadataInfo')->disableOriginalConstructor()->getMock();
     $dumper->expects($this->once())->method('setClassMetadataInfo')->with($classMetaDataInfo)->will($this->returnValue(null));
     $metaDataFactory = $this->getMockBuilder('\\Doctrine\\Common\\Persistence\\Mapping\\ClassMetadataFactory')->disableOriginalConstructor()->setMethods(['getMetadataFor'])->getMockForAbstractClass();
     $metaDataFactory->expects($this->once())->method('getMetadataFor')->with('BundleName:EntityName')->will($this->returnValue($classMetaDataInfo));
     $entityManager = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->setMethods(['getMetadataFactory'])->getMock();
     $entityManager->expects($this->once())->method('getMetadataFactory')->will($this->returnValue($metaDataFactory));
     $doctrine = $this->getMockBuilder('\\Doctrine\\Bundle\\DoctrineBundle\\Registry')->disableOriginalConstructor()->setMethods(['getManager'])->getMock();
     $doctrine->expects($this->once())->method('getManager')->will($this->returnValue($entityManager));
     $container = new Container();
     $container->set('doctrine', $doctrine);
     $container->set('cosma_testing.fixture_dumper', $dumper);
     $command = $this->getMockBuilder('\\Cosma\\Bundle\\TestingBundle\\Command\\FixturesExportCommand')->disableOriginalConstructor()->setMethods(['getContainer'])->getMock();
     $command->expects($this->exactly(2))->method('getContainer')->will($this->returnValue($container));
     $reflectionClass = new \ReflectionClass($command);
     $dumperProperty = $reflectionClass->getParentClass()->getProperty('dumper');
     $dumperProperty->setAccessible(true);
     $dumperProperty->setValue($command, $dumper);
     $inputDefinition = new InputDefinition([new InputArgument('dumpDirectory', InputArgument::REQUIRED), new InputArgument('entity', InputArgument::OPTIONAL), new InputOption('associations', 'a', InputOption::VALUE_NONE)]);
     $input = new ArgvInput(['dummySoInputValidates' => 'dummy', 'dumpDirectory' => $directoryPath, 'entity' => 'BundleName:EntityName'], $inputDefinition);
     $input->setOption('associations', true);
     $output = new BufferedOutput();
     $reflectionClass = new \ReflectionClass($command);
     $executeMethod = $reflectionClass->getMethod('execute');
     $executeMethod->setAccessible(true);
     $executeMethod->invoke($command, $input, $output);
     $this->assertContains("successfully dumped in file  {$directoryPath}/table.yml", $output->fetch(), 'The entity was not dump successfully');
 }
开发者ID:stevepop,项目名称:testing-bundle,代码行数:36,代码来源:FixturesExportCommandTest.php

示例2: runLocateFile

 /**
  * Do the locateFile Action
  *
  * @param $arg
  * @param $dir
  * @return string
  */
 protected function runLocateFile($arg, $dir)
 {
     chdir($this->baseDir . '/' . $dir);
     $definition = new InputDefinition(array(new InputOption('configuration')));
     $input = new ArgvInput(array(), $definition);
     if ($arg) {
         $input->setOption('configuration', $arg);
     }
     $command = new VoidCommand('void');
     return $command->locateConfigFile($input);
 }
开发者ID:Slayug,项目名称:castor,代码行数:18,代码来源:ConfigFileTest.php

示例3: ArgvInput

 /**
  * Handles the brood default options/arguments.
  */
 public static final function ArgvInput()
 {
     # get the raw commands
     $raws = ['--env', '--timeout'];
     # get the options from Brood
     $options = [Brood::environmentOption(), Brood::timeoutOption()];
     $instances = [];
     $reflect = new ReflectionClass(InputOption::class);
     foreach ($options as $opt) {
         $instances[] = $reflect->newInstanceArgs($opt);
     }
     # still, listen to the php $_SERVER['argv']
     $cmd_input = new ArgvInput();
     # get the default brood options
     $brood_input = new ArgvInput($raws, new InputDefinition($instances));
     foreach ($raws as $raw) {
         if ($cmd_input->hasParameterOption([$raw])) {
             $val = $cmd_input->getParameterOption($raw);
             $val = is_numeric($val) ? (int) $val : $val;
             $brood_input->setOption(str_replace('-', '', $raw), $val);
         }
     }
     return $brood_input;
 }
开发者ID:phalconslayer,项目名称:framework,代码行数:27,代码来源:CLI.php


注:本文中的Symfony\Component\Console\Input\ArgvInput::setOption方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。