Example #1
0
 public function testGetParameterOption()
 {
     $input = new ArrayInput(array('name' => 'Fabien', '--foo' => 'bar'));
     $this->assertEquals('bar', $input->getParameterOption('--foo'), '->getParameterOption() returns the option of specified name');
     $this->assertFalse($input->getParameterOption('--bar'), '->getParameterOption() returns the default if an option is not present in the passed parameters');
     $input = new ArrayInput(array('Fabien', '--foo' => 'bar'));
     $this->assertEquals('bar', $input->getParameterOption('--foo'), '->getParameterOption() returns the option of specified name');
     $input = new ArrayInput(array('--foo', '--', '--bar' => 'woop'));
     $this->assertEquals('woop', $input->getParameterOption('--bar'), '->getParameterOption() returns the correct value if an option is present in the passed parameters');
     $this->assertFalse($input->getParameterOption('--bar', false, true), '->getParameterOption() returns false if an option is present in the passed parameters after an end of options signal');
 }
 public function testGetParameterOption()
 {
     $input = new ArrayInput(array('name' => 'Fabien', '--foo' => 'bar'));
     $this->assertEquals('bar', $input->getParameterOption('--foo'), '->getParameterOption() returns the option of specified name');
     $input = new ArrayInput(array('Fabien', '--foo' => 'bar'));
     $this->assertEquals('bar', $input->getParameterOption('--foo'), '->getParameterOption() returns the option of specified name');
 }
Example #3
0
 /**
  * Runs the current application.
  *
  * @param InputInterface  $input  An Input instance
  * @param OutputInterface $output An Output instance
  *
  * @return integer 0 if everything went fine, or an error code
  */
 public function doRun(InputInterface $input, OutputInterface $output)
 {
     // xdebug's default nesting level of 100 is not enough
     if (extension_loaded('xdebug') && false === strpos(ini_get('disable_functions'), 'ini_set')) {
         $oldValue = ini_get('xdebug.max_nesting_level');
         if ($oldValue === false || $oldValue < 256) {
             ini_set('xdebug.max_nesting_level', 256);
         }
     }
     if ($input->hasParameterOption(array('--config-reference'))) {
         $input = new ArrayInput(array('--config-reference' => true));
     }
     if ($path = $input->getParameterOption(array('--config', '-c'))) {
         if (!is_file($path)) {
             throw new ConfigurationLoadingException("The requested config file does not exist");
         }
         $this->configurationLoader->setConfigurationFilePath($path);
     }
     $this->add($this->createCommand($input, $output));
     return parent::doRun($input, $output);
 }