PHPUnit2
[ class tree: PHPUnit2 ] [ index: PHPUnit2 ] [ all elements ]

Source for file HTML.php

Documentation is available at HTML.php

  1. <?php
  2. //
  3. // +------------------------------------------------------------------------+
  4. // | PEAR :: PHPUnit2                                                       |
  5. // +------------------------------------------------------------------------+
  6. // | Copyright (c) 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de>. |
  7. // +------------------------------------------------------------------------+
  8. // | This source file is subject to version 3.00 of the PHP License,        |
  9. // | that is available at http://www.php.net/license/3_0.txt.               |
  10. // | If you did not receive a copy of the PHP license and are unable to     |
  11. // | obtain it through the world-wide-web, please send a note to            |
  12. // | license@php.net so we can mail you a copy immediately.                 |
  13. // +------------------------------------------------------------------------+
  14. //
  15. // $Id: HTML.php,v 1.12.2.1 2004/12/22 08:06:07 sebastian Exp $
  16. //
  17.  
  18. require_once 'PHPUnit2/Extensions/CodeCoverage/Renderer.php';
  19.  
  20. /**
  21.  * Renders Code Coverage information in HTML format.
  22.  *
  23.  * Formatting of the generated HTML can be achieved through
  24.  * CSS (codecoverage.css).
  25.  *
  26.  * Example
  27.  *
  28.  * <code>
  29.  * td.ccLineNumber, td.ccCoveredLine, td.ccUncoveredLine, td.ccNotExecutableLine {
  30.  *   font-family: monospace;
  31.  *   white-space: pre;
  32.  * }
  33.  *
  34.  * td.ccLineNumber, td.ccCoveredLine {
  35.  *   background-color: #aaaaaa;
  36.  * }
  37.  *
  38.  * td.ccNotExecutableLine {
  39.  *   color: #aaaaaa;
  40.  * }
  41.  * </code>
  42.  *
  43.  * @author      Sebastian Bergmann <sb@sebastian-bergmann.de>
  44.  * @copyright   Copyright &copy; 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de>
  45.  * @license     http://www.php.net/license/3_0.txt The PHP License, Version 3.0
  46.  * @category    Testing
  47.  * @package     PHPUnit2
  48.  * @subpackage  Extensions
  49.  * @since       2.1.0
  50.  */
  51.     // {{{ Constants
  52.  
  53.     const pageHeader =
  54. '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  55.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  56.  
  57. <html xmlns="http://www.w3.org/1999/xhtml">
  58.   <head>
  59.     <link href="codecoverage.css" type="text/css" rel="stylesheet" />
  60.   </head>
  61.   <body>
  62. ';
  63.  
  64.     const pageFooter =
  65. '  </body>
  66. </html>
  67. ';
  68.  
  69.     const sourceFileHeader =
  70. '   <table style="border: 1px solid black" cellspacing="0" cellpadding="0" width="100%">
  71. ';
  72.  
  73.     const sourceFileFooter =
  74. '   </table>
  75. ';
  76.  
  77.     const codeLine =
  78. '     <tr><td class="ccLineNumber">%s</td><td class="%s">%s</td></tr>
  79. ';
  80.  
  81.     // }}}
  82.     // {{{ protected function header()
  83.  
  84.     /**
  85.     * @return string 
  86.     * @access protected
  87.     * @since  2.1.1
  88.     */
  89.     protected function header({
  90.         return self::pageHeader;
  91.     }
  92.  
  93.     // }}}
  94.     // {{{ protected function footer()
  95.  
  96.     /**
  97.     * @return string 
  98.     * @access protected
  99.     * @since  2.1.1
  100.     */
  101.     protected function footer({
  102.         return self::pageFooter;
  103.     }
  104.  
  105.     // }}}
  106.     // {{{ protected function startSourceFile($sourceFile)
  107.  
  108.     /**
  109.     * @param  string $sourceFile 
  110.     * @return string 
  111.     * @access protected
  112.     */
  113.     protected function startSourceFile($sourceFile{
  114.         return self::sourceFileHeader;
  115.     }
  116.  
  117.     // }}}
  118.     // {{{ protected function endSourceFile($sourceFile)
  119.  
  120.     /**
  121.     * @param  string $sourceFile 
  122.     * @return string 
  123.     * @access protected
  124.     */
  125.     protected function endSourceFile($sourceFile{
  126.         return self::sourceFileFooter;
  127.     }
  128.  
  129.     // }}}
  130.     // {{{ protected function renderSourceFile($codeLines, $executedLines)
  131.  
  132.     /**
  133.     * @param  array $codeLines 
  134.     * @param  array $executedLines 
  135.     * @return string 
  136.     * @access protected
  137.     */
  138.     protected function renderSourceFile($codeLines$executedLines{
  139.         $buffer '';
  140.         $line   = 1;
  141.  
  142.         foreach ($codeLines as $codeLine{
  143.             $lineStyle 'ccNotExecutableLine';
  144.  
  145.             if (isset($executedLines[$line])) {
  146.                 if ($executedLines[$line> 0{
  147.                     $lineStyle 'ccCoveredLine';
  148.                 else {
  149.                     $lineStyle 'ccUncoveredLine';
  150.                 }
  151.             }
  152.  
  153.             $buffer .= sprintf(
  154.               self::codeLine,
  155.  
  156.               $line,
  157.               $lineStyle,
  158.               htmlspecialchars(rtrim($codeLine))
  159.             );
  160.  
  161.             $line++;
  162.         }
  163.  
  164.         return $buffer;
  165.     }
  166.  
  167.     // }}}
  168. }
  169.  
  170. /*
  171.  * vim600:  et sw=2 ts=2 fdm=marker
  172.  * vim<600: et sw=2 ts=2
  173.  */
  174. ?>

Documentation generated on Mon, 11 Mar 2019 14:19:18 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.