* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * * Licensed under The MIT License * Redistributions of files must retain the above copyright notice * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project * @package cake.tests.libs.reporter * @since CakePHP(tm) v 1.2.0.4433 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ include_once dirname(__FILE__) . DS . 'cake_base_reporter.php'; PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); /** * CakeHtmlReporter Reports Results of TestSuites and Test Cases * in an HTML format / context. * * @package cake * @package cake.tests.lib */ 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->sendNoCacheHeaders(); $this->paintDocumentStart(); $this->paintTestMenu(); 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 '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'; 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('