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-2004 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.1.2.4 2004/10/01 06:43:52 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 {
  30.  *   font-family: monospace;
  31.  *   white-space:pre;
  32.  * }
  33.  *
  34.  * td.ccLineNumber, td.ccCoveredLine {
  35.  *   background-color: #aaaaaa;
  36.  * }
  37.  * </code>
  38.  *
  39.  * @author      Sebastian Bergmann <sb@sebastian-bergmann.de>
  40.  * @copyright   Copyright &copy; 2002-2004 Sebastian Bergmann <sb@sebastian-bergmann.de>
  41.  * @license     http://www.php.net/license/3_0.txt The PHP License, Version 3.0
  42.  * @category    Testing
  43.  * @package     PHPUnit2
  44.  * @subpackage  Extensions
  45.  * @since       2.1.0
  46.  */
  47.     // {{{ Constants
  48.  
  49.     const templatePageHeader =
  50. '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  51.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  52.  
  53. <html xmlns="http://www.w3.org/1999/xhtml">
  54.   <head>
  55.     <link href="codecoverage.css" type="text/css" rel="stylesheet" />
  56.   </head>
  57.   <body>
  58. ';
  59.  
  60.     const templatePageFooter =
  61. '  </body>
  62. </html>
  63. ';
  64.  
  65.     const templateSourceFileHeader =
  66. '   <table style="border: 1px solid black" cellspacing="0" cellpadding="0" width="100%">
  67. ';
  68.  
  69.     const templateSourceFileFooter =
  70. '   </table>
  71. ';
  72.  
  73.     const templateCodeLine =
  74. '     <tr><td class="ccLineNumber">%s</td><td class="ccLineNumber">%s</td><td class="%s">%s</td></tr>
  75. ';
  76.  
  77.     // }}}
  78.     // {{{ protected function header()
  79.  
  80.     /**
  81.     * @return string 
  82.     * @access protected
  83.     * @since  2.1.1
  84.     */
  85.     protected function header({
  86.         return self::templatePageHeader;
  87.     }
  88.  
  89.     // }}}
  90.     // {{{ protected function footer()
  91.  
  92.     /**
  93.     * @return string 
  94.     * @access protected
  95.     * @since  2.1.1
  96.     */
  97.     protected function footer({
  98.         return self::templatePageFooter;
  99.     }
  100.  
  101.     // }}}
  102.     // {{{ protected function startSourceFile($sourceFile)
  103.  
  104.     /**
  105.     * @param  string $sourceFile 
  106.     * @return string 
  107.     * @access protected
  108.     */
  109.     protected function startSourceFile($sourceFile{
  110.         return self::templateSourceFileHeader;
  111.     }
  112.  
  113.     // }}}
  114.     // {{{ protected function endSourceFile($sourceFile)
  115.  
  116.     /**
  117.     * @param  string $sourceFile 
  118.     * @return string 
  119.     * @access protected
  120.     */
  121.     protected function endSourceFile($sourceFile{
  122.         return self::templateSourceFileFooter;
  123.     }
  124.  
  125.     // }}}
  126.     // {{{ protected function renderSourceFile($codeLines, $executedLines)
  127.  
  128.     /**
  129.     * @param  array $codeLines 
  130.     * @param  array $executedLines 
  131.     * @return string 
  132.     * @access protected
  133.     */
  134.     protected function renderSourceFile($codeLines$executedLines{
  135.         $buffer '';
  136.         $line   = 1;
  137.  
  138.         foreach ($codeLines as $codeLine{
  139.             $buffer .= sprintf(
  140.               self::templateCodeLine,
  141.  
  142.               $line,
  143.               (isset($executedLines[$line])) $executedLines[$line'x' '',
  144.               (isset($executedLines[$line])) 'ccCoveredLine' 'ccUncoveredLine',
  145.               htmlspecialchars(rtrim($codeLine))
  146.             );
  147.  
  148.             $line++;
  149.         }
  150.  
  151.         return $buffer;
  152.     }
  153.  
  154.     // }}}
  155. }
  156.  
  157. /*
  158.  * vim600:  et sw=2 ts=2 fdm=marker
  159.  * vim<600: et sw=2 ts=2
  160.  */
  161. ?>

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