cvs: pear /PHPUnit2 package.xml /PHPUnit2/Util/CodeCoverage/Renderer HTML.php /PHPUnit2/Util/CodeCoverage/Renderer/HTML Template.php
/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Template amber.png directory.htm emerald.png file.htm glass.png item.htm ruby.png snow.png style.css
/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Tree Factory.php Node.php /PHPUnit2/Util/CodeCoverage/Renderer/HTML/Tree/Node Directory.php File.php
| From: | Sebastian Bergmann | Date: | Sat, 25 Feb 2006 08:30:44 +0000 |
| Subject: | cvs: pear /PHPUnit2 package.xml /PHPUnit2/Util/CodeCoverage/Renderer HTML.php /PHPUnit2/Util/CodeCoverage/Renderer/HTML Template.php /PHPUnit2/Util/CodeCoverage/Renderer/HTML/Template amber.png directory.htm emerald.png file.htm glass.png item.htm ruby.png snow.png style.css /PHPUnit2/Util/CodeCoverage/Renderer/HTML/Tree Factory.php Node.php /PHPUnit2/Util/CodeCoverage/Renderer/HTML/Tree/Node Directory.php File.php |
||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-38588@lists.php.net to get a copy of this message | ||
sebastian Sat Feb 25 08:30:44 2006 UTC
Added files:
/pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML Template.php
/pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Template amber.png
directory.htm
emerald.png
file.htm
glass.png
item.htm
ruby.png
snow.png
style.css
/pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Tree Factory.php
Node.php
/pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Tree/Node
Directory.php
File.php
Modified files:
/pear/PHPUnit2/Util/CodeCoverage/Renderer HTML.php
/pear/PHPUnit2 package.xml
Log:
New HTML Code Coverage renderer based on the layout of LCOV.
http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML.php?r1=1.15&r2=1.16&diff_format=u Index: pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML.php diff -u pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML.php:1.15 pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML.php:1.16 --- pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML.php:1.15 Wed Jan 4 07:04:53 2006 +++ pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML.php Sat Feb 25 08:30:43 2006 @@ -13,7 +13,7 @@ * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the @@ -41,7 +41,7 @@ * @author Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: HTML.php,v 1.15 2006/01/04 07:04:53 sebastian Exp $ + * @version CVS: $Id: HTML.php,v 1.16 2006/02/25 08:30:43 sebastian Exp $ * @link http://pear.php.net/package/PHPUnit2 * @since File available since Release 2.3.0 */ @@ -51,7 +51,7 @@ PHPUnit2_Util_Classloader::import( array( - 'PHPUnit2_Util_CodeCoverage_Renderer', + 'PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Factory', ) ); @@ -60,26 +60,6 @@ /** * Renders Code Coverage information in HTML format. * - * Formatting of the generated HTML can be achieved through - * CSS (codecoverage.css). - * - * Example - * - * <code> - * td.ccLineNumber, td.ccCoveredLine, td.ccUncoveredLine, td.ccNotExecutableLine { - * font-family: monospace; - * white-space: pre; - * } - * - * td.ccLineNumber, td.ccCoveredLine { - * background-color: #aaaaaa; - * } - * - * td.ccNotExecutableLine { - * color: #aaaaaa; - * } - * </code> - * * @category Testing * @package PHPUnit2 * @author Sebastian Bergmann <sb@sebastian-bergmann.de> @@ -91,108 +71,60 @@ */ class PHPUnit2_Util_CodeCoverage_Renderer_HTML extends PHPUnit2_Util_CodeCoverage_Renderer { - const pageHeader = -'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> - -<html xmlns="http://www.w3.org/1999/xhtml"> - <head> - <link href="codecoverage.css" type="text/css" rel="stylesheet" /> - </head> - <body> -'; - - const pageFooter = -' </body> -</html> -'; - - const sourceFileHeader = -' <table style="border: 1px solid black" cellspacing="0" cellpadding="0" width="100%"> -'; - - const sourceFileFooter = -' </table> -'; - - const codeLine = -' <tr><td class="ccLineNumber">%s</td><td class="%s">%s</td></tr> -'; - /** + * Visualizes the result array of + * PHPUnit2_Framework_TestResult::getCodeCoverageInformation() + * and writes it to a directory. + * * @return string - * @access protected - * @since Method available since Release 2.1.1 + * @access public + * @since Method available since Release 3.0.0 */ - protected function header() + public function render($target) { - return self::pageHeader; - } + if (!is_dir($target)) { + throw new InvalidArgumentException; + } - /** - * @return string - * @access protected - * @since Method available since Release 2.1.1 - */ - protected function footer() - { - return self::pageFooter; - } + if (substr($target, -1, 1) != DIRECTORY_SEPARATOR) { + $target .= DIRECTORY_SEPARATOR; + } - /** - * @param string $sourceFile - * @return string - * @access protected - */ - protected function startSourceFile($sourceFile) - { - return self::sourceFileHeader; - } + $tree = PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Factory::create( + $this->getSummary() + ); - /** - * @param string $sourceFile - * @return string - * @access protected - */ - protected function endSourceFile($sourceFile) - { - return self::sourceFileFooter; + $tree->render($target); + + $this->copyFiles($target); } - /** - * @param array $codeLines - * @param array $executedLines - * @return string - * @access protected - */ - protected function renderSourceFile(Array $codeLines, Array $executedLines) + protected function copyFiles($target) { - $buffer = ''; - $line = 1; - foreach ($codeLines as $codeLine) { - $lineStyle = 'ccNotExecutableLine'; + $files = array( + 'amber.png', + 'emerald.png', + 'ruby.png', + 'snow.png', + 'style.css', + ); - if (isset($executedLines[$line])) { - if ($executedLines[$line] > 0) { - $lineStyle = 'ccCoveredLine'; - } else { - $lineStyle = 'ccUncoveredLine'; - } - } - - $buffer .= sprintf( - self::codeLine, - - $line, - $lineStyle, - htmlspecialchars(rtrim($codeLine)) - ); - - $line++; + foreach ($files as $file) { + copy(self::getTemplatePath() . $file, $target . $file); } + } + + public static function getTemplatePath() + { + return sprintf( + '%s%sHTML%sTemplate%s', - return $buffer; + dirname(__FILE__), + DIRECTORY_SEPARATOR, + DIRECTORY_SEPARATOR, + DIRECTORY_SEPARATOR + ); } } http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/package.xml?r1=1.171&r2=1.172&diff_format=u Index: pear/PHPUnit2/package.xml diff -u pear/PHPUnit2/package.xml:1.171 pear/PHPUnit2/package.xml:1.172 --- pear/PHPUnit2/package.xml:1.171 Mon Feb 20 06:45:41 2006 +++ pear/PHPUnit2/package.xml Sat Feb 25 08:30:43 2006 @@ -41,6 +41,8 @@ + Added a TestListener that generates a logfile of the test execution using the Test Anything Protocol (TAP). ++ Added new HTML Code Coverage renderer based on the layout of LCOV. + * PHPUnit2_Framework_Assert::assertContains() and PHPUnit2_Framework_Assert::assertNotContains() can now work on strings. * PHPUnit2_Framework_ComparisonFailure has been refactored into PHPUnit2_Framework_ComparisonFailure, PHPUnit2_Framework_ComparisonFailure_Array, PHPUnit2_Framework_ComparisonFailure_Object, PHPUnit2_Framework_ComparisonFailure_Scalar, PHPUnit2_Framework_ComparisonFailure_String, and PHPUnit2_Framework_ComparisonFailure_Type to improve discrepancy visualization, initially developed by Jan Borsodi and contributed by eZ systems AS. @@ -51,16 +53,16 @@ * PHPUnit2 now uses the Standard PHP Library (SPL)'s specialized exceptions InvalidArgumentException and RuntimeException instead of the generic Exception exception class. -* Fixed bug #5053: Problems with global variables. - -* Fixed bug #5933: PHPUnit2_Framework_TestSuite::addTestFile() and non-working directories. - * Implemented RFE #5546: Make filtering and/or filtering on the current file optional. * Implemented RFE #5860: Missing parse errors after lint. * Implemented RFE #5932: Make the PHP syntax check of files optional. +* Fixed bug #5053: Problems with global variables. + +* Fixed bug #5933: PHPUnit2_Framework_TestSuite::addTestFile() and non-working directories. + - Removed PHPUnit2_Framework_Assert::setLooselyTyped(). - Removed dependency on the Benchmark_Timer, Console_Getopt, and PEAR_Config PEAR classes. @@ -520,6 +522,42 @@ <dir name="Util" role="php"> <dir name="CodeCoverage"> <dir name="Renderer"> + <dir name="HTML"> + <dir name="Template"> + <file name="amber.png"/> + <file name="directory.htm"/> + <file name="emerald.png"/> + <file name="file.htm"/> + <file name="glass.png"/> + <file name="item.htm"/> + <file name="ruby.png"/> + <file name="snow.png"/> + <file name="style.css"/> + </dir> + + <dir name="Tree"> + <dir name="Node"> + <file name="Directory.php"> + <replace type="package-info" from="@package_version@" to="version"/> + </file> + <file name="File.php"> + <replace type="package-info" from="@package_version@" to="version"/> + </file> + </dir> + + <file name="Factory.php"> + <replace type="package-info" from="@package_version@" to="version"/> + </file> + <file name="Node.php"> + <replace type="package-info" from="@package_version@" to="version"/> + </file> + </dir> + + <file name="Template.php"> + <replace type="package-info" from="@package_version@" to="version"/> + </file> + </dir> + <file name="HTML.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Template.php?view=markup&rev=1.1 Index: pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Template.php +++ pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Template.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * PHP Version 5 * * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of Sebastian Bergmann nor the names of his * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @category Testing * @package PHPUnit2 * @author Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @version CVS: $Id: Template.php,v 1.1 2006/02/25 08:30:43 sebastian Exp $ * @link http://pear.php.net/package/PHPUnit2 * @since File available since Release 3.0.0 */ require_once 'PHPUnit2/Util/Filter.php'; PHPUnit2_Util_Filter::addFileToFilter(__FILE__); /** * * * @category Testing * @package PHPUnit2 * @author Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @version Release: @package_version@ * @link http://pear.php.net/package/PHPUnit2 * @since Class available since Release 3.0.0 */ class PHPUnit2_Util_CodeCoverage_Renderer_HTML_Template { /** * @var array * @access private */ private $template = ''; /** * @var array * @access private */ private $keys = array(); /** * @var array * @access private */ private $values = array(); /** * Constructor. * * @param string $file * @throws InvalidArgumentException * @access public */ public function __construct($file = '') { $this->setFile($file); } /** * Sets the template file. * * @param string $file * @throws InvalidArgumentException * @access public */ public function setFile($file) { if ($file != '' && file_exists($file)) { $this->template = file_get_contents($file); } else { throw new InvalidArgumentException( 'Template file could not be loaded.' ); } } /** * Sets one or more template variables. * * @param mixed $keys * @param mixed $values * @access public */ public function setVar($keys, $values) { if (is_array($keys) && is_array($values) && sizeof($keys) == sizeof($values)) { foreach ($keys as $key) { $this->keys[] = '{' . $key . '}'; } $this->values = array_merge($this->values, $values); } else { $this->keys[] = '{' . $keys . '}'; $this->values[] = $values; } } /** * Renders the template and returns the result. * * @return $string * @access public */ public function render() { return str_replace($this->keys, $this->values, $this->template); } } /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * c-hanging-comment-ender-p: nil * End: */ ?> http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Template/directory.htm?view=markup&rev=1.1 Index: pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Template/directory.htm +++ pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Template/directory.htm <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>{title}</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr><td class="title">{title}</td></tr> <tr><td class="ruler"><img src="glass.png" width="3" height="3" alt=""></td></tr> <tr> <td width="100%"> <table cellpadding="1" border="0" width="100%"> <tr> <td class="headerItem" width="20%">Current view:</td> <td class="headerValue" width="80%" colspan="4">{path}</td> </tr> <tr> <td class="headerItem" width="20%">Date:</td> <td class="headerValue" width="20%">{date}</td> <td width="20%"></td> <td class="headerItem" width="20%">Executable lines:</td> <td class="headerValue" width="20%">{executable_lines}</td> </tr> <tr> <td class="headerItem" width="20%">Code covered:</td> <td class="headerValue" width="20%">{executed_percent}%</td> <td width="20%"></td> <td class="headerItem" width="20%">Executed lines:</td> <td class="headerValue" width="20%">{executed_lines}</td> </tr> <tr> <td class="legendItem" width="20%">Legend:</td> <td class="legendValue" width="80%" colspan="4"> <span class="coverLegendLo"> <b>Low:</b> 0% to 15% </span> <span class="coverLegendMed"> <b>Medium:</b> 15% to 50% </span> <span class="coverLegendHi"> <b>High:</b> 50% to 100% </span> </td> </tr> </table> </td> </tr> <tr> <td class="ruler"><img src="glass.png" width="3" height="3" alt=""></td> </tr> </table> <center> <table width="80%" cellpadding=2 cellspacing=1 border=0> <tr> <td width="50%"><br></td> <td width="15%"></td> <td width="15%"></td> <td width="20%"></td> </tr> <tr> <td class="tableHead"></td> <td class="tableHead" colspan="3">Coverage</td> </tr> {items} </table> </center> <br/> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr><td class="ruler"><img src="glass.png" width="3" height="3" alt=""></td></tr> <tr><td class="versionInfo">Generated by: <a href="http://www.phpunit.de/">PHPUnit {phpunit_version}</a> and <a href="http://www.xdebug.org/">Xdebug {xdebug_version}</a>.</td></tr> </table> <br/> </body> </html> http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Template/file.htm?view=markup&rev=1.1 Index: pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Template/file.htm +++ pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Template/file.htm <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>{title}</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr><td class="title">{title}</td></tr> <tr><td class="ruler"><img src="glass.png" width="3" height="3" alt=""></td></tr> <tr> <td width="100%"> <table cellpadding=1 border=0 width="100%"> <tr> <td class="headerItem" width="20%">Current view:</td> <td class="headerValue" width="80%" colspan="4">{path}</td> </tr> <tr> <td class="headerItem" width="20%">Date:</td> <td class="headerValue" width="20%">{date}</td> <td width="20%"></td> <td class="headerItem" width="20%">Executable lines:</td> <td class="headerValue" width="20%">{executable_lines}</td> </tr> <tr> <td class="headerItem" width="20%">Code covered:</td> <td class="headerValue" width="20%">{executed_percent}%</td> <td width="20%"></td> <td class="headerItem" width="20%">Executed lines:</td> <td class="headerValue" width="20%">{executed_lines}</td> </tr> <tr> <td class="legendItem" width="20%">Legend:</td> <td class="legendValue" width="80%" colspan="4"> <span class="legendNoCov">not executed</span> <span class="legendCov">executed</span> </td> </tr> </table> </td> </tr> <tr> <td class="ruler"><img src="glass.png" width="3" height="3" alt=""></td> </tr> </table> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td><br /></td> </tr> <tr> <td> <pre class="source"> {lines} </pre> </td> </tr> </table> <br /> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr><td class="ruler"><img src="glass.png" width="3" height="3" alt=""></td></tr> <tr><td class="versionInfo">Generated by: <a href="http://www.phpunit.de/">PHPUnit {phpunit_version}</a> and <a href="http://www.xdebug.org/">Xdebug {xdebug_version}</a>.</td></tr> </table> <br /> </body> </html> http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Template/item.htm?view=markup&rev=1.1 Index: pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Template/item.htm +++ pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Template/item.htm <tr> <td class="coverFile"><a href="{url}.htm">{name}</a></td> <td class="coverBar" align="center"> <table border="0" cellspacing="0" cellpadding="1"> <tr> <td class="coverBarOutline"><img src="{color}.png" width="{executed_width}" height="10" alt="{executed_percent} %"><img src="snow.png" width="{not_executed_width}" height="10" alt="{executed_percent} %"></td> </tr> </table> </td> <td class="coverPer{level}">{executed_percent} %</td> <td class="coverNum{level}">{executed_lines} / {executable_lines} lines</td> </tr> http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Template/style.css?view=markup&rev=1.1 Index: pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Template/style.css +++ pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Template/style.css /* All views: initial background and text color */ body { color: #000000; background-color: #FFFFFF; } /* All views: standard link format*/ a:link { color: #284FA8; text-decoration: underline; } /* All views: standard link - visited format */ a:visited { color: #00CB40; text-decoration: underline; } /* All views: standard link - activated format */ a:active { color: #FF0040; text-decoration: underline; } /* All views: main title format */ td.title { text-align: center; padding-bottom: 10px; font-family: sans-serif; font-size: 20pt; font-style: italic; font-weight: bold; } /* All views: header item format */ td.headerItem { text-align: right; padding-right: 6px; font-family: sans-serif; font-weight: bold; } /* All views: header item value format */ td.headerValue { text-align: left; color: #284FA8; font-family: sans-serif; font-weight: bold; } /* All views: header legend item format */ td.legendItem { text-align: right; padding-right: 6px; padding-top: 10px; padding-bottom: 2px; font-family: sans-serif; font-weight: bold; } /* All views: header legend item value format */ td.legendValue { text-align: left; padding-top: 10px; padding-bottom: 2px; color: #000000; font-family: sans-serif; font-weight: bold; } /* All views: color of horizontal ruler */ td.ruler { background-color: #6688D4; } /* All views: version string format */ td.versionInfo { text-align: center; padding-top: 2px; font-family: sans-serif; font-style: italic; } /* Directory view/File view (all)/Test case descriptions: table headline format */ td.tableHead { text-align: center; color: #FFFFFF; background-color: #6688D4; font-family: sans-serif; font-size: 120%; font-weight: bold; } /* Directory view/File view (all): filename entry format */ td.coverFile { text-align: left; padding-left: 10px; padding-right: 20px; color: #284FA8; background-color: #DAE7FE; font-family: monospace; } /* Directory view/File view (all): bar-graph entry format*/ td.coverBar { padding-left: 10px; padding-right: 10px; background-color: #DAE7FE; } /* Directory view/File view (all): bar-graph outline color */ td.coverBarOutline { background-color: #000000; } /* Directory view/File view (all): percentage entry for files with high coverage rate */ td.coverPerHi { text-align: right; padding-left: 10px; padding-right: 10px; background-color: #A7FC9D; font-weight: bold; } /* Directory view/File view (all): line count entry for files with high coverage rate */ td.coverNumHi { text-align: right; padding-left: 10px; padding-right: 10px; background-color: #A7FC9D; } /* Directory view/File view (all): legend entry for high coverage rate */ span.coverLegendHi { text-align: center; padding-left: 10px; padding-right: 10px; background-color: #A7FC9D; } /* Directory view/File view (all): percentage entry for files with medium coverage rate */ td.coverPerMed { text-align: right; padding-left: 10px; padding-right: 10px; background-color: #FFEA20; font-weight: bold; } /* Directory view/File view (all): line count entry for files with medium coverage rate */ td.coverNumMed { text-align: right; padding-left: 10px; padding-right: 10px; background-color: #FFEA20; } /* Directory view/File view (all): legend entry for medium coverage rate */ span.coverLegendMed { text-align: center; padding-left: 10px; padding-right: 10px; margin-top: 5px; margin-bottom: 5px; margin-right: 2px; background-color: #FFEA20; } /* Directory view/File view (all): percentage entry for files with low coverage rate */ td.coverPerLo { text-align: right; padding-left: 10px; padding-right: 10px; background-color: #FF0000; font-weight: bold; } /* Directory view/File view (all): line count entry for files with low coverage rate */ td.coverNumLo { text-align: right; padding-left: 10px; padding-right: 10px; background-color: #FF0000; } /* Directory view/File view (all): legend entry for low coverage rate */ span.coverLegendLo { text-align: center; padding-left: 10px; padding-right: 10px; margin-right: 2px; background-color: #FF0000; } /* File view (all): "show/hide details" link format */ a.detail:link { color: #B8D0FF; } /* File view (all): "show/hide details" link - visited format */ a.detail:visited { color: #B8D0FF; } /* File view (all): "show/hide details" link - activated format */ a.detail:active { color: #FFFFFF; } /* File view (detail): test name table headline format */ td.testNameHead { text-align: right; padding-right: 10px; background-color: #DAE7FE; font-family: sans-serif; font-weight: bold; } /* File view (detail): test lines table headline format */ td.testLinesHead { text-align: center; background-color: #DAE7FE; font-family: sans-serif; font-weight: bold; } /* File view (detail): test name entry */ td.testName { text-align: right; padding-right: 10px; background-color: #DAE7FE; } /* File view (detail): test percentage entry */ td.testPer { text-align: right; padding-left: 10px; padding-right: 10px; background-color: #DAE7FE; } /* File view (detail): test lines count entry */ td.testNum { text-align: right; padding-left: 10px; padding-right: 10px; background-color: #DAE7FE; } /* Test case descriptions: test name format*/ dt { font-family: sans-serif; font-weight: bold; } /* Test case descriptions: description table body */ td.testDescription { padding-top: 10px; padding-left: 30px; padding-bottom: 10px; padding-right: 30px; background-color: #DAE7FE; } /* Source code view: source code format */ pre.source { font-family: monospace; white-space: pre; } /* Source code view: line number format */ span.lineNum { background-color: #EFE383; } /* Source code view: format for lines which were executed */ span.lineCov { background-color: #CAD7FE; } /* Source code view: format for Cov legend */ span.LegendCov { text-align: center; padding-left: 10px; padding-right: 10px; margin-right: 2px; background-color: #CAD7FE; } /* Source code view: format for lines which were not executed */ span.lineNoCov { background-color: #FF6230; } /* Source code view: format for NoCov legend */ span.LegendNoCov { text-align: center; padding-left: 10px; padding-right: 10px; margin-right: 2px; background-color: #FF6230; } /* Source code view: format for lines which were executed only in a previous version */ span.lineDiffCov { background-color: #B5F7AF; } /* Source code view: format for DiffCov legend */ span.LegendDiffCov { text-align: center; padding-left: 10px; padding-right: 10px; background-color: #B5F7AF; } http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Tree/Factory.php?view=markup&rev=1.1 Index: pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Tree/Factory.php +++ pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Tree/Factory.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * PHP Version 5 * * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of Sebastian Bergmann nor the names of his * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @category Testing * @package PHPUnit2 * @author Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @version CVS: $Id: Factory.php,v 1.1 2006/02/25 08:30:43 sebastian Exp $ * @link http://pear.php.net/package/PHPUnit2 * @since File available since Release 3.0.0 */ require_once 'PHPUnit2/Util/Classloader.php'; require_once 'PHPUnit2/Util/Filter.php'; PHPUnit2_Util_Classloader::import( array( 'PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node_Directory', 'PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node_File', ) ); PHPUnit2_Util_Filter::addFileToFilter(__FILE__); /** * * * @category Testing * @package PHPUnit2 * @author Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @version Release: @package_version@ * @link http://pear.php.net/package/PHPUnit2 * @since Class available since Release 3.0.0 */ class PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Factory { /** * Creates a new Code Coverage information tree. * * @param array $files * @access public * @static */ public static function create($files) { $commonPath = self::reducePaths($files); $directory = self::buildDirectoryStructure($files); $root = new PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node_Directory( $commonPath ); self::addItems($root, $directory['.']); return $root; } /** * @param PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node_Directory $root * @param array $items * @access protected * @static */ protected static function addItems($root, $items) { foreach ($items as $key => $value) { if (substr($key, -4) == '.php') { $root->addFile($key, $value); } else { $child = $root->addDirectory($key); self::addItems($child, $value); } } } /** * Reduces the paths by cutting the longest common start path. * * For instance, * * <code> * Array * ( * [/home/sb/PHPUnit2/Samples/Money/Money.php] => Array * ( * ... * ) * * [/home/sb/PHPUnit2/Samples/Money/MoneyBag.php] => Array * ( * ... * ) * ) * </code> * * is reduced to * * <code> * Array * ( * [Money.php] => Array * ( * ... * ) * * [MoneyBag.php] => Array * ( * ... * ) * ) * </code> * * @param array $files * @return string * @access protected * @static */ protected static function reducePaths(&$files) { $commonPath = ''; $paths = array_keys($files); for ($i = 0; $i < sizeof($paths); $i++) { $paths[$i] = explode(DIRECTORY_SEPARATOR, $paths[$i]); if (empty($paths[$i][0])) { $paths[$i][0] = DIRECTORY_SEPARATOR; } } $done = FALSE; while (!$done) { for ($i = 0; $i < sizeof($paths)-1; $i++) { if (!isset($paths[$i][0]) || !isset($paths[$i+1][0]) || $paths[$i][0] != $paths[$i+1][0]) { $done = TRUE; break; } } if (!$done) { $commonPath .= $paths[0][0] . (($paths[0][0] != DIRECTORY_SEPARATOR) ? DIRECTORY_SEPARATOR : ''); for ($i = 0; $i < sizeof($paths); $i++) { array_shift($paths[$i]); } } } $original = array_keys($files); for ($i = 0; $i < sizeof($original); $i++) { $files[join('/', $paths[$i])] = $files[$original[$i]]; unset($files[$original[$i]]); } ksort($files); return $commonPath; } /** * Builds an array representation of the directory structure. * * For instance, * * <code> * Array * ( * [Money.php] => Array * ( * ... * ) * * [MoneyBag.php] => Array * ( * ... * ) * ) * </code> * * is transformed into * * <code> * Array * ( * [.] => Array * ( * [Money.php] => Array * ( * ... * ) * * [MoneyBag.php] => Array * ( * ... * ) * ) * ) * </code> * * @param array $files * @return array * @access protected * @static */ protected static function buildDirectoryStructure($files) { $result = array(); foreach ($files as $key => $value) { $file = basename($key); $path = explode(DIRECTORY_SEPARATOR, dirname($key)); $pointer = &$result; foreach ($path as $p) { if (!array_key_exists($p, $pointer)) { $pointer[$p] = array(); } $pointer = &$pointer[$p]; } $pointer[$file] = $value; } return $result; } } /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * c-hanging-comment-ender-p: nil * End: */ ?> http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Tree/Node.php?view=markup&rev=1.1 Index: pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Tree/Node.php +++ pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Tree/Node.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * PHP Version 5 * * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of Sebastian Bergmann nor the names of his * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @category Testing * @package PHPUnit2 * @author Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @version CVS: $Id: Node.php,v 1.1 2006/02/25 08:30:43 sebastian Exp $ * @link http://pear.php.net/package/PHPUnit2 * @since File available since Release 3.0.0 */ require_once 'PHPUnit2/Util/Filter.php'; PHPUnit2_Util_Filter::addFileToFilter(__FILE__); /** * * * @category Testing * @package PHPUnit2 * @author Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @version Release: @package_version@ * @link http://pear.php.net/package/PHPUnit2 * @since Class available since Release 3.0.0 */ abstract class PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node { /** * @var string * @access protected */ protected $name; /** * @var PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node * @access protected */ protected $parent; /** * Constructor. * * @param string $name * @param PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node $parent * @access public */ public function __construct($name, PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node $parent = NULL) { $this->name = $name; $this->parent = $parent; } /** * Returns this node's ID. * * @return string * @access public */ public function getId() { if ($this->parent === NULL) { return 'index'; } else { return str_replace('index_', '', $this->parent->getId() . '_' . strtolower($this->getName())); } } /** * Returns the link to this node. * * @return string * @access public */ public function getLink() { return sprintf( '%s<a href="%s.htm">%s</a>', $this->parent !== NULL ? $this->parent->getLink() : '', $this->getId(), $this->getName() ); } /** * Returns this node's name. * * @return string * @access public */ public function getName() { return $this->name; } /** * Returns this node's path. * * @return string * @access public */ public function getPath() { if ($this->parent === NULL) { return $this->getName(); } else { return $this->parent->getPath() . DIRECTORY_SEPARATOR . $this->getName(); } } /** * Returns the percentage of executed lines. * * @return integer * @access public */ public function getExecutedPercent() { return sprintf( '%01.2f', ($this->getNumExecutedLines() / $this->getNumExecutableLines()) * 100 ); } /** * Returns the number of executable lines. * * @return integer * @access public * @abstract */ abstract public function getNumExecutableLines(); /** * Returns the number of executed lines. * * @return integer * @access public * @abstract */ abstract public function getNumExecutedLines(); /** * Renders the node to HTML. * * @param string $target * @access public * @abstract */ abstract public function render($target); } /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * c-hanging-comment-ender-p: nil * End: */ ?> http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Tree/Node/Directory.php?view=markup&rev=1.1 Index: pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Tree/Node/Directory.php +++ pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Tree/Node/Directory.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * PHP Version 5 * * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of Sebastian Bergmann nor the names of his * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @category Testing * @package PHPUnit2 * @author Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @version CVS: $Id: Directory.php,v 1.1 2006/02/25 08:30:43 sebastian Exp $ * @link http://pear.php.net/package/PHPUnit2 * @since File available since Release 3.0.0 */ require_once 'PHPUnit2/Util/Classloader.php'; require_once 'PHPUnit2/Util/Filter.php'; PHPUnit2_Util_Classloader::import( array( 'PHPUnit2_Util_CodeCoverage_Renderer_HTML_Template', 'PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node', ) ); PHPUnit2_Util_Filter::addFileToFilter(__FILE__); /** * * * @category Testing * @package PHPUnit2 * @author Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @version Release: @package_version@ * @link http://pear.php.net/package/PHPUnit2 * @since Class available since Release 3.0.0 */ class PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node_Directory extends PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node { /** * @var array * @access protected */ protected $children = array(); /** * Adds a new directory. * * @return PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node_Directory * @access public */ public function addDirectory($name) { $directory = new PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node_Directory( $name, $this ); $this->children[] = $directory; return $directory; } /** * Adds a new file. * * @param string $name * @param array $lines * @access public */ public function addFile($name, $lines) { $file = new PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node_File( $name, $this, $lines ); $this->children[] = $file; } /** * Returns the number of executable lines. * * @return integer * @access public */ public function getNumExecutableLines() { $numExecutableLines = 0; foreach ($this->children as $child) { $numExecutableLines += $child->getNumExecutableLines(); } return $numExecutableLines; } /** * Returns the number of executed lines. * * @return integer * @access public */ public function getNumExecutedLines() { $numExecutedLines = 0; foreach ($this->children as $child) { $numExecutedLines += $child->getNumExecutedLines(); } return $numExecutedLines; } /** * Renders the node to HTML. * * @param string $target * @access public */ public function render($target) { $template = new PHPUnit2_Util_CodeCoverage_Renderer_HTML_Template( PHPUnit2_Util_CodeCoverage_Renderer_HTML::getTemplatePath() . 'directory.htm' ); $items = ''; foreach ($this->children as $child) { $itemTemplate = new PHPUnit2_Util_CodeCoverage_Renderer_HTML_Template( PHPUnit2_Util_CodeCoverage_Renderer_HTML::getTemplatePath() . 'item.htm' ); $floorPercent = floor($child->getExecutedPercent()); if ($floorPercent < 15) { $color = 'ruby'; $level = 'Lo'; } else if ($floorPercent >= 15 && $floorPercent < 50) { $color = 'amber'; $level = 'Med'; } else { $color = 'emerald'; $level = 'Hi'; } $itemTemplate->setVar( array( 'url', 'name', 'color', 'level', 'executed_width', 'executed_percent', 'not_executed_width', 'executable_lines', 'executed_lines', ), array( $child->getId(), $child->getName(), $color, $level, floor($child->getExecutedPercent()), $child->getExecutedPercent(), 100 - floor($child->getExecutedPercent()), $child->getNumExecutableLines(), $child->getNumExecutedLines() ) ); $items .= $itemTemplate->render(); } $template->setVar( array( 'path', 'executable_lines', 'executed_lines', 'executed_percent', 'items', 'date', 'phpunit_version', 'xdebug_version', ), array( $this->getLink(), $this->getNumExecutableLines(), $this->getNumExecutedLines(), $this->getExecutedPercent(), $items, date('D M j G:i:s T Y'), PHPUnit2_Runner_Version::id(), phpversion('xdebug') ) ); $fp = fopen($target . $this->getId() . '.htm', 'w'); fputs($fp, $template->render()); fclose($fp); foreach ($this->children as $child) { $child->render($target); } } } /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * c-hanging-comment-ender-p: nil * End: */ ?> http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Tree/Node/File.php?view=markup&rev=1.1 Index: pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Tree/Node/File.php +++ pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Tree/Node/File.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * PHP Version 5 * * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of Sebastian Bergmann nor the names of his * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @category Testing * @package PHPUnit2 * @author Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @version CVS: $Id: File.php,v 1.1 2006/02/25 08:30:43 sebastian Exp $ * @link http://pear.php.net/package/PHPUnit2 * @since File available since Release 3.0.0 */ require_once 'PHPUnit2/Util/Classloader.php'; require_once 'PHPUnit2/Util/Filter.php'; PHPUnit2_Util_Classloader::import( array( 'PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node', ) ); PHPUnit2_Util_Filter::addFileToFilter(__FILE__); /** * * * @category Testing * @package PHPUnit2 * @author Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @version Release: @package_version@ * @link http://pear.php.net/package/PHPUnit2 * @since Class available since Release 3.0.0 */ class PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node_File extends PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node { /** * @var array * @access protected */ protected $lines; /** * Constructor. * * @param string $name * @param PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node $parent * @param array $lines * @access public */ public function __construct($name, $parent, $lines) { parent::__construct($name, $parent); $this->lines = $lines; } /** * Returns the number of executable lines. * * @return integer * @access public */ public function getNumExecutableLines() { return sizeof($this->lines); } /** * Returns the number of executed lines. * * @return integer * @access public */ public function getNumExecutedLines() { $numExecutedLines = 0; foreach ($this->lines as $line => $flag) { if ($flag > 0) { $numExecutedLines++; } } return $numExecutedLines; } /** * Renders the node to HTML. * * @param string $target * @access public */ public function render($target) { $template = new PHPUnit2_Util_CodeCoverage_Renderer_HTML_Template( PHPUnit2_Util_CodeCoverage_Renderer_HTML::getTemplatePath() . 'file.htm' ); $file = file($this->getPath()); $i = 1; $lines = ''; foreach ($file as $line) { $css = ''; if (isset($this->lines[$i])) { if ($this->lines[$i] > 0) { $css = '<span class="lineCov">'; } else { $css = '<span class="lineNoCov">'; } } $lines .= sprintf( '<span class="lineNum">%6d</span> %s%s%s' . "\n", $i, $css, htmlspecialchars(rtrim($line)), !empty($css) ? '</span>' : '' ); $i++; } $template->setVar( array( 'path', 'executable_lines', 'executed_lines', 'executed_percent', 'lines', 'date', 'phpunit_version', 'xdebug_version', ), array( $this->getLink(), $this->getNumExecutableLines(), $this->getNumExecutedLines(), $this->getExecutedPercent(), $lines, date('D M j G:i:s T Y'), PHPUnit2_Runner_Version::id(), phpversion('xdebug') ) ); $fp = fopen($target . $this->getId() . '.htm', 'w'); fputs($fp, $template->render()); fclose($fp); } } /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * c-hanging-comment-ender-p: nil * End: */ ?>
http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML.php?r1=1.15&r2=1.16&diff_format=u Index: pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML.php diff -u pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML.php:1.15 pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML.php:1.16 --- pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML.php:1.15 Wed Jan 4 07:04:53 2006 +++ pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML.php Sat Feb 25 08:30:43 2006 @@ -13,7 +13,7 @@ * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the @@ -41,7 +41,7 @@ * @author Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: HTML.php,v 1.15 2006/01/04 07:04:53 sebastian Exp $ + * @version CVS: $Id: HTML.php,v 1.16 2006/02/25 08:30:43 sebastian Exp $ * @link http://pear.php.net/package/PHPUnit2 * @since File available since Release 2.3.0 */ @@ -51,7 +51,7 @@ PHPUnit2_Util_Classloader::import( array( - 'PHPUnit2_Util_CodeCoverage_Renderer', + 'PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Factory', ) ); @@ -60,26 +60,6 @@ /** * Renders Code Coverage information in HTML format. * - * Formatting of the generated HTML can be achieved through - * CSS (codecoverage.css). - * - * Example - * - * <code> - * td.ccLineNumber, td.ccCoveredLine, td.ccUncoveredLine, td.ccNotExecutableLine { - * font-family: monospace; - * white-space: pre; - * } - * - * td.ccLineNumber, td.ccCoveredLine { - * background-color: #aaaaaa; - * } - * - * td.ccNotExecutableLine { - * color: #aaaaaa; - * } - * </code> - * * @category Testing * @package PHPUnit2 * @author Sebastian Bergmann <sb@sebastian-bergmann.de> @@ -91,108 +71,60 @@ */ class PHPUnit2_Util_CodeCoverage_Renderer_HTML extends PHPUnit2_Util_CodeCoverage_Renderer { - const pageHeader = -'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> - -<html xmlns="http://www.w3.org/1999/xhtml"> - <head> - <link href="codecoverage.css" type="text/css" rel="stylesheet" /> - </head> - <body> -'; - - const pageFooter = -' </body> -</html> -'; - - const sourceFileHeader = -' <table style="border: 1px solid black" cellspacing="0" cellpadding="0" width="100%"> -'; - - const sourceFileFooter = -' </table> -'; - - const codeLine = -' <tr><td class="ccLineNumber">%s</td><td class="%s">%s</td></tr> -'; - /** + * Visualizes the result array of + * PHPUnit2_Framework_TestResult::getCodeCoverageInformation() + * and writes it to a directory. + * * @return string - * @access protected - * @since Method available since Release 2.1.1 + * @access public + * @since Method available since Release 3.0.0 */ - protected function header() + public function render($target) { - return self::pageHeader; - } + if (!is_dir($target)) { + throw new InvalidArgumentException; + } - /** - * @return string - * @access protected - * @since Method available since Release 2.1.1 - */ - protected function footer() - { - return self::pageFooter; - } + if (substr($target, -1, 1) != DIRECTORY_SEPARATOR) { + $target .= DIRECTORY_SEPARATOR; + } - /** - * @param string $sourceFile - * @return string - * @access protected - */ - protected function startSourceFile($sourceFile) - { - return self::sourceFileHeader; - } + $tree = PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Factory::create( + $this->getSummary() + ); - /** - * @param string $sourceFile - * @return string - * @access protected - */ - protected function endSourceFile($sourceFile) - { - return self::sourceFileFooter; + $tree->render($target); + + $this->copyFiles($target); } - /** - * @param array $codeLines - * @param array $executedLines - * @return string - * @access protected - */ - protected function renderSourceFile(Array $codeLines, Array $executedLines) + protected function copyFiles($target) { - $buffer = ''; - $line = 1; - foreach ($codeLines as $codeLine) { - $lineStyle = 'ccNotExecutableLine'; + $files = array( + 'amber.png', + 'emerald.png', + 'ruby.png', + 'snow.png', + 'style.css', + ); - if (isset($executedLines[$line])) { - if ($executedLines[$line] > 0) { - $lineStyle = 'ccCoveredLine'; - } else { - $lineStyle = 'ccUncoveredLine'; - } - } - - $buffer .= sprintf( - self::codeLine, - - $line, - $lineStyle, - htmlspecialchars(rtrim($codeLine)) - ); - - $line++; + foreach ($files as $file) { + copy(self::getTemplatePath() . $file, $target . $file); } + } + + public static function getTemplatePath() + { + return sprintf( + '%s%sHTML%sTemplate%s', - return $buffer; + dirname(__FILE__), + DIRECTORY_SEPARATOR, + DIRECTORY_SEPARATOR, + DIRECTORY_SEPARATOR + ); } } http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/package.xml?r1=1.171&r2=1.172&diff_format=u Index: pear/PHPUnit2/package.xml diff -u pear/PHPUnit2/package.xml:1.171 pear/PHPUnit2/package.xml:1.172 --- pear/PHPUnit2/package.xml:1.171 Mon Feb 20 06:45:41 2006 +++ pear/PHPUnit2/package.xml Sat Feb 25 08:30:43 2006 @@ -41,6 +41,8 @@ + Added a TestListener that generates a logfile of the test execution using the Test Anything Protocol (TAP). ++ Added new HTML Code Coverage renderer based on the layout of LCOV. + * PHPUnit2_Framework_Assert::assertContains() and PHPUnit2_Framework_Assert::assertNotContains() can now work on strings. * PHPUnit2_Framework_ComparisonFailure has been refactored into PHPUnit2_Framework_ComparisonFailure, PHPUnit2_Framework_ComparisonFailure_Array, PHPUnit2_Framework_ComparisonFailure_Object, PHPUnit2_Framework_ComparisonFailure_Scalar, PHPUnit2_Framework_ComparisonFailure_String, and PHPUnit2_Framework_ComparisonFailure_Type to improve discrepancy visualization, initially developed by Jan Borsodi and contributed by eZ systems AS. @@ -51,16 +53,16 @@ * PHPUnit2 now uses the Standard PHP Library (SPL)'s specialized exceptions InvalidArgumentException and RuntimeException instead of the generic Exception exception class. -* Fixed bug #5053: Problems with global variables. - -* Fixed bug #5933: PHPUnit2_Framework_TestSuite::addTestFile() and non-working directories. - * Implemented RFE #5546: Make filtering and/or filtering on the current file optional. * Implemented RFE #5860: Missing parse errors after lint. * Implemented RFE #5932: Make the PHP syntax check of files optional. +* Fixed bug #5053: Problems with global variables. + +* Fixed bug #5933: PHPUnit2_Framework_TestSuite::addTestFile() and non-working directories. + - Removed PHPUnit2_Framework_Assert::setLooselyTyped(). - Removed dependency on the Benchmark_Timer, Console_Getopt, and PEAR_Config PEAR classes. @@ -520,6 +522,42 @@ <dir name="Util" role="php"> <dir name="CodeCoverage"> <dir name="Renderer"> + <dir name="HTML"> + <dir name="Template"> + <file name="amber.png"/> + <file name="directory.htm"/> + <file name="emerald.png"/> + <file name="file.htm"/> + <file name="glass.png"/> + <file name="item.htm"/> + <file name="ruby.png"/> + <file name="snow.png"/> + <file name="style.css"/> + </dir> + + <dir name="Tree"> + <dir name="Node"> + <file name="Directory.php"> + <replace type="package-info" from="@package_version@" to="version"/> + </file> + <file name="File.php"> + <replace type="package-info" from="@package_version@" to="version"/> + </file> + </dir> + + <file name="Factory.php"> + <replace type="package-info" from="@package_version@" to="version"/> + </file> + <file name="Node.php"> + <replace type="package-info" from="@package_version@" to="version"/> + </file> + </dir> + + <file name="Template.php"> + <replace type="package-info" from="@package_version@" to="version"/> + </file> + </dir> + <file name="HTML.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Template.php?view=markup&rev=1.1 Index: pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Template.php +++ pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Template.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * PHP Version 5 * * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of Sebastian Bergmann nor the names of his * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @category Testing * @package PHPUnit2 * @author Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @version CVS: $Id: Template.php,v 1.1 2006/02/25 08:30:43 sebastian Exp $ * @link http://pear.php.net/package/PHPUnit2 * @since File available since Release 3.0.0 */ require_once 'PHPUnit2/Util/Filter.php'; PHPUnit2_Util_Filter::addFileToFilter(__FILE__); /** * * * @category Testing * @package PHPUnit2 * @author Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @version Release: @package_version@ * @link http://pear.php.net/package/PHPUnit2 * @since Class available since Release 3.0.0 */ class PHPUnit2_Util_CodeCoverage_Renderer_HTML_Template { /** * @var array * @access private */ private $template = ''; /** * @var array * @access private */ private $keys = array(); /** * @var array * @access private */ private $values = array(); /** * Constructor. * * @param string $file * @throws InvalidArgumentException * @access public */ public function __construct($file = '') { $this->setFile($file); } /** * Sets the template file. * * @param string $file * @throws InvalidArgumentException * @access public */ public function setFile($file) { if ($file != '' && file_exists($file)) { $this->template = file_get_contents($file); } else { throw new InvalidArgumentException( 'Template file could not be loaded.' ); } } /** * Sets one or more template variables. * * @param mixed $keys * @param mixed $values * @access public */ public function setVar($keys, $values) { if (is_array($keys) && is_array($values) && sizeof($keys) == sizeof($values)) { foreach ($keys as $key) { $this->keys[] = '{' . $key . '}'; } $this->values = array_merge($this->values, $values); } else { $this->keys[] = '{' . $keys . '}'; $this->values[] = $values; } } /** * Renders the template and returns the result. * * @return $string * @access public */ public function render() { return str_replace($this->keys, $this->values, $this->template); } } /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * c-hanging-comment-ender-p: nil * End: */ ?> http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Template/directory.htm?view=markup&rev=1.1 Index: pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Template/directory.htm +++ pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Template/directory.htm <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>{title}</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr><td class="title">{title}</td></tr> <tr><td class="ruler"><img src="glass.png" width="3" height="3" alt=""></td></tr> <tr> <td width="100%"> <table cellpadding="1" border="0" width="100%"> <tr> <td class="headerItem" width="20%">Current view:</td> <td class="headerValue" width="80%" colspan="4">{path}</td> </tr> <tr> <td class="headerItem" width="20%">Date:</td> <td class="headerValue" width="20%">{date}</td> <td width="20%"></td> <td class="headerItem" width="20%">Executable lines:</td> <td class="headerValue" width="20%">{executable_lines}</td> </tr> <tr> <td class="headerItem" width="20%">Code covered:</td> <td class="headerValue" width="20%">{executed_percent}%</td> <td width="20%"></td> <td class="headerItem" width="20%">Executed lines:</td> <td class="headerValue" width="20%">{executed_lines}</td> </tr> <tr> <td class="legendItem" width="20%">Legend:</td> <td class="legendValue" width="80%" colspan="4"> <span class="coverLegendLo"> <b>Low:</b> 0% to 15% </span> <span class="coverLegendMed"> <b>Medium:</b> 15% to 50% </span> <span class="coverLegendHi"> <b>High:</b> 50% to 100% </span> </td> </tr> </table> </td> </tr> <tr> <td class="ruler"><img src="glass.png" width="3" height="3" alt=""></td> </tr> </table> <center> <table width="80%" cellpadding=2 cellspacing=1 border=0> <tr> <td width="50%"><br></td> <td width="15%"></td> <td width="15%"></td> <td width="20%"></td> </tr> <tr> <td class="tableHead"></td> <td class="tableHead" colspan="3">Coverage</td> </tr> {items} </table> </center> <br/> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr><td class="ruler"><img src="glass.png" width="3" height="3" alt=""></td></tr> <tr><td class="versionInfo">Generated by: <a href="http://www.phpunit.de/">PHPUnit {phpunit_version}</a> and <a href="http://www.xdebug.org/">Xdebug {xdebug_version}</a>.</td></tr> </table> <br/> </body> </html> http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Template/file.htm?view=markup&rev=1.1 Index: pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Template/file.htm +++ pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Template/file.htm <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>{title}</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr><td class="title">{title}</td></tr> <tr><td class="ruler"><img src="glass.png" width="3" height="3" alt=""></td></tr> <tr> <td width="100%"> <table cellpadding=1 border=0 width="100%"> <tr> <td class="headerItem" width="20%">Current view:</td> <td class="headerValue" width="80%" colspan="4">{path}</td> </tr> <tr> <td class="headerItem" width="20%">Date:</td> <td class="headerValue" width="20%">{date}</td> <td width="20%"></td> <td class="headerItem" width="20%">Executable lines:</td> <td class="headerValue" width="20%">{executable_lines}</td> </tr> <tr> <td class="headerItem" width="20%">Code covered:</td> <td class="headerValue" width="20%">{executed_percent}%</td> <td width="20%"></td> <td class="headerItem" width="20%">Executed lines:</td> <td class="headerValue" width="20%">{executed_lines}</td> </tr> <tr> <td class="legendItem" width="20%">Legend:</td> <td class="legendValue" width="80%" colspan="4"> <span class="legendNoCov">not executed</span> <span class="legendCov">executed</span> </td> </tr> </table> </td> </tr> <tr> <td class="ruler"><img src="glass.png" width="3" height="3" alt=""></td> </tr> </table> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td><br /></td> </tr> <tr> <td> <pre class="source"> {lines} </pre> </td> </tr> </table> <br /> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr><td class="ruler"><img src="glass.png" width="3" height="3" alt=""></td></tr> <tr><td class="versionInfo">Generated by: <a href="http://www.phpunit.de/">PHPUnit {phpunit_version}</a> and <a href="http://www.xdebug.org/">Xdebug {xdebug_version}</a>.</td></tr> </table> <br /> </body> </html> http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Template/item.htm?view=markup&rev=1.1 Index: pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Template/item.htm +++ pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Template/item.htm <tr> <td class="coverFile"><a href="{url}.htm">{name}</a></td> <td class="coverBar" align="center"> <table border="0" cellspacing="0" cellpadding="1"> <tr> <td class="coverBarOutline"><img src="{color}.png" width="{executed_width}" height="10" alt="{executed_percent} %"><img src="snow.png" width="{not_executed_width}" height="10" alt="{executed_percent} %"></td> </tr> </table> </td> <td class="coverPer{level}">{executed_percent} %</td> <td class="coverNum{level}">{executed_lines} / {executable_lines} lines</td> </tr> http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Template/style.css?view=markup&rev=1.1 Index: pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Template/style.css +++ pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Template/style.css /* All views: initial background and text color */ body { color: #000000; background-color: #FFFFFF; } /* All views: standard link format*/ a:link { color: #284FA8; text-decoration: underline; } /* All views: standard link - visited format */ a:visited { color: #00CB40; text-decoration: underline; } /* All views: standard link - activated format */ a:active { color: #FF0040; text-decoration: underline; } /* All views: main title format */ td.title { text-align: center; padding-bottom: 10px; font-family: sans-serif; font-size: 20pt; font-style: italic; font-weight: bold; } /* All views: header item format */ td.headerItem { text-align: right; padding-right: 6px; font-family: sans-serif; font-weight: bold; } /* All views: header item value format */ td.headerValue { text-align: left; color: #284FA8; font-family: sans-serif; font-weight: bold; } /* All views: header legend item format */ td.legendItem { text-align: right; padding-right: 6px; padding-top: 10px; padding-bottom: 2px; font-family: sans-serif; font-weight: bold; } /* All views: header legend item value format */ td.legendValue { text-align: left; padding-top: 10px; padding-bottom: 2px; color: #000000; font-family: sans-serif; font-weight: bold; } /* All views: color of horizontal ruler */ td.ruler { background-color: #6688D4; } /* All views: version string format */ td.versionInfo { text-align: center; padding-top: 2px; font-family: sans-serif; font-style: italic; } /* Directory view/File view (all)/Test case descriptions: table headline format */ td.tableHead { text-align: center; color: #FFFFFF; background-color: #6688D4; font-family: sans-serif; font-size: 120%; font-weight: bold; } /* Directory view/File view (all): filename entry format */ td.coverFile { text-align: left; padding-left: 10px; padding-right: 20px; color: #284FA8; background-color: #DAE7FE; font-family: monospace; } /* Directory view/File view (all): bar-graph entry format*/ td.coverBar { padding-left: 10px; padding-right: 10px; background-color: #DAE7FE; } /* Directory view/File view (all): bar-graph outline color */ td.coverBarOutline { background-color: #000000; } /* Directory view/File view (all): percentage entry for files with high coverage rate */ td.coverPerHi { text-align: right; padding-left: 10px; padding-right: 10px; background-color: #A7FC9D; font-weight: bold; } /* Directory view/File view (all): line count entry for files with high coverage rate */ td.coverNumHi { text-align: right; padding-left: 10px; padding-right: 10px; background-color: #A7FC9D; } /* Directory view/File view (all): legend entry for high coverage rate */ span.coverLegendHi { text-align: center; padding-left: 10px; padding-right: 10px; background-color: #A7FC9D; } /* Directory view/File view (all): percentage entry for files with medium coverage rate */ td.coverPerMed { text-align: right; padding-left: 10px; padding-right: 10px; background-color: #FFEA20; font-weight: bold; } /* Directory view/File view (all): line count entry for files with medium coverage rate */ td.coverNumMed { text-align: right; padding-left: 10px; padding-right: 10px; background-color: #FFEA20; } /* Directory view/File view (all): legend entry for medium coverage rate */ span.coverLegendMed { text-align: center; padding-left: 10px; padding-right: 10px; margin-top: 5px; margin-bottom: 5px; margin-right: 2px; background-color: #FFEA20; } /* Directory view/File view (all): percentage entry for files with low coverage rate */ td.coverPerLo { text-align: right; padding-left: 10px; padding-right: 10px; background-color: #FF0000; font-weight: bold; } /* Directory view/File view (all): line count entry for files with low coverage rate */ td.coverNumLo { text-align: right; padding-left: 10px; padding-right: 10px; background-color: #FF0000; } /* Directory view/File view (all): legend entry for low coverage rate */ span.coverLegendLo { text-align: center; padding-left: 10px; padding-right: 10px; margin-right: 2px; background-color: #FF0000; } /* File view (all): "show/hide details" link format */ a.detail:link { color: #B8D0FF; } /* File view (all): "show/hide details" link - visited format */ a.detail:visited { color: #B8D0FF; } /* File view (all): "show/hide details" link - activated format */ a.detail:active { color: #FFFFFF; } /* File view (detail): test name table headline format */ td.testNameHead { text-align: right; padding-right: 10px; background-color: #DAE7FE; font-family: sans-serif; font-weight: bold; } /* File view (detail): test lines table headline format */ td.testLinesHead { text-align: center; background-color: #DAE7FE; font-family: sans-serif; font-weight: bold; } /* File view (detail): test name entry */ td.testName { text-align: right; padding-right: 10px; background-color: #DAE7FE; } /* File view (detail): test percentage entry */ td.testPer { text-align: right; padding-left: 10px; padding-right: 10px; background-color: #DAE7FE; } /* File view (detail): test lines count entry */ td.testNum { text-align: right; padding-left: 10px; padding-right: 10px; background-color: #DAE7FE; } /* Test case descriptions: test name format*/ dt { font-family: sans-serif; font-weight: bold; } /* Test case descriptions: description table body */ td.testDescription { padding-top: 10px; padding-left: 30px; padding-bottom: 10px; padding-right: 30px; background-color: #DAE7FE; } /* Source code view: source code format */ pre.source { font-family: monospace; white-space: pre; } /* Source code view: line number format */ span.lineNum { background-color: #EFE383; } /* Source code view: format for lines which were executed */ span.lineCov { background-color: #CAD7FE; } /* Source code view: format for Cov legend */ span.LegendCov { text-align: center; padding-left: 10px; padding-right: 10px; margin-right: 2px; background-color: #CAD7FE; } /* Source code view: format for lines which were not executed */ span.lineNoCov { background-color: #FF6230; } /* Source code view: format for NoCov legend */ span.LegendNoCov { text-align: center; padding-left: 10px; padding-right: 10px; margin-right: 2px; background-color: #FF6230; } /* Source code view: format for lines which were executed only in a previous version */ span.lineDiffCov { background-color: #B5F7AF; } /* Source code view: format for DiffCov legend */ span.LegendDiffCov { text-align: center; padding-left: 10px; padding-right: 10px; background-color: #B5F7AF; } http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Tree/Factory.php?view=markup&rev=1.1 Index: pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Tree/Factory.php +++ pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Tree/Factory.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * PHP Version 5 * * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of Sebastian Bergmann nor the names of his * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @category Testing * @package PHPUnit2 * @author Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @version CVS: $Id: Factory.php,v 1.1 2006/02/25 08:30:43 sebastian Exp $ * @link http://pear.php.net/package/PHPUnit2 * @since File available since Release 3.0.0 */ require_once 'PHPUnit2/Util/Classloader.php'; require_once 'PHPUnit2/Util/Filter.php'; PHPUnit2_Util_Classloader::import( array( 'PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node_Directory', 'PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node_File', ) ); PHPUnit2_Util_Filter::addFileToFilter(__FILE__); /** * * * @category Testing * @package PHPUnit2 * @author Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @version Release: @package_version@ * @link http://pear.php.net/package/PHPUnit2 * @since Class available since Release 3.0.0 */ class PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Factory { /** * Creates a new Code Coverage information tree. * * @param array $files * @access public * @static */ public static function create($files) { $commonPath = self::reducePaths($files); $directory = self::buildDirectoryStructure($files); $root = new PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node_Directory( $commonPath ); self::addItems($root, $directory['.']); return $root; } /** * @param PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node_Directory $root * @param array $items * @access protected * @static */ protected static function addItems($root, $items) { foreach ($items as $key => $value) { if (substr($key, -4) == '.php') { $root->addFile($key, $value); } else { $child = $root->addDirectory($key); self::addItems($child, $value); } } } /** * Reduces the paths by cutting the longest common start path. * * For instance, * * <code> * Array * ( * [/home/sb/PHPUnit2/Samples/Money/Money.php] => Array * ( * ... * ) * * [/home/sb/PHPUnit2/Samples/Money/MoneyBag.php] => Array * ( * ... * ) * ) * </code> * * is reduced to * * <code> * Array * ( * [Money.php] => Array * ( * ... * ) * * [MoneyBag.php] => Array * ( * ... * ) * ) * </code> * * @param array $files * @return string * @access protected * @static */ protected static function reducePaths(&$files) { $commonPath = ''; $paths = array_keys($files); for ($i = 0; $i < sizeof($paths); $i++) { $paths[$i] = explode(DIRECTORY_SEPARATOR, $paths[$i]); if (empty($paths[$i][0])) { $paths[$i][0] = DIRECTORY_SEPARATOR; } } $done = FALSE; while (!$done) { for ($i = 0; $i < sizeof($paths)-1; $i++) { if (!isset($paths[$i][0]) || !isset($paths[$i+1][0]) || $paths[$i][0] != $paths[$i+1][0]) { $done = TRUE; break; } } if (!$done) { $commonPath .= $paths[0][0] . (($paths[0][0] != DIRECTORY_SEPARATOR) ? DIRECTORY_SEPARATOR : ''); for ($i = 0; $i < sizeof($paths); $i++) { array_shift($paths[$i]); } } } $original = array_keys($files); for ($i = 0; $i < sizeof($original); $i++) { $files[join('/', $paths[$i])] = $files[$original[$i]]; unset($files[$original[$i]]); } ksort($files); return $commonPath; } /** * Builds an array representation of the directory structure. * * For instance, * * <code> * Array * ( * [Money.php] => Array * ( * ... * ) * * [MoneyBag.php] => Array * ( * ... * ) * ) * </code> * * is transformed into * * <code> * Array * ( * [.] => Array * ( * [Money.php] => Array * ( * ... * ) * * [MoneyBag.php] => Array * ( * ... * ) * ) * ) * </code> * * @param array $files * @return array * @access protected * @static */ protected static function buildDirectoryStructure($files) { $result = array(); foreach ($files as $key => $value) { $file = basename($key); $path = explode(DIRECTORY_SEPARATOR, dirname($key)); $pointer = &$result; foreach ($path as $p) { if (!array_key_exists($p, $pointer)) { $pointer[$p] = array(); } $pointer = &$pointer[$p]; } $pointer[$file] = $value; } return $result; } } /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * c-hanging-comment-ender-p: nil * End: */ ?> http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Tree/Node.php?view=markup&rev=1.1 Index: pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Tree/Node.php +++ pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Tree/Node.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * PHP Version 5 * * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of Sebastian Bergmann nor the names of his * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @category Testing * @package PHPUnit2 * @author Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @version CVS: $Id: Node.php,v 1.1 2006/02/25 08:30:43 sebastian Exp $ * @link http://pear.php.net/package/PHPUnit2 * @since File available since Release 3.0.0 */ require_once 'PHPUnit2/Util/Filter.php'; PHPUnit2_Util_Filter::addFileToFilter(__FILE__); /** * * * @category Testing * @package PHPUnit2 * @author Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @version Release: @package_version@ * @link http://pear.php.net/package/PHPUnit2 * @since Class available since Release 3.0.0 */ abstract class PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node { /** * @var string * @access protected */ protected $name; /** * @var PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node * @access protected */ protected $parent; /** * Constructor. * * @param string $name * @param PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node $parent * @access public */ public function __construct($name, PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node $parent = NULL) { $this->name = $name; $this->parent = $parent; } /** * Returns this node's ID. * * @return string * @access public */ public function getId() { if ($this->parent === NULL) { return 'index'; } else { return str_replace('index_', '', $this->parent->getId() . '_' . strtolower($this->getName())); } } /** * Returns the link to this node. * * @return string * @access public */ public function getLink() { return sprintf( '%s<a href="%s.htm">%s</a>', $this->parent !== NULL ? $this->parent->getLink() : '', $this->getId(), $this->getName() ); } /** * Returns this node's name. * * @return string * @access public */ public function getName() { return $this->name; } /** * Returns this node's path. * * @return string * @access public */ public function getPath() { if ($this->parent === NULL) { return $this->getName(); } else { return $this->parent->getPath() . DIRECTORY_SEPARATOR . $this->getName(); } } /** * Returns the percentage of executed lines. * * @return integer * @access public */ public function getExecutedPercent() { return sprintf( '%01.2f', ($this->getNumExecutedLines() / $this->getNumExecutableLines()) * 100 ); } /** * Returns the number of executable lines. * * @return integer * @access public * @abstract */ abstract public function getNumExecutableLines(); /** * Returns the number of executed lines. * * @return integer * @access public * @abstract */ abstract public function getNumExecutedLines(); /** * Renders the node to HTML. * * @param string $target * @access public * @abstract */ abstract public function render($target); } /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * c-hanging-comment-ender-p: nil * End: */ ?> http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Tree/Node/Directory.php?view=markup&rev=1.1 Index: pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Tree/Node/Directory.php +++ pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Tree/Node/Directory.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * PHP Version 5 * * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of Sebastian Bergmann nor the names of his * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @category Testing * @package PHPUnit2 * @author Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @version CVS: $Id: Directory.php,v 1.1 2006/02/25 08:30:43 sebastian Exp $ * @link http://pear.php.net/package/PHPUnit2 * @since File available since Release 3.0.0 */ require_once 'PHPUnit2/Util/Classloader.php'; require_once 'PHPUnit2/Util/Filter.php'; PHPUnit2_Util_Classloader::import( array( 'PHPUnit2_Util_CodeCoverage_Renderer_HTML_Template', 'PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node', ) ); PHPUnit2_Util_Filter::addFileToFilter(__FILE__); /** * * * @category Testing * @package PHPUnit2 * @author Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @version Release: @package_version@ * @link http://pear.php.net/package/PHPUnit2 * @since Class available since Release 3.0.0 */ class PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node_Directory extends PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node { /** * @var array * @access protected */ protected $children = array(); /** * Adds a new directory. * * @return PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node_Directory * @access public */ public function addDirectory($name) { $directory = new PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node_Directory( $name, $this ); $this->children[] = $directory; return $directory; } /** * Adds a new file. * * @param string $name * @param array $lines * @access public */ public function addFile($name, $lines) { $file = new PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node_File( $name, $this, $lines ); $this->children[] = $file; } /** * Returns the number of executable lines. * * @return integer * @access public */ public function getNumExecutableLines() { $numExecutableLines = 0; foreach ($this->children as $child) { $numExecutableLines += $child->getNumExecutableLines(); } return $numExecutableLines; } /** * Returns the number of executed lines. * * @return integer * @access public */ public function getNumExecutedLines() { $numExecutedLines = 0; foreach ($this->children as $child) { $numExecutedLines += $child->getNumExecutedLines(); } return $numExecutedLines; } /** * Renders the node to HTML. * * @param string $target * @access public */ public function render($target) { $template = new PHPUnit2_Util_CodeCoverage_Renderer_HTML_Template( PHPUnit2_Util_CodeCoverage_Renderer_HTML::getTemplatePath() . 'directory.htm' ); $items = ''; foreach ($this->children as $child) { $itemTemplate = new PHPUnit2_Util_CodeCoverage_Renderer_HTML_Template( PHPUnit2_Util_CodeCoverage_Renderer_HTML::getTemplatePath() . 'item.htm' ); $floorPercent = floor($child->getExecutedPercent()); if ($floorPercent < 15) { $color = 'ruby'; $level = 'Lo'; } else if ($floorPercent >= 15 && $floorPercent < 50) { $color = 'amber'; $level = 'Med'; } else { $color = 'emerald'; $level = 'Hi'; } $itemTemplate->setVar( array( 'url', 'name', 'color', 'level', 'executed_width', 'executed_percent', 'not_executed_width', 'executable_lines', 'executed_lines', ), array( $child->getId(), $child->getName(), $color, $level, floor($child->getExecutedPercent()), $child->getExecutedPercent(), 100 - floor($child->getExecutedPercent()), $child->getNumExecutableLines(), $child->getNumExecutedLines() ) ); $items .= $itemTemplate->render(); } $template->setVar( array( 'path', 'executable_lines', 'executed_lines', 'executed_percent', 'items', 'date', 'phpunit_version', 'xdebug_version', ), array( $this->getLink(), $this->getNumExecutableLines(), $this->getNumExecutedLines(), $this->getExecutedPercent(), $items, date('D M j G:i:s T Y'), PHPUnit2_Runner_Version::id(), phpversion('xdebug') ) ); $fp = fopen($target . $this->getId() . '.htm', 'w'); fputs($fp, $template->render()); fclose($fp); foreach ($this->children as $child) { $child->render($target); } } } /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * c-hanging-comment-ender-p: nil * End: */ ?> http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Tree/Node/File.php?view=markup&rev=1.1 Index: pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Tree/Node/File.php +++ pear/PHPUnit2/Util/CodeCoverage/Renderer/HTML/Tree/Node/File.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * PHP Version 5 * * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of Sebastian Bergmann nor the names of his * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @category Testing * @package PHPUnit2 * @author Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @version CVS: $Id: File.php,v 1.1 2006/02/25 08:30:43 sebastian Exp $ * @link http://pear.php.net/package/PHPUnit2 * @since File available since Release 3.0.0 */ require_once 'PHPUnit2/Util/Classloader.php'; require_once 'PHPUnit2/Util/Filter.php'; PHPUnit2_Util_Classloader::import( array( 'PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node', ) ); PHPUnit2_Util_Filter::addFileToFilter(__FILE__); /** * * * @category Testing * @package PHPUnit2 * @author Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @version Release: @package_version@ * @link http://pear.php.net/package/PHPUnit2 * @since Class available since Release 3.0.0 */ class PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node_File extends PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node { /** * @var array * @access protected */ protected $lines; /** * Constructor. * * @param string $name * @param PHPUnit2_Util_CodeCoverage_Renderer_HTML_Tree_Node $parent * @param array $lines * @access public */ public function __construct($name, $parent, $lines) { parent::__construct($name, $parent); $this->lines = $lines; } /** * Returns the number of executable lines. * * @return integer * @access public */ public function getNumExecutableLines() { return sizeof($this->lines); } /** * Returns the number of executed lines. * * @return integer * @access public */ public function getNumExecutedLines() { $numExecutedLines = 0; foreach ($this->lines as $line => $flag) { if ($flag > 0) { $numExecutedLines++; } } return $numExecutedLines; } /** * Renders the node to HTML. * * @param string $target * @access public */ public function render($target) { $template = new PHPUnit2_Util_CodeCoverage_Renderer_HTML_Template( PHPUnit2_Util_CodeCoverage_Renderer_HTML::getTemplatePath() . 'file.htm' ); $file = file($this->getPath()); $i = 1; $lines = ''; foreach ($file as $line) { $css = ''; if (isset($this->lines[$i])) { if ($this->lines[$i] > 0) { $css = '<span class="lineCov">'; } else { $css = '<span class="lineNoCov">'; } } $lines .= sprintf( '<span class="lineNum">%6d</span> %s%s%s' . "\n", $i, $css, htmlspecialchars(rtrim($line)), !empty($css) ? '</span>' : '' ); $i++; } $template->setVar( array( 'path', 'executable_lines', 'executed_lines', 'executed_percent', 'lines', 'date', 'phpunit_version', 'xdebug_version', ), array( $this->getLink(), $this->getNumExecutableLines(), $this->getNumExecutedLines(), $this->getExecutedPercent(), $lines, date('D M j G:i:s T Y'), PHPUnit2_Runner_Version::id(), phpversion('xdebug') ) ); $fp = fopen($target . $this->getId() . '.htm', 'w'); fputs($fp, $template->render()); fclose($fp); } } /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * c-hanging-comment-ender-p: nil * End: */ ?>