示例#1
0
 protected function execute(array $arguments = array(), array $options = array())
 {
     $filename = isset($options['filename']) ? $options['filename'] : null;
     $printer = new nbConfigurationPrinter();
     $printer->addConfiguration(nbConfig::getAll());
     if ($filename) {
         $this->logLine(sprintf('bee configuration (file: %s)', $filename), nbLogger::COMMENT);
         $printer->addConfigurationFile($filename);
     } else {
         $dirs = array('./', nbConfig::get('nb_config_dir'));
         $this->logLine(sprintf('bee configuration (dirs: %s)', implode(', ', $dirs)), nbLogger::COMMENT);
         $finder = nbFileFinder::create('file')->add('*.yml')->maxdepth(0);
         foreach ($dirs as $dir) {
             $files = $finder->in($dir);
             foreach ($files as $file) {
                 $this->logLine('Adding ' . $file, nbLogger::COMMENT);
                 $printer->addConfigurationFile($file);
             }
         }
     }
     $this->logLine($printer->printAll());
     return true;
 }
示例#2
0
    $t->pass('No config file to print exists');
}
$text = '
app_required_child_field: value
app_required_field: text
app_param1: value4
app_dir1: test/data/system
app_file1: test/data/system/Class.java
app_array: 
  0: 
    key1: value4
  1: 
    key2: field2';
$t->is(removeCarriageReturn($printer->printAll()), removeCarriageReturn($text), 'Printed text is formatted correctly');
$printer = new nbConfigurationPrinter();
$printer->addConfigurationFile($configFileNoChild);
$text = '
app_required_child_field: <error>required</error>
app_required_field: value
app_param3: value3
app_dir1: <error>dir_exists</error>
app_file1: <error>file_exists</error>';
$errors = array('app_required_child_field' => 'required', 'app_dir1' => 'dir_exists', 'app_file1' => 'file_exists');
$printer->addConfigurationErrors($errors);
$t->is(removeCarriageReturn($printer->printAll()), removeCarriageReturn($text), 'Printed text is formatted correctly with errors');
function removeCarriageReturn($text)
{
    $text = str_replace("\r", '', $text);
    $text = str_replace("\n", '|', $text);
    return $text;
}