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

Source for file Renderer.php

Documentation is available at Renderer.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: Renderer.php,v 1.1.2.2 2004/10/01 06:11:52 sebastian Exp $
  16. //
  17.  
  18. /**
  19.  * Abstract base class for Code Coverage renderers.
  20.  *
  21.  * @author      Sebastian Bergmann <sb@sebastian-bergmann.de>
  22.  * @copyright   Copyright &copy; 2002-2004 Sebastian Bergmann <sb@sebastian-bergmann.de>
  23.  * @license     http://www.php.net/license/3_0.txt The PHP License, Version 3.0
  24.  * @category    Testing
  25.  * @package     PHPUnit2
  26.  * @subpackage  Extensions
  27.  * @since       2.1.0
  28.  * @abstract
  29.  */
  30.     // {{{ Members
  31.  
  32.     /**
  33.     * @var    array 
  34.     * @access protected
  35.     */
  36.     protected $codeCoverageInformation;
  37.  
  38.     // }}}
  39.     // {{{ protected function __construct($codeCoverageInformation)
  40.  
  41.     /**
  42.     * Constructor.
  43.     *
  44.     * @param  array $codeCoverageInformation 
  45.     * @access protected
  46.     */
  47.     protected function __construct($codeCoverageInformation{
  48.         $this->codeCoverageInformation = $codeCoverageInformation;
  49.     }
  50.  
  51.     // }}}
  52.     // {{{ public function factory($type, $codeCoverageInformation)
  53.  
  54.     /**
  55.     * Abstract Factory.
  56.     *
  57.     * @param  string  $type 
  58.     * @param  array   $codeCoverageInformation 
  59.     * @access public
  60.     */
  61.     public function factory($type$codeCoverageInformation{
  62.         $class  'PHPUnit2_Extensions_CodeCoverage_Renderer_' $type;
  63.  
  64.         if (@require_once('PHPUnit2/Extensions/CodeCoverage/Renderer/' $type '.php')) {
  65.             $object = new $class($codeCoverageInformation);
  66.  
  67.             return $object;
  68.         else {
  69.             throw new Exception(
  70.               sprintf(
  71.                 'Could not load class %s.',
  72.                 $class
  73.               )
  74.             );
  75.         }
  76.     }
  77.  
  78.     // }}}
  79.     // {{{ public function render()
  80.  
  81.     /**
  82.     * Visualizes the result array of
  83.     * PHPUnit2_Framework_TestResult::getCodeCoverageInformation().
  84.     *
  85.     * @return string 
  86.     * @access public
  87.     * @final
  88.     */
  89.     public final function render({
  90.         $buffer $this->header();
  91.  
  92.         foreach ($this->codeCoverageInformation as $testCaseName => $sourceFiles{
  93.             $buffer .= $this->startTestCase($testCaseName);
  94.  
  95.             foreach ($sourceFiles as $sourceFile => $executedLines{
  96.                 $buffer .= $this->startSourceFile($sourceFile);
  97.                 $buffer .= $this->renderSourceFile(file($sourceFile)$executedLines);
  98.                 $buffer .= $this->endSourceFile($sourceFile);
  99.             }
  100.  
  101.             $buffer .= $this->endTestCase($testCaseName);
  102.         }
  103.  
  104.         return $buffer $this->footer();
  105.     }
  106.  
  107.     // }}}
  108.     // {{{ protected function header()
  109.  
  110.     /**
  111.     * @return string 
  112.     * @access protected
  113.     * @since  2.1.1
  114.     */
  115.     protected function header({
  116.     }
  117.  
  118.     // }}}
  119.     // {{{ protected function footer()
  120.  
  121.     /**
  122.     * @return string 
  123.     * @access protected
  124.     * @since  2.1.1
  125.     */
  126.     protected function footer({
  127.     }
  128.  
  129.     // }}}
  130.     // {{{ protected function startTestCase($testCaseName)
  131.  
  132.     /**
  133.     * @param  string $testCaseName 
  134.     * @return string 
  135.     * @access protected
  136.     */
  137.     protected function startTestCase($testCaseName{
  138.     }
  139.  
  140.     // }}}
  141.     // {{{ protected function endTestCase($testCaseName)
  142.  
  143.     /**
  144.     * @param  string $testCaseName 
  145.     * @return string 
  146.     * @access protected
  147.     */
  148.     protected function endTestCase($testCaseName{
  149.     }
  150.  
  151.     // }}}
  152.     // {{{ protected function startSourceFile($sourceFile)
  153.  
  154.     /**
  155.     * @param  string $sourceFile 
  156.     * @return string 
  157.     * @access protected
  158.     */
  159.     protected function startSourceFile($sourceFile{
  160.     }
  161.  
  162.     // }}}
  163.     // {{{ protected function endSourceFile($sourceFile)
  164.  
  165.     /**
  166.     * @param  string $sourceFile 
  167.     * @return string 
  168.     * @access protected
  169.     */
  170.     protected function endSourceFile($sourceFile{
  171.     }
  172.  
  173.     // }}}
  174.     // {{{ abstract protected function renderSourceFile($codeLines, $executedLines)
  175.  
  176.     /**
  177.     * @param  array $codeLines 
  178.     * @param  array $executedLines 
  179.     * @return string 
  180.     * @access protected
  181.     * @abstract
  182.     */
  183.     abstract protected function renderSourceFile($codeLines$executedLines);
  184.  
  185.     // }}}
  186. }
  187.  
  188. /*
  189.  * vim600:  et sw=2 ts=2 fdm=marker
  190.  * vim<600: et sw=2 ts=2
  191.  */
  192. ?>

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