premier commit
[bazdig.git] / test / PHPUnit / TestDecorator.php
blob47a687b54a04da7bd5be7fd58f9d449f7c0bf652
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 // +------------------------------------------------------------------------+
15 // $Id: TestDecorator.php,v 1.10 2004/10/01 06:11:39 sebastian Exp $
18 require_once 'PHPUnit/TestCase.php';
19 require_once 'PHPUnit/TestSuite.php';
21 /**
22 * A Decorator for Tests.
24 * Use TestDecorator as the base class for defining new
25 * test decorators. Test decorator subclasses can be introduced
26 * to add behaviour before or after a test is run.
28 * @author Sebastian Bergmann <sb@sebastian-bergmann.de>
29 * @copyright Copyright &copy; 2002-2004 Sebastian Bergmann <sb@sebastian-bergmann.de>
30 * @license http://www.php.net/license/3_0.txt The PHP License, Version 3.0
31 * @category Testing
32 * @package PHPUnit
34 class PHPUnit_TestDecorator {
35 /**
36 * The Test to be decorated.
38 * @var object
39 * @access protected
41 var $_test = NULL;
43 /**
44 * Constructor.
46 * @param object
47 * @access public
49 function PHPUnit_TestDecorator(&$test) {
50 if (is_object($test) &&
51 (is_a($test, 'PHPUnit_TestCase') ||
52 is_a($test, 'PHPUnit_TestSuite'))) {
54 $this->_test = $test;
58 /**
59 * Runs the test and collects the
60 * result in a TestResult.
62 * @param object
63 * @access public
65 function basicRun(&$result) {
66 $this->_test->run($result);
69 /**
70 * Counts the number of test cases that
71 * will be run by this test.
73 * @return integer
74 * @access public
76 function countTestCases() {
77 return $this->_test->countTestCases();
80 /**
81 * Returns the test to be run.
83 * @return object
84 * @access public
86 function &getTest() {
87 return $this->_test;
90 /**
91 * Runs the decorated test and collects the
92 * result in a TestResult.
94 * @param object
95 * @access public
96 * @abstract
98 function run(&$result) { /* abstract */ }
101 * Returns a string representation of the test.
103 * @return string
104 * @access public
106 function toString() {
107 return $this->_test->toString();