$lines++; } if ($_v >= 1) { $total++; } } $avg[$file] = round($total / $lines * 100, 2); } else { $avg[$file] = 0; } }, $_file); } $total = 0.0; foreach ($avg as $_c) { $total += $_c; } \unittest\Output::send('--------------------', \unittest\Output::DEBUG, true); \unittest\Output::send(sprintf('Total Test Coverage : %s%%', round($total / (count($avg) * 100) * 100, 2)), \unittest\Output::DEBUG, true); \unittest\Output::send('--------------------', \unittest\Output::DEBUG, true); foreach ($avg as $_k => $_c) { \unittest\Output::send(sprintf('File : %s', $_k), \unittest\Output::DEBUG, true); \unittest\Output::send(sprintf('Coverage : %s%%', $_c), \unittest\Output::DEBUG, true); \unittest\Output::send('--------------------', \unittest\Output::DEBUG, true); } }); } xp_import("unittest"); // load the standard unittest output unittest\generate_output(); // make sure we save the event history xp_set_signal_history(true);
/** * Calls an assertion function. * * @return boolean true */ public function __call($func, $args) { $this->_assertions_ran[] = $func; if ($this->_failed && SKIP_TESTS_ON_FAILURE) { Output::instance()->assertion($this, $func, $args, null); return false; } else { try { $call = Assertions::instance()->call_assertion($func, $args, $this); } catch (\BadMethodCallException $e) { $call = null; Output::instance()->unknown_assertion($this, $func, $args, Assertions::instance()); } if ($call !== true) { $this->_failed = true; } Output::instance()->assertion($this, $func, $args, $call); } // Add call to results $this->_assertion_results[] = [$call, $func, $args, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)]; return $call; }