Class: PHPUnit
Source Location: /PHPUnit-1.3.2/PHPUnit.php
Class Overview
PHPUnit runs a TestSuite and returns a TestResult object.
Author(s):
Sebastian Bergmann <mailto:sb at sebastian-bergmann.de>
Version:
Release: @package_version@
Copyright:
2002-2005 Sebastian Bergmann <
[email protected]>
Methods
run
Inherited Variables
Inherited Methods
Class Details
[line 109]
PHPUnit runs a TestSuite and returns a TestResult object.
Here is an example:
1 <?php
2 require_once 'PHPUnit.php';
3
4 class MathTest extends PHPUnit_TestCase {
5 var $fValue1;
6 var $fValue2;
7
8 function MathTest($name) {
9 $this->PHPUnit_TestCase($name);
10 }
11
12 function setUp() {
13 $this->fValue1 = 2;
14 $this->fValue2 = 3;
15 }
16
17 function testAdd() {
18 $this->assertTrue($this->fValue1 + $this->fValue2 == 5);
19 }
20 }
21
22 $suite = new PHPUnit_TestSuite();
23 $suite->addTest(new MathTest('testAdd'));
24
25 $result = PHPUnit::run($suite);
26 print $result->toHTML();
27 ?>
Alternatively, you can pass a class name to the PHPUnit_TestSuite() constructor and let it automatically add all methods of that class that start with 'test' to the suite:
1 <?php
2 $suite = new PHPUnit_TestSuite('MathTest');
3 $result = PHPUnit::run($suite);
4 print $result->toHTML();
5 ?>
Link:
http://pear.php.net/package/PHPUnit
Since: Class available since Release 1.0.0
Version: Release: @package_version@
License: BSD License
Copyright: 2002-2005 Sebastian Bergmann <
[email protected]>
Author: Sebastian Bergmann <mailto:sb