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

Source for file NamePrettifier.php

Documentation is available at NamePrettifier.php

  1. <?php
  2. //
  3. // +------------------------------------------------------------------------+
  4. // | PEAR :: PHPUnit2 :: TestDox                                            |
  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: NamePrettifier.php,v 1.3.2.1 2004/12/22 08:06:07 sebastian Exp $
  16. //
  17.  
  18. /**
  19.  * A prettifier for class names.
  20.  *
  21.  * @author      Sebastian Bergmann <sb@sebastian-bergmann.de>
  22.  * @copyright   Copyright &copy; 2002-2005 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.  */
  29.     // {{{ Instance Variables
  30.  
  31.     /**
  32.     * @var    string 
  33.     * @access protected
  34.     */
  35.     protected $prefix = 'Test';
  36.  
  37.     /**
  38.     * @var    string 
  39.     * @access protected
  40.     */
  41.     protected $suffix = 'Test';
  42.  
  43.     // }}}
  44.     // {{{ public function isATestMethod($testMethodName)
  45.  
  46.     /**
  47.     * Tests if a method is a test method.
  48.     *
  49.     * @param  string  $testMethodName 
  50.     * @return boolean 
  51.     * @access public
  52.     */
  53.     public function isATestMethod($testMethodName{
  54.         if (substr($testMethodName04== 'test'{
  55.             return TRUE;
  56.         }
  57.  
  58.         return FALSE;
  59.     }
  60.  
  61.     // }}}
  62.     // {{{ public function prettifyTestClass($testClassName)
  63.  
  64.     /**
  65.     * Prettifies the name of a test class.
  66.     *
  67.     * @param  string  $testClassName 
  68.     * @return string 
  69.     * @access public
  70.     */
  71.     public function prettifyTestClass($testClassName{
  72.         $title $testClassName;
  73.  
  74.         if ($this->suffix !== NULL &&
  75.             $this->suffix == substr($testClassName-1 * strlen($this->suffix))) {
  76.             $title substr($title0strripos($title$this->suffix));
  77.         }
  78.  
  79.         if ($this->prefix !== NULL &&
  80.             $this->prefix == substr($testClassName0strlen($this->prefix))) {
  81.             $title substr($titlestrlen($this->prefix));
  82.         }
  83.  
  84.         return $title;
  85.     }
  86.  
  87.     // }}}
  88.     // {{{ public function prettifyTestMethod($testMethodName)
  89.  
  90.     /**
  91.     * Prettifies the name of a test method.
  92.     *
  93.     * @param  string  $testMethodName 
  94.     * @return string 
  95.     * @access public
  96.     */
  97.     public function prettifyTestMethod($testMethodName{
  98.         $buffer '';
  99.  
  100.         for ($i = 4; $i strlen($testMethodName)$i++{
  101.             if ($i > 4 &&
  102.                 ord($testMethodName[$i]>= 65 && 
  103.                 ord($testMethodName[$i]<= 90{
  104.                 $buffer .= ' ' strtolower($testMethodName[$i]);
  105.             else {
  106.                 $buffer .= $testMethodName[$i];
  107.             }
  108.         }
  109.  
  110.         return $buffer;
  111.     }
  112.  
  113.     // }}}
  114.     // {{{ public function setPrefix($prefix)
  115.  
  116.     /**
  117.     * Sets the prefix of test names.
  118.     *
  119.     * @param  string  $prefix 
  120.     * @access public
  121.     */
  122.     public function setPrefix($prefix{
  123.         $this->prefix = $prefix;
  124.     }
  125.  
  126.     // }}}
  127.     // {{{ public function setSuffix($suffix)
  128.  
  129.     /**
  130.     * Sets the suffix of test names.
  131.     *
  132.     * @param  string  $prefix 
  133.     * @access public
  134.     */
  135.     public function setSuffix($suffix{
  136.         $this->suffix = $suffix;
  137.     }
  138.  
  139.     // }}}
  140. }
  141.  
  142. /*
  143.  * vim600:  et sw=2 ts=2 fdm=marker
  144.  * vim<600: et sw=2 ts=2
  145.  */
  146. ?>

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