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

Source for file PHPUnit.php

Documentation is available at PHPUnit.php

  1. <?php
  2. //
  3. // +------------------------------------------------------------------------+
  4. // | PEAR :: PHPUnit                                                        |
  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: PHPUnit.php,v 1.14 2004/12/22 08:06:11 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.  * <code>
  28.  * <?php
  29.  * require_once 'PHPUnit.php';
  30.  *
  31.  * class MathTest extends PHPUnit_TestCase {
  32.  *     var $fValue1;
  33.  *     var $fValue2;
  34.  *
  35.  *     function MathTest($name) {
  36.  *       $this->PHPUnit_TestCase($name);
  37.  *     }
  38.  *
  39.  *     function setUp() {
  40.  *       $this->fValue1 = 2;
  41.  *       $this->fValue2 = 3;
  42.  *     }
  43.  *
  44.  *     function testAdd() {
  45.  *       $this->assertTrue($this->fValue1 + $this->fValue2 == 5);
  46.  *     }
  47.  * }
  48.  *
  49.  * $suite = new PHPUnit_TestSuite();
  50.  * $suite->addTest(new MathTest('testAdd'));
  51.  *
  52.  * $result = PHPUnit::run($suite);
  53.  * print $result->toHTML();
  54.  * ?>
  55.  * </code>
  56.  *
  57.  * Alternatively, you can pass a class name to the PHPUnit_TestSuite()
  58.  * constructor and let it automatically add all methods of that class
  59.  * that start with 'test' to the suite:
  60.  *
  61.  * <code>
  62.  * <?php
  63.  * $suite  = new PHPUnit_TestSuite('MathTest');
  64.  * $result = PHPUnit::run($suite);
  65.  * print $result->toHTML();
  66.  * ?>
  67.  * </code>
  68.  *
  69.  * @author      Sebastian Bergmann <sb@sebastian-bergmann.de>
  70.  * @copyright   Copyright &copy; 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de>
  71.  * @license     http://www.php.net/license/3_0.txt The PHP License, Version 3.0
  72.  * @category    Testing
  73.  * @package     PHPUnit
  74.  */
  75. class PHPUnit {
  76.     function &run(&$suite{
  77.         $result = new PHPUnit_TestResult();
  78.         $suite->run($result);
  79.  
  80.         return $result;
  81.     }
  82. }
  83. ?>

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