cvs: pear /PHPUnit PHPUnit_TestDecorator.php
| From: | Sebastian Bergmann | Date: | Fri, 12 Jul 2002 05:12:30 +0000 |
| Subject: | cvs: pear /PHPUnit PHPUnit_TestDecorator.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-5062@lists.php.net to get a copy of this message | ||
sebastian Fri Jul 12 01:12:30 2002 EDT
Modified files:
/pear/PHPUnit PHPUnit_TestDecorator.php
Log:
Add example.
Index: pear/PHPUnit/PHPUnit_TestDecorator.php
diff -u pear/PHPUnit/PHPUnit_TestDecorator.php:1.3 pear/PHPUnit/PHPUnit_TestDecorator.php:1.4
--- pear/PHPUnit/PHPUnit_TestDecorator.php:1.3 Fri Jul 12 01:03:07 2002
+++ pear/PHPUnit/PHPUnit_TestDecorator.php Fri Jul 12 01:12:30 2002
@@ -16,14 +16,51 @@
// | Author: Sebastian Bergmann <sb@sebastian-bergmann.de> |
// +----------------------------------------------------------------------+
//
-// $Id: PHPUnit_TestDecorator.php,v 1.3 2002/07/12 05:03:07 sebastian Exp $
+// $Id: PHPUnit_TestDecorator.php,v 1.4 2002/07/12 05:12:30 sebastian Exp $
//
/**
* A Decorator for Tests.
+ *
* Use TestDecorator as the base class for defining new
* test decorators. Test decorator subclasses can be introduced
* to add behaviour before or after a test is run.
+ *
+ * Here is an example:
+ *
+ * <?php
+ * require_once 'PHPUnit/PHPUnit.php';
+ * require_once 'PHPUnit/PHPUnit_RepeatedTest.php';
+ *
+ * class MathTest extends PHPUnit_TestCase {
+ * var $fValue1;
+ * var $fValue2;
+ *
+ * function MathTest($name) {
+ * $this->PHPUnit_TestCase($name);
+ * }
+ *
+ * function setUp() {
+ * $this->fValue1 = 2;
+ * $this->fValue2 = 3;
+ * }
+ *
+ * function testAdd() {
+ * $this->assertTrue($this->fValue1 + $this->fValue2 == 5);
+ * }
+ * }
+ *
+ * $suite = new PHPUnit_TestSuite;
+ * $suite->addTest(
+ * new PHPUnit_RepeatedTest(
+ * new MathTest('testAdd'),
+ * 10
+ * )
+ * );
+ *
+ * $result = PHPUnit::run($suite);
+ * echo $result->toString();
+ * ?>
*
* @package PHPUnit
* @author Sebastian Bergmann <sb@sebastian-bergmann.de>