* Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) * * Licensed under The Open Group Test Suite License * Redistributions of files must retain the above copyright notice. * * @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org * @package cake * @subpackage cake.cake.tests.libs * @since CakePHP(tm) v 1.2.0.4433 * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License */ include_once dirname(__FILE__) . DS . 'cake_base_reporter.php'; /** * CakeHtmlReporter Reports Results of TestSuites and Test Cases * in an HTML format / context. * * @package cake * @subpackage cake.tests.lib */ class CakeHtmlReporter extends CakeBaseReporter { /** * Character set for the output of test reporting. * * @var string * @access protected */ var $_character_set; /** * Toggle to show passes in output. * * @var boolean * @access protected */ var $_show_passes = false; /** * Array of request parameters. Usually parsed GET params. * * @var array */ var $params = array(); /** * Does nothing yet. The first output will * be sent on the first test start. For use * by a web browser. * * ### Params * * - show_passes - Should passes be shown * - plugin - Plugin test being run? * - app - App test being run. * - case - The case being run * * @param string $character_set The character set to output with. Defaults to ISO-8859-1 * @param array $params Array of request parameters the reporter should use. See above. * @access public */ function CakeHtmlReporter($character_set = 'ISO-8859-1', $params = array()) { $this->SimpleReporter(); $this->_character_set = !empty($character_set) ? $character_set : 'ISO-8859-1'; $this->params = $params; $this->_url = $_SERVER['PHP_SELF']; } /** * Paints the top of the web page setting the * title to the name of the starting test. * * @param string $test_name Name class of test. * @return void * @access public */ function paintHeader($testName) { $this->sendNoCacheHeaders(); $this->paintDocumentHeader(); $this->paintTestMenu(); echo "
Time taken by tests (in seconds): ' . $this->_timeDuration . '
'; 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 */ 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 */ function paintDocumentEnd() { $baseDir = $this->params['baseDir']; include CAKE_TESTS_LIB . 'templates' . DS . 'footer.php'; } /** * Paints the test failure with a breadcrumbs * trail of the nesting test suites below the * top level test. * * @param string $message Failure message displayed in * the context of the other tests. * @return void * @access public */ function paintFail($message) { parent::paintFail($message); echo "' . $this->_htmlEntities($message) . ''; } /** * Character set adjusted entity conversion. * * @param string $message Plain text or Unicode message. * @return string Browser readable message. * @access protected */ function _htmlEntities($message) { return htmlentities($message, ENT_COMPAT, $this->_character_set); } } ?>