function testSetOptionName()
 {
     //arrange
     $name = "peanut allergy";
     $test_allergy = new Option($name);
     //act
     $test_allergy->setName("peanut allergy");
     $result = $test_allergy->getName();
     //assert
     $this->assertEquals("peanut allergy", $result);
 }
Example #2
0
 /**
  * @param $renderApi
  * @param $unit
  * @return IOptionProvider
  */
 public function getListOptions($renderApi, $unit)
 {
     $options = preg_split('/\\n/', $renderApi->getFormValue($unit, 'listFieldOptions'));
     foreach ($options as $option) {
         $checked = false;
         if (preg_match('/\\*$/', $option)) {
             $checked = true;
             $option = preg_replace('/\\*$/', '', $option);
         }
         $optionObj = new \Option();
         $optionObj->setName($option);
         $optionObj->setValue($option);
         $optionObj->setChecked($checked);
         $this->optionProvider->addOption($optionObj);
     }
     return $this->optionProvider;
 }
Example #3
0
 /**
  * @covers Phossa\Console\Option::setName
  */
 public function testSetName()
 {
     $this->object->setName('test');
     $this->assertEquals('test', $this->object->getName());
 }
Example #4
0
 /**
  * The main entry point method.
  */
 public function main()
 {
     $command = array();
     $command[] = !empty($this->bin) ? $this->bin : 'drush';
     if (!empty($this->alias)) {
         $command[] = $this->alias;
     }
     if (empty($this->color)) {
         $option = new Option();
         $option->setName('nocolor');
         $this->options[] = $option;
     }
     if (!empty($this->root)) {
         $option = new Option();
         $option->setName('root');
         $option->addText($this->root);
         $this->options[] = $option;
     }
     if (!empty($this->uri)) {
         $option = new Option();
         $option->setName('uri');
         $option->addText($this->uri);
         $this->options[] = $option;
     }
     if (!empty($this->config)) {
         $option = new Option();
         $option->setName('config');
         $option->addText($this->config);
         $this->options[] = $option;
     }
     if (!empty($this->aliasPath)) {
         $option = new Option();
         $option->setName('alias-path');
         $option->addText($this->aliasPath);
         $this->options[] = $option;
     }
     if (is_bool($this->assume)) {
         $option = new Option();
         $option->setName($this->assume ? 'yes' : 'no');
         $this->options[] = $option;
     }
     if ($this->simulate) {
         $option = new Option();
         $option->setName('simulate');
         $this->options[] = $option;
     }
     if ($this->pipe) {
         $option = new Option();
         $option->setName('pipe');
         $this->options[] = $option;
     }
     if ($this->verbose) {
         $option = new Option();
         $option->setName('verbose');
         $this->options[] = $option;
     }
     foreach ($this->options as $option) {
         $command[] = $option->toString();
     }
     $command[] = $this->command;
     foreach ($this->params as $param) {
         $command[] = '"' . escapeshellcmd($param->getValue()) . '"';
     }
     $command = implode(' ', $command);
     if ($this->dir !== NULL) {
         $currdir = getcwd();
         @chdir($this->dir->getPath());
     }
     // Execute Drush.
     $this->log("Executing '{$command}'...");
     $output = array();
     exec($command, $output, $return);
     if (isset($currdir)) {
         @chdir($currdir);
     }
     // Collect Drush output for display through Phing's log.
     foreach ($output as $line) {
         $this->log($line);
     }
     // Set value of the 'pipe' property.
     if (!empty($this->returnProperty)) {
         $this->getProject()->setProperty($this->returnProperty, implode($this->returnGlue, $output));
     }
     // Build fail.
     if ($this->haltOnError && $return != 0) {
         throw new \BuildException("Drush exited with code {$return}");
     }
     return $return != 0;
 }