Beispiel #1
0
 /**
  * respond information to the user
  * 
  * @return void
  */
 public function respond()
 {
     $inspector = $this->inspector;
     CCCli::write("\n" . $inspector->exception_name() . ': ', 'red');
     CCCli::line($inspector->message());
     CCCli::line($inspector->exception()->getFile() . ':' . $inspector->exception()->getLine());
 }
Beispiel #2
0
 *
 * By default the the environment detector defines the current 
 * environment. But you can force another one using the this var.
 */
$environment = 'phpunit';
/*
 *---------------------------------------------------------------
 * Require CCF
 *---------------------------------------------------------------
 *
 * load the framework file wich wil initialize CCF. 
 */
require_once __DIR__ . "/../framework.php";
/*
 *---------------------------------------------------------------
 * CCUnit resources
 *---------------------------------------------------------------
 *
 * For the unit tests we need some additional resources like
 * controllers, views, ect... 
 */
CCOrbit::enter(COREPATH . 'orbit/CCUnit');
// write header
CCCli::line("==============================\n    _____ _____ ______ \n   / ____/ ____|  ____|\n  | |   | |    | |__   \n  | |   | |    |  __|  \n  | |___| |____| |     \n   \\_____\\_____|_| ramework\n==============================\n", 'cyan');
// complete overwrite of DB configuration
CCConfig::create('database')->_data = CCConfig::create('Core::phpunit/database')->_data;
// delete all database table
DB\Migrator::hard_reset();
DB\Migrator::hard_reset('phpunit');
// run the migrations
DB\Migrator::migrate(true);
Beispiel #3
0
 /**
  * Delete a file
  * This function is going to remove a file from your filesystem
  *
  * @param string 	$path
  * @return bool
  */
 public static function delete($path)
 {
     $success = false;
     if (file_exists($path)) {
         $success = unlink($path);
     }
     if (static::_can_print()) {
         if ($success) {
             CCCli::line(CCCli::color('removed', 'green') . ' ' . $path);
         } else {
             CCCli::line(CCCli::color('removing failure', 'red') . ' ' . $path);
         }
     }
     return $success;
 }
Beispiel #4
0
 /**
  * Migrates the current migration down
  *
  * @return void
  */
 public function down()
 {
     \CCCli::info($this->name . '...', 'reverting');
     $this->run_queries('down');
 }
Beispiel #5
0
 /**
  * default help formatter
  *
  * @param array 		$params
  * @return void
  */
 protected function help_formatter($help = null)
 {
     if (is_null($help)) {
         CCCli::line('Invalid data passed to help formatter.', 'red');
         return;
     }
     $output = array();
     // print the name
     if (isset($help['name'])) {
         $output[] = '+-' . str_repeat('-', strlen($help['name'])) . '-+';
         $output[] = '| ' . CCCli::color($help['name'], 'light_yellow') . ' |';
         $output[] = '+-' . str_repeat('-', strlen($help['name'])) . '-+';
     }
     // description
     if (isset($help['desc'])) {
         $output[] = wordwrap(str_replace("\n", "\n" . ' * ', $help['desc']), 60);
     }
     // list the actions
     if (isset($help['actions']) && !empty($help['actions'])) {
         // for every action in this console controller
         foreach ($help['actions'] as $action => $attributes) {
             // print the action
             $output[] = '';
             $output[] = '| ' . CCStr::suffix(get_called_class(), '\\') . '::' . CCCli::color($action, 'cyan');
             $output[] = '|';
             // for every attribute ( arguments, usage etc. )
             foreach ($attributes as $attribute => $options) {
                 $output[] = '| ' . CCCli::color(ucfirst($attribute), 'light_yellow');
                 // if we just got a string
                 if (is_string($options)) {
                     $output[] = '|  ' . CCCli::color($options, 'green');
                 } elseif (is_array($options)) {
                     // print every option and its description
                     foreach ($options as $option => $description) {
                         $buffer = CCCli::color($option, 'green');
                         $buffer .= str_repeat(' ', 35 - strlen($buffer));
                         $buffer .= $description;
                         $buffer = '|  ' . $buffer;
                         // is the line to long?
                         if (strlen($buffer) > 80) {
                             $overflow = substr($buffer, 80);
                             $buffer = substr($buffer, 0, 80) . "\n";
                             $overflow = wordwrap($overflow, 45);
                             $overflow = explode("\n", $overflow);
                             foreach ($overflow as $key => $value) {
                                 $overflow[$key] = '| ' . str_repeat(' ', 25) . trim($value);
                             }
                             $buffer .= implode("\n", $overflow);
                         }
                         $output[] = $buffer;
                     }
                 }
                 $output[] = '|';
             }
             array_pop($output);
         }
     }
     return $output;
 }