Exemple #1
0
 /**
  * Assert that the indention only indents when there was actual output on the
  * previous indention level
  *
  * @return void
  */
 public function testIndention()
 {
     $n = PHP_EOL;
     $expected = 'Cosmological Constant' . $n . '  Einstein, the frizzy-haired,' . $n . '  said E equals MC squared.' . $n . '  Thus all mass decreases' . $n . '  as activity ceases?' . $n . '    Not my mass, my ass declared!' . $n . '- Michael R. Burch' . $n;
     ob_start();
     $stream = fopen('php://output', 'rw');
     $output = new Output($stream);
     $output->indent();
     $output->writeln('Cosmological Constant');
     $output->indent();
     $output->writeln('Einstein, the frizzy-haired,');
     $output->writeln('said E equals MC squared.');
     $output->indent();
     $output->outdent();
     $output->writeln('Thus all mass decreases');
     $output->writeln('as activity ceases?');
     $output->indent();
     $output->indent();
     $output->writeln('Not my mass, my ass declared!');
     $output->outdent();
     $output->outdent();
     $output->outdent();
     $output->outdent();
     $output->writeln('- Michael R. Burch');
     $this->assertEquals($expected, ob_get_clean());
 }
Exemple #2
0
 /**
  * Load the configuration
  *
  * @return void
  */
 protected function loadConfig()
 {
     $this->config = new Config();
     $expectedFile = 'kite.php';
     $app = null;
     $indicators = ['TYPO3' => ['typo3conf', 'Kite.php'], 'Magento' => ['app/etc', 'kite.php']];
     foreach ($indicators as $appName => $dirAndFile) {
         list($dir, $file) = $dirAndFile;
         if (is_dir($dir)) {
             $app = $appName;
             $expectedFile = $dir . '/' . $file;
             break;
         }
     }
     try {
         $this->config->loadConfigFile($expectedFile);
     } catch (\Exception $e) {
         if ($app) {
             $message = ['You appear to be in a ' . $app . ' root directory but', 'there is no kite config file at the expected', 'location (' . $expectedFile . ').'];
         } else {
             $message = ['You are either not in an application root directory or', 'you have no appropriate config file yet.', '', 'The config file path is expected to be:'];
             foreach ($indicators as $appName => $dirAndFile) {
                 $message[] = '  - "' . implode('/', $dirAndFile) . '" for ' . $appName . ' applications or';
             }
             $message[] = '  - "' . $expectedFile . '" for any other application';
         }
         $lMax = 0;
         foreach ($message as $line) {
             if (($l = strlen($line)) > $lMax) {
                 $lMax = $l;
             }
         }
         $this->output->writeln('<warning>' . str_repeat(' ', $lMax + 4) . '</warning>');
         foreach ($message as $line) {
             $line = str_pad($line, $lMax + 2);
             $this->output->writeln("<warning>  {$line}</warning>");
         }
         $this->output->writeln('<warning>' . str_repeat(' ', $lMax + 4) . '</warning>');
     }
 }