home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / PHPUnit.php < prev    next >
Encoding:
PHP Script  |  2004-03-24  |  2.3 KB  |  76 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: PHPUnit.php,v 1.9 2003/03/26 18:04:32 sebastian Exp $
  16. //
  17.  
  18. require_once 'PHPUnit/TestCase.php';
  19. require_once 'PHPUnit/TestResult.php';
  20. require_once 'PHPUnit/TestSuite.php';
  21.  
  22. /**
  23.  * PHPUnit runs a TestSuite and returns a TestResult object.
  24.  *
  25.  * Here is an example:
  26.  *
  27.  *   <?php
  28.  *   require_once 'PHPUnit.php';
  29.  *
  30.  *   class MathTest extends PHPUnit_TestCase {
  31.  *     var $fValue1;
  32.  *     var $fValue2;
  33.  *
  34.  *     function MathTest($name) {
  35.  *       $this->PHPUnit_TestCase($name);
  36.  *     }
  37.  *
  38.  *     function setUp() {
  39.  *       $this->fValue1 = 2;
  40.  *       $this->fValue2 = 3;
  41.  *     }
  42.  *
  43.  *     function testAdd() {
  44.  *       $this->assertTrue($this->fValue1 + $this->fValue2 == 5);
  45.  *     }
  46.  *   }
  47.  *
  48.  *   $suite = new PHPUnit_TestSuite();
  49.  *   $suite->addTest(new MathTest('testAdd'));
  50.  *
  51.  *   $result = PHPUnit::run($suite);
  52.  *   echo $result->toHTML();
  53.  *   ?>
  54.  *
  55.  * Alternatively, you can pass a class name to the
  56.  * PHPUnit_TestSuite() constructor and let it automatically add all
  57.  * methods of that class that start with 'test' to the suite:
  58.  *
  59.  *   $suite  = new PHPUnit_TestSuite('MathTest');
  60.  *   $result = PHPUnit::run($suite);
  61.  *   echo $result->toHTML();
  62.  *
  63.  * @package PHPUnit
  64.  * @author  Sebastian Bergmann <sb@sebastian-bergmann.de>
  65.  *          Based upon JUnit, see http://www.junit.org/ for details.
  66.  */
  67. class PHPUnit {
  68.     function &run(&$suite) {
  69.         $result = new PHPUnit_TestResult();
  70.         $suite->run($result);
  71.  
  72.         return $result;
  73.     }
  74. }
  75. ?>
  76.