Exemplo n.º 1
0
 /**
  * @return void
  **/
 public function testParameterDefinition()
 {
     // Note leading slashes in some
     $structure = new Structure();
     $structure->directory('foo')->file('bar')->parameter('foo', 'The foo parameter')->parameter('bar', 'The bar parameter');
     $this->assertInstanceOf('Naneau\\FileGen\\Directory', $structure->scan('foo'));
     $this->assertInstanceOf('Naneau\\FileGen\\File', $structure->scan('bar'));
     $this->assertInstanceOf('Naneau\\FileGen\\Parameter\\Parameter', $structure->getParameterDefinition()->get('foo'));
     $this->assertInstanceOf('Naneau\\FileGen\\Parameter\\Parameter', $structure->getParameterDefinition()->get('bar'));
 }
Exemplo n.º 2
0
 /**
  * Ask for a parameter's value
  *
  * @param  Structure           $structure
  * @param  InputInterface      $input
  * @param  OutputInterface     $output
  * @return array[string]string the parameter set as a key/value hash for use in a generator
  **/
 public function askParameters(Structure $structure, InputInterface $input, OutputInterface $output)
 {
     $parameters = array();
     foreach ($structure->getParameterDefinition() as $parameter) {
         $parameters[$parameter->getName()] = $this->askParameter($parameter, $input, $output);
     }
     return $parameters;
 }
Exemplo n.º 3
0
 public function testExecute()
 {
     $application = new Application();
     $application->getHelperSet()->set(new ParameterHelper(), 'filegenParameters');
     $command = new ParameterCommand();
     $application->add($command);
     $structure = new Structure();
     $structure->parameter('foo', 'foo description')->parameter('bar', 'bar description')->parameter('baz', 'baz description');
     $structure->getParameterDefinition()->get('baz')->setDefaultValue('BazValue');
     $command->setStructure($structure);
     $commandTester = new CommandTester($command);
     // Set the input stream
     $helper = $command->getHelper('question');
     $helper->setInputStream($this->getInputStream("FooValue\nBarValue\n\n"));
     $commandTester->execute(array('command' => $command->getName()));
     $this->assertEquals('foo descriptionbar descriptionbaz description', $commandTester->getDisplay());
     $received = $command->getReceived();
     $this->assertArrayHasKey('foo', $received);
     $this->assertEquals('FooValue', $received['foo']);
     $this->assertArrayHasKey('bar', $received);
     $this->assertEquals('BarValue', $received['bar']);
     $this->assertArrayHasKey('baz', $received);
     $this->assertEquals('BazValue', $received['baz']);
 }