@@ -209,68 +209,6 @@ In :ref:`appendixes.configuration.test-listeners` you can see
209
209
how to configure PHPUnit to attach your test listener to the test
210
210
execution.
211
211
212
- .. _extending-phpunit.PHPUnit_Extensions_TestDecorator :
213
-
214
- Subclass PHPUnit_Extensions_TestDecorator
215
- #########################################
216
-
217
- You can wrap test cases or test suites in a subclass of
218
- ``PHPUnit_Extensions_TestDecorator `` and use the
219
- Decorator design pattern to perform some actions before and after the
220
- test runs.
221
-
222
- PHPUnit ships with one concrete test decorator:
223
- ``PHPUnit_Extensions_RepeatedTest ``. It is used to run a
224
- test repeatedly and only count it as a success if all iterations are
225
- successful.
226
-
227
- :numref: `extending-phpunit.examples.RepeatedTest.php `
228
- shows a cut-down version of the ``PHPUnit_Extensions_RepeatedTest ``
229
- test decorator that illustrates how to write your own test decorators.
230
-
231
- .. code-block :: php
232
- :caption: The RepeatedTest Decorator
233
- :name: extending-phpunit.examples.RepeatedTest.php
234
-
235
- <?php
236
- use PHPUnit\Framework\TestCase;
237
-
238
- require_once 'PHPUnit/Extensions/TestDecorator.php';
239
-
240
- class PHPUnit_Extensions_RepeatedTest extends PHPUnit_Extensions_TestDecorator
241
- {
242
- private $timesRepeat = 1;
243
-
244
- public function __construct(PHPUnit_Framework_Test $test, $timesRepeat = 1)
245
- {
246
- parent::__construct($test);
247
-
248
- if (is_integer($timesRepeat) &&
249
- $timesRepeat >= 0) {
250
- $this->timesRepeat = $timesRepeat;
251
- }
252
- }
253
-
254
- public function count()
255
- {
256
- return $this->timesRepeat * $this->test->count();
257
- }
258
-
259
- public function run(PHPUnit_Framework_TestResult $result = null)
260
- {
261
- if ($result === null) {
262
- $result = $this->createResult();
263
- }
264
-
265
- for ($i = 0; $i < $this->timesRepeat && !$result->shouldStop(); $i++) {
266
- $this->test->run($result);
267
- }
268
-
269
- return $result;
270
- }
271
- }
272
- ?>
273
-
274
212
.. _extending-phpunit.PHPUnit_Framework_Test :
275
213
276
214
Implement PHPUnit_Framework_Test
0 commit comments