";
$urlExtra = null;
if ($app) {
$buffer = "App Test Groups:
\n";
$urlExtra = '&app=true';
} else if ($plugin) {
$buffer = "" . Inflector::humanize($plugin) . " Test Groups:
\n";
$urlExtra = '&plugin=' . $plugin;
}
$buffer .= "- All tests
\n";
foreach ($groupTests as $groupTest) {
$buffer .= "- " . $groupTest . "
\n";
}
$buffer .= "
\n";
echo $buffer;
}
/**
* Send the headers necessary to ensure the page is
* reloaded on every request. Otherwise you could be
* scratching your head over out of date test data.
*
* @return void
*/
public function sendNoCacheHeaders() {
if (!headers_sent()) {
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
}
}
/**
* Paints the end of the test with a summary of
* the passes and failures.
*
* @param PHPUnit_Framework_TestResult $result Result object
* @return void
*/
public function paintFooter($result) {
$colour = ($result->failureCount() + $result->errorCount() > 0 ? "red" : "green");
echo "
\n";
echo "";
echo $result->count() . "/" . ($result->count() - $result->skippedCount());
echo " test methods complete:\n";
echo "" . count($result->passed()) . " passes, ";
echo "" . $result->failureCount() . " fails, ";
echo "" . $this->numAssertions . " assertions and ";
echo "" . $result->errorCount() . " exceptions.";
echo "
\n";
echo '';
echo '
Time taken by tests (in seconds): ' . $result->time() . '
';
if (function_exists('memory_get_peak_usage')) {
echo '
Peak memory use: (in bytes): ' . number_format(memory_get_peak_usage()) . '
';
}
echo $this->_paintLinks();
echo '
';
if (isset($this->params['codeCoverage']) && $this->params['codeCoverage']) {
$coverage = $result->getCodeCoverageInformation();
echo $this->paintCoverage($coverage);
}
$this->paintDocumentEnd();
}
/**
* Paints a code coverage report.
*
* @return void
*/
public function paintCoverage($coverage) {
$file = dirname(dirname(__FILE__)) . '/coverage/html_coverage_report.php';
include $file;
$reporter = new HtmlCoverageReport($coverage, $this);
echo $reporter->report();
}
/**
* Renders the links that for accessing things in the test suite.
*
* @return void
*/
protected function _paintLinks() {
$show = $query = array();
if (!empty($this->params['group'])) {
$show['show'] = 'groups';
} elseif (!empty($this->params['case'])) {
$show['show'] = 'cases';
}
if (!empty($this->params['app'])) {
$show['app'] = $query['app'] = 'true';
}
if (!empty($this->params['plugin'])) {
$show['plugin'] = $query['plugin'] = $this->params['plugin'];
}
if (!empty($this->params['case'])) {
$query['case'] = $this->params['case'];
} elseif (!empty($this->params['group'])) {
$query['group'] = $this->params['group'];
}
$show = $this->_queryString($show);
$query = $this->_queryString($query);
echo "Run more tests | Show Passes | \n";
echo " Analyze Code Coverage
\n";
}
/**
* Convert an array of parameters into a query string url
*
* @param array $url Url hash to be converted
* @return string Converted url query string
*/
protected function _queryString($url) {
$out = '?';
$params = array();
foreach ($url as $key => $value) {
$params[] = "$key=$value";
}
$out .= implode('&', $params);
return $out;
}
/**
* Paints the end of the document html.
*
* @return void
*/
public function paintDocumentEnd() {
$baseDir = $this->params['baseDir'];
include CAKE_TESTS_LIB . 'templates/footer.php';
ob_end_flush();
}
/**
* Paints the test failure with a breadcrumbs
* trail of the nesting test suites below the
* top level test.
*
* @param PHPUnit_Framework_AssertionFailedError $message Failure object displayed in
* the context of the other tests.
* @return void
*/
public function paintFail($message) {
$context = $message->getTrace();
$realContext = $context[3];
$context = $context[2];
echo "- \n";
echo "Failed";
echo "
" . $this->_htmlEntities($message->toString()) . "
\n";
echo "" . sprintf(__('File: %s'), $context['file']) . "
\n";
echo "" . sprintf(__('Method: %s'), $realContext['function']) . "
\n";
echo "" . sprintf(__('Line: %s'), $context['line']) . "
\n";
echo " \n";
}
/**
* Paints the test pass with a breadcrumbs
* trail of the nesting test suites below the
* top level test.
*
* @param PHPUnit_Framework_Test test method that just passed
* @param float $time time spent to run the test method
* @return void
*/
public function paintPass(PHPUnit_Framework_Test $test, $time = null) {
if (isset($this->params['show_passes']) && $this->params['show_passes']) {
echo "- \n";
echo "Passed ";
//$breadcrumb = $this->getTestList();
//array_shift($breadcrumb);
//echo implode(" -> ", $breadcrumb);
echo "
" . $this->_htmlEntities($test->getName()) . " ($time seconds)\n";
echo " \n";
}
}
/**
* Paints a PHP error.
*
* @param string $message Message is ignored.
* @return void
*/
public function paintError($message) {
echo "- \n";
echo "Error";
echo "
" . $this->_htmlEntities($message) . "
\n";
$breadcrumb = $this->getTestList();
array_shift($breadcrumb);
echo "" . implode(" -> ", $breadcrumb) . "
\n";
echo " \n";
}
/**
* Paints a PHP exception.
*
* @param Exception $exception Exception to display.
* @return void
*/
public function paintException($exception) {
echo "- \n";
echo "Exception";
$message = 'Unexpected exception of type [' . get_class($exception) .
'] with message ['. $exception->getMessage() .
'] in ['. $exception->getFile() .
' line ' . $exception->getLine() . ']';
echo "
" . $this->_htmlEntities($message) . "
\n";
//$breadcrumb = $this->getTestList();
//array_shift($breadcrumb);
//echo "" . implode(" -> ", $breadcrumb) . "
\n";
echo " \n";
}
/**
* Prints the message for skipping tests.
*
* @param string $message Text of skip condition.
* @return void
*/
public function paintSkip($message) {
echo "- \n";
echo "Skipped ";
echo $this->_htmlEntities($message);
echo "
\n";
}
/**
* Paints formatted text such as dumped variables.
*
* @param string $message Text to show.
* @return void
*/
public function paintFormattedMessage($message) {
echo '