sebastianbergmann/phpunit — Issue #431: Bug in documentation - Extending PHPUnit example
Author: soid
Created: 2011-12-03 02:05:07+00:00
State: open

In "Chapter 19. Extending PHPUnit" http://www.phpunit.de/manual/3.6/en/extending-phpunit.html#extending-phpunit.PHPUnit_Framework_Test
you have a data-driven test example. There's a bug in this example. I fixed it:

25c25,26
<
---
> $stopTime = NULL;
>
35c36,37
< $result->addFailure($this, $e, PHP_Timer::stop());
---
> $stopTime = PHP_Timer::stop();
> $result->addFailure($this, $e, $stopTime);
39c41,42
< $result->addError($this, $e, PHP_Timer::stop()());
---
> $stopTime = PHP_Timer::stop();
> $result->addError($this, $e, $stopTime);
41,42c44,48
<
< $result->endTest($this, PHP_Timer::stop());
---
>
> if ($stopTime === NULL) {
> $stopTime = PHP_Timer::stop();
> }
> $result->endTest($this, $stopTime);

This is because in case of failure or error PHP_Timer::stop() will be called two times and test duration will be detected incorrectly. My patch solves this.

PS. Sorry if it's the wrong place for bugs in documentation but I didn't find where I should put it to.