public function StopwatchEventTest::testStartTime

File

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

Class

StopwatchEventTest
StopwatchEventTest

Namespace

Symfony\Component\HttpKernel\Tests\Debug

Code

public function testStartTime() {
  $event = new StopwatchEvent(microtime(true) * 1000);
  $this
    ->assertTrue($event
    ->getStartTime() < 0.5);
  $event = new StopwatchEvent(microtime(true) * 1000);
  $event
    ->start();
  $event
    ->stop();
  $this
    ->assertTrue($event
    ->getStartTime() < 1);
  $event = new StopwatchEvent(microtime(true) * 1000);
  $event
    ->start();
  usleep(10000);
  $event
    ->stop();
  $start = $event
    ->getStartTime();
  $this
    ->assertTrue($start >= 0 && $start <= 20);
}