Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
3
 
4
/**
5
 * PHP Version 4
6
 *
7
 * Copyright (c) 2002-2005, Sebastian Bergmann <sb@sebastian-bergmann.de>.
8
 * All rights reserved.
9
 *
10
 * Redistribution and use in source and binary forms, with or without
11
 * modification, are permitted provided that the following conditions
12
 * are met:
13
 *
14
 *   * Redistributions of source code must retain the above copyright
15
 *     notice, this list of conditions and the following disclaimer.
16
 *
17
 *   * Redistributions in binary form must reproduce the above copyright
18
 *     notice, this list of conditions and the following disclaimer in
19
 *     the documentation and/or other materials provided with the
20
 *     distribution.
21
 *
22
 *   * Neither the name of Sebastian Bergmann nor the names of his
23
 *     contributors may be used to endorse or promote products derived
24
 *     from this software without specific prior written permission.
25
 *
26
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
29
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
30
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
31
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
32
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
33
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
34
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
35
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
36
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37
 * POSSIBILITY OF SUCH DAMAGE.
38
 *
39
 * @category   Testing
40
 * @package    PHPUnit
41
 * @author     Sebastian Bergmann <sb@sebastian-bergmann.de>
42
 * @copyright  2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de>
43
 * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
44
 * @version    CVS: $Id: RepeatedTest.php,v 1.13 2005/11/10 09:47:14 sebastian Exp $
45
 * @link       http://pear.php.net/package/PHPUnit
46
 * @since      File available since Release 1.0.0
47
 */
48
 
49
require_once 'PHPUnit/TestDecorator.php';
50
 
51
/**
52
 * A Decorator that runs a test repeatedly.
53
 *
54
 * Here is an example:
55
 *
56
 * <code>
57
 * <?php
58
 * require_once 'PHPUnit.php';
59
 * require_once 'PHPUnit/RepeatedTest.php';
60
 *
61
 * class MathTest extends PHPUnit_TestCase {
62
 *     var $fValue1;
63
 *     var $fValue2;
64
 *
65
 *     function MathTest($name) {
66
 *         $this->PHPUnit_TestCase($name);
67
 *     }
68
 *
69
 *     function setUp() {
70
 *         $this->fValue1 = 2;
71
 *         $this->fValue2 = 3;
72
 *     }
73
 *
74
 *     function testAdd() {
75
 *         $this->assertTrue($this->fValue1 + $this->fValue2 == 5);
76
 *     }
77
 * }
78
 *
79
 * $suite = new PHPUnit_TestSuite;
80
 *
81
 * $suite->addTest(
82
 *   new PHPUnit_RepeatedTest(
83
 *     new MathTest('testAdd'),
84
 *     10
85
 *   )
86
 * );
87
 *
88
 * $result = PHPUnit::run($suite);
89
 * print $result->toString();
90
 * ?>
91
 * </code>
92
 *
93
 * @category   Testing
94
 * @package    PHPUnit
95
 * @author     Sebastian Bergmann <sb@sebastian-bergmann.de>
96
 * @copyright  2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de>
97
 * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
98
 * @version    Release: 1.3.2
99
 * @link       http://pear.php.net/package/PHPUnit
100
 * @since      Class available since Release 1.0.0
101
 */
102
class PHPUnit_RepeatedTest extends PHPUnit_TestDecorator {
103
    /**
104
     * @var    integer
105
     * @access private
106
     */
107
    var $_timesRepeat = 1;
108
 
109
    /**
110
     * Constructor.
111
     *
112
     * @param  object
113
     * @param  integer
114
     * @access public
115
     */
116
    function PHPUnit_RepeatedTest(&$test, $timesRepeat = 1) {
117
        $this->PHPUnit_TestDecorator($test);
118
        $this->_timesRepeat = $timesRepeat;
119
    }
120
 
121
    /**
122
     * Counts the number of test cases that
123
     * will be run by this test.
124
     *
125
     * @return integer
126
     * @access public
127
     */
128
    function countTestCases() {
129
        return $this->_timesRepeat * $this->_test->countTestCases();
130
    }
131
 
132
    /**
133
     * Runs the decorated test and collects the
134
     * result in a TestResult.
135
     *
136
     * @param  object
137
     * @access public
138
     * @abstract
139
     */
140
    function run(&$result) {
141
        for ($i = 0; $i < $this->_timesRepeat; $i++) {
142
            $this->_test->run($result);
143
        }
144
    }
145
}
146
 
147
/*
148
 * Local variables:
149
 * tab-width: 4
150
 * c-basic-offset: 4
151
 * c-hanging-comment-ender-p: nil
152
 * End:
153
 */
154
?>