Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit 34d2cb0

Browse files
Nicolas HartWynnChen
Nicolas Hart
authored andcommitted
Remove the deprecated PHPUnit_Extensions_TestDecorator part
1 parent c6ad9f7 commit 34d2cb0

File tree

1 file changed

+0
-54
lines changed

1 file changed

+0
-54
lines changed

src/extending-phpunit.rst

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -181,60 +181,6 @@ PHPUnit\\Framework\\TestCase 的子类
181181
182182
:ref:`appendixes.configuration.test-listeners`中可以看到如何配置 PHPUnit 来将测试监听器附加到测试执行过程上。
183183

184-
.. _extending-phpunit.PHPUnit_Extensions_TestDecorator:
185-
186-
从 PHPUnit_Extensions_TestDecorator 派生子类
187-
#######################################
188-
189-
可以将测试用例或者测试套件包装在 ``PHPUnit_Extensions_TestDecorator`` 的子类中并运用 Decorator(修饰器)设计模式来在测试运行前后执行一些动作。
190-
191-
PHPUnit 了包含了一个具体的测试修饰器:``PHPUnit_Extensions_RepeatedTest``。它用于重复运行某个测试,并且只在全部循环中都成功时计为成功。
192-
193-
:numref:`extending-phpunit.examples.RepeatedTest.php`展示了测试修饰器 ``PHPUnit_Extensions_RepeatedTest`` 的一个删减版本,用以说明如何编写你自己的测试修饰器。
194-
195-
.. code-block:: php
196-
:caption: RepeatedTest 修饰器
197-
:name: extending-phpunit.examples.RepeatedTest.php
198-
199-
<?php
200-
use PHPUnit\Framework\TestCase;
201-
202-
require_once 'PHPUnit/Extensions/TestDecorator.php';
203-
204-
class PHPUnit_Extensions_RepeatedTest extends PHPUnit_Extensions_TestDecorator
205-
{
206-
private $timesRepeat = 1;
207-
208-
public function __construct(PHPUnit_Framework_Test $test, $timesRepeat = 1)
209-
{
210-
parent::__construct($test);
211-
212-
if (is_integer($timesRepeat) &&
213-
$timesRepeat >= 0) {
214-
$this->timesRepeat = $timesRepeat;
215-
}
216-
}
217-
218-
public function count()
219-
{
220-
return $this->timesRepeat * $this->test->count();
221-
}
222-
223-
public function run(PHPUnit_Framework_TestResult $result = null)
224-
{
225-
if ($result === null) {
226-
$result = $this->createResult();
227-
}
228-
229-
for ($i = 0; $i < $this->timesRepeat && !$result->shouldStop(); $i++) {
230-
$this->test->run($result);
231-
}
232-
233-
return $result;
234-
}
235-
}
236-
?>
237-
238184
.. _extending-phpunit.PHPUnit_Framework_Test:
239185

240186
实现 PHPUnit_Framework_Test

0 commit comments

Comments
 (0)