* 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 CakePHP(tm) Project * @package cake * @subpackage cake.tests.libs.reporter * @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'; PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'DEFAULT'); /** * CakeHtmlReporter Reports Results of TestSuites and Test Cases * in an HTML format / context. * * @package cake * @subpackage cake.tests.lib */ class CakeHtmlReporter extends CakeBaseReporter implements PHPUnit_Framework_TestListener { /** * 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'; 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 "" . $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); } public function paintResult(PHPUnit_Framework_TestResult $result) { /*if ($result->errorCount() > 0) { $this->printErrors($result); } if ($result->failureCount() > 0) { $this->printFailures($result); } if ($result->skippedCount() > 0) { $this->printIncompletes($result); } if ($result->skippedCount() > 0) { $this->printSkipped($result); }*/ $this->paintFooter($result); } /** * An error occurred. * * @param PHPUnit_Framework_Test $test * @param Exception $e * @param float $time */ public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) { $this->paintException($e); } /** * A failure occurred. * * @param PHPUnit_Framework_Test $test * @param PHPUnit_Framework_AssertionFailedError $e * @param float $time */ public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) { $this->paintFail($e); } /** * Incomplete test. * * @param PHPUnit_Framework_Test $test * @param Exception $e * @param float $time */ public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) { } /** * Skipped test. * * @param PHPUnit_Framework_Test $test * @param Exception $e * @param float $time */ public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) { } /** * A test suite started. * * @param PHPUnit_Framework_TestSuite $suite */ public function startTestSuite(PHPUnit_Framework_TestSuite $suite) { echo '