You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
2.5 KiB

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