Ejemplo n.º 1
0
 /**
  * @param Command $command
  * @param mixed   $options
  *
  * @return array The given options or the options converted into an array
  *
  * @throws UnsupportedException                                                 If options isn't an array and cannot be converted
  * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException If any of the passed options has not been defined or does not contain an allowed value
  * @throws \Symfony\Component\OptionsResolver\Exception\MissingOptionsException If a required option is missing
  *
  * @api
  */
 public function resolve(Command $command, $options)
 {
     if (!is_array($options)) {
         $options = $this->convert($options);
     }
     $resolver = new OptionsResolver();
     $command->configure($resolver);
     $resolver->resolve($options);
 }
Ejemplo n.º 2
0
 function it_throws_when_unsupported_type(Command $command, Converter $converter)
 {
     $input = new \StdClass();
     $options = array('content' => 'No one expects the Spanish Inquisition!');
     $this->addConverter($converter);
     $converter->supports($input)->willReturn(false);
     $optionsResolverType = 'Symfony\\Component\\OptionsResolver\\OptionsResolver';
     $command->configure(Argument::type($optionsResolverType))->shouldNotBeCalled();
     $invalidOptionsExceptionType = 'Gnugat\\Ordono\\UnsupportedException';
     $this->shouldThrow($invalidOptionsExceptionType)->duringResolve($command, $input);
 }