public function StopwatchEventTest::testEnsureStopped

File

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

Class

StopwatchEventTest
StopwatchEventTest

Namespace

Symfony\Component\HttpKernel\Tests\Debug

Code

public function testEnsureStopped() {

  // this also test overlap between two periods
  $event = new StopwatchEvent(microtime(true) * 1000);
  $event
    ->start();
  usleep(10000);
  $event
    ->start();
  usleep(10000);
  $event
    ->ensureStopped();
  $total = $event
    ->getTotalTime();
  $this
    ->assertTrue($total >= 21 && $total <= 39, $total . ' should be 30 (between 21 and 39)');
}