public function StopwatchTest::testLap

File

drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/StopwatchTest.php, line 44

Class

StopwatchTest
StopwatchTest

Namespace

Symfony\Component\HttpKernel\Tests\Debug

Code

public function testLap() {
  $stopwatch = new Stopwatch();
  $stopwatch
    ->start('foo', 'cat');
  usleep(10000);
  $event = $stopwatch
    ->lap('foo');
  usleep(10000);
  $stopwatch
    ->stop('foo');
  $this
    ->assertInstanceof('Symfony\\Component\\HttpKernel\\Debug\\StopwatchEvent', $event);
  $total = $event
    ->getTotalTime();
  $this
    ->assertTrue($total > 10 && $total <= 29, $total . ' should be 20 (between 10 and 29)');
}