* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org) * * Licensed under The MIT License * Redistributions of files must retain the above copyright notice * * @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project * @since CakePHP(tm) v 1.2.0.4433 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ App::uses('CakeBaseReporter', 'TestSuite/Reporter'); /** * CakeHtmlReporter Reports Results of TestSuites and Test Cases * in an HTML format / context. * * @package Cake.TestSuite.Reporter */ class CakeHtmlReporter extends CakeBaseReporter { /** * Paints the top of the web page setting the * title to the name of the starting test. * * @return void */ public function paintHeader() { $this->_headerSent = true; $this->sendContentType(); $this->sendNoCacheHeaders(); $this->paintDocumentStart(); $this->paintTestMenu(); echo "
Time: ' . $result->time() . ' seconds
'; echo 'Peak memory: ' . number_format(memory_get_peak_usage()) . ' bytes
'; echo $this->_paintLinks(); 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 . 'TestSuite' . DS . 'templates' . DS . 'footer.php'; if (ob_get_length()) { 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, $test) { $trace = $this->_getStackTrace($message); $testName = get_class($test) . '(' . $test->getName() . ')'; echo "" . $this->_htmlEntities($message->toString()) . "
' . $this->_htmlEntities($message) . ''; } /** * Character set adjusted entity conversion. * * @param string $message Plain text or Unicode message. * @return string Browser readable message. */ protected function _htmlEntities($message) { return htmlentities($message, ENT_COMPAT, $this->_characterSet); } /** * Gets a formatted stack trace. * * @param Exception $e Exception to get a stack trace for. * @return string Generated stack trace. */ protected function _getStackTrace(Exception $e) { $trace = $e->getTrace(); $out = array(); foreach ($trace as $frame) { if (isset($frame['file']) && isset($frame['line'])) { $out[] = $frame['file'] . ' : ' . $frame['line']; } elseif (isset($frame['class']) && isset($frame['function'])) { $out[] = $frame['class'] . '::' . $frame['function']; } else { $out[] = '[internal]'; } } return implode('