@@ -211,69 +211,6 @@ PHPUnit\\Framework\\TestListener の実装
211
211
に、自作のテストリスナーをテスト実行時にアタッチするための
212
212
PHPUnit の設定方法についての説明があります。
213
213
214
- .. _extending-phpunit.PHPUnit_Extensions_TestDecorator :
215
-
216
- PHPUnit_Extensions_TestDecorator のサブクラスの作成
217
- ##########################################
218
-
219
- ``PHPUnit_Extensions_TestDecorator ``
220
- のサブクラスでテストケースあるいはテストスイートをラッピングし、
221
- デコレータパターンを使用することで
222
- 各テストの実行前後に何らかの処理をさせることができます。
223
-
224
- PHPUnit には、``PHPUnit_Extensions_RepeatedTest ``
225
- および ``PHPUnit_Extensions_TestSetup ``
226
- という 2 つの具象テストデコレータが付属しています。
227
- 前者はテストを繰り返し実行し、それらが全て成功した場合にのみ成功とみなします。
228
- 後者については :ref: `fixtures ` で説明しました。
229
-
230
- :numref: `extending-phpunit.examples.RepeatedTest.php `
231
- は、テストデコレータ ``PHPUnit_Extensions_RepeatedTest ``
232
- の一部を抜粋したものです。独自のデコレータを作成するための参考にしてください。
233
-
234
- .. code-block :: php
235
- :caption: RepeatedTest デコレータ
236
- :name: extending-phpunit.examples.RepeatedTest.php
237
-
238
- <?php
239
- use PHPUnit\Framework\TestCase;
240
-
241
- require_once 'PHPUnit/Extensions/TestDecorator.php';
242
-
243
- class PHPUnit_Extensions_RepeatedTest extends PHPUnit_Extensions_TestDecorator
244
- {
245
- private $timesRepeat = 1;
246
-
247
- public function __construct(PHPUnit\Framework\Test $test, $timesRepeat = 1)
248
- {
249
- parent::__construct($test);
250
-
251
- if (is_integer($timesRepeat) &&
252
- $timesRepeat >= 0) {
253
- $this->timesRepeat = $timesRepeat;
254
- }
255
- }
256
-
257
- public function count()
258
- {
259
- return $this->timesRepeat * $this->test->count();
260
- }
261
-
262
- public function run(PHPUnit\Framework\TestResult $result = null)
263
- {
264
- if ($result === null) {
265
- $result = $this->createResult();
266
- }
267
-
268
- for ($i = 0; $i < $this->timesRepeat && !$result->shouldStop(); $i++) {
269
- $this->test->run($result);
270
- }
271
-
272
- return $result;
273
- }
274
- }
275
- ?>
276
-
277
214
.. _extending-phpunit.PHPUnit_Framework_Test :
278
215
279
216
PHPUnit\F ramework\T est の実装
0 commit comments