home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / TestDecorator.php < prev    next >
Encoding:
PHP Script  |  2004-03-24  |  2.8 KB  |  109 lines

  1. <?php
  2. //
  3. // +------------------------------------------------------------------------+
  4. // | PEAR :: PHPUnit                                                        |
  5. // +------------------------------------------------------------------------+
  6. // | Copyright (c) 2002-2003 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: TestDecorator.php,v 1.4 2003/03/26 18:04:32 sebastian Exp $
  16. //
  17.  
  18. require_once 'PHPUnit/TestCase.php';
  19. require_once 'PHPUnit/TestSuite.php';
  20.  
  21. /**
  22.  * A Decorator for Tests.
  23.  *
  24.  * Use TestDecorator as the base class for defining new 
  25.  * test decorators. Test decorator subclasses can be introduced
  26.  * to add behaviour before or after a test is run.
  27.  *
  28.  * @package PHPUnit
  29.  * @author  Sebastian Bergmann <sb@sebastian-bergmann.de>
  30.  *          Based upon JUnit, see http://www.junit.org/ for details.
  31.  */
  32. class PHPUnit_TestDecorator {
  33.     /**
  34.     * The Test to be decorated.
  35.     *
  36.     * @var    object
  37.     * @access protected
  38.     */
  39.     var $_test = null;
  40.  
  41.     /**
  42.     * Constructor.
  43.     *
  44.     * @param  object
  45.     * @access public
  46.     */
  47.     function PHPUnit_TestDecorator(&$test) {
  48.         if (is_object($test) &&
  49.             (is_a($test, 'PHPUnit_TestCase') ||
  50.              is_a($test, 'PHPUnit_TestSuite'))) {
  51.  
  52.             $this->_test = $test;
  53.         }
  54.     }
  55.  
  56.     /**
  57.     * Runs the test and collects the
  58.     * result in a TestResult.
  59.     *
  60.     * @param  object
  61.     * @access public
  62.     */
  63.     function basicRun(&$result) {
  64.         $this->_test->run($result);
  65.     }
  66.  
  67.     /**
  68.     * Counts the number of test cases that
  69.     * will be run by this test.
  70.     *
  71.     * @return integer
  72.     * @access public
  73.     */
  74.     function countTestCases() {
  75.         return $this->_test->countTestCases();
  76.     }
  77.  
  78.     /**
  79.     * Returns the test to be run.
  80.     *
  81.     * @return object
  82.     * @access public
  83.     */
  84.     function &getTest() {
  85.         return $this->_test;
  86.     }
  87.  
  88.     /**
  89.     * Runs the decorated test and collects the
  90.     * result in a TestResult.
  91.     *
  92.     * @param  object
  93.     * @access public
  94.     * @abstract
  95.     */
  96.     function run(&$result) { /* abstract */ }
  97.  
  98.     /**
  99.     * Returns a string representation of the test.
  100.     *
  101.     * @return string
  102.     * @access public
  103.     */
  104.     function toString() {
  105.         return $this->_test->toString();
  106.     }
  107. }
  108. ?>
  109.