debug_out() public static method

public static debug_out ( $str )
Example #1
0
 /**
  * Run the registered tests, and output a report
  *
  * @param boolean $report whether or not to output a report after tests run. Default true.
  * @param string $filter optional test case name filter
  * @see FUnit::run_tests()
  * @see FUnit::report()
  */
 public static function run($report = true, $filter = null, $report_format = null)
 {
     // create a new current suite if needed
     static::check_current_suite();
     // get the suite
     $suite = static::get_current_suite();
     if (static::$disable_run) {
         FUnit::debug_out("Not running tests because of \$disable_run");
         return;
     }
     // set handlers
     $old_error_handler = set_error_handler('\\FUnit::error_handler');
     // run the tests in the suite
     FUnit::debug_out("Running tests in suite '" . $suite->getName() . "'");
     $run_tests = $suite->run($filter);
     if (static::$disable_reporting) {
         FUnit::debug_out("Reporting disabled");
         $report = false;
     }
     if ($report) {
         FUnit::debug_out("Printing report for tests run in suite '" . $suite->getName() . "'");
         static::report($report_format, $run_tests);
     } else {
         FUnit::debug_out("Not printing report for tests run in suite '" . $suite->getName() . "'");
     }
     // add this suite's data to the static $all_run_tests
     static::$all_run_tests = array_merge(static::$all_run_tests, $run_tests);
     // restore handlers
     if ($old_error_handler) {
         set_error_handler($old_error_handler);
     }
     $exit_code = $suite->getExitCode();
     static::$current_suite_name = null;
     return $exit_code;
 }
Example #2
0
 /**
  * @see \FUnit::run_tests()
  * @return [type] [description]
  */
 public function runTests($filter = null)
 {
     // before
     if (isset($this->before_func)) {
         \FUnit::debug_out("running before for suite '{$this->name}'");
         $before_func = $this->before_func;
         $before_func();
         unset($before_func);
     }
     foreach ($this->tests as $name => &$test) {
         if (is_null($filter) || stripos($name, $filter) !== false) {
             $this->runTest($name);
         } else {
             $this->tests[$name]['skipped'] = true;
             \FUnit::debug_out("skipping test {$name} due to filter '{$filter}'");
         }
     }
     // after
     if (isset($this->after_func)) {
         \FUnit::debug_out("running after for suite '{$this->name}'");
         $after_func = $this->after_func;
         $after_func();
         unset($after_func);
     }
     return $this->tests;
 }