public function StopwatchEventTest::testEndTime

File

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

Class

StopwatchEventTest
StopwatchEventTest

Namespace

Symfony\Component\HttpKernel\Tests\Debug

Code

public function testEndTime() {
  $event = new StopwatchEvent(microtime(true) * 1000);
  $this
    ->assertEquals(0, $event
    ->getEndTime());
  $event = new StopwatchEvent(microtime(true) * 1000);
  $event
    ->start();
  $this
    ->assertEquals(0, $event
    ->getEndTime());
  $event = new StopwatchEvent(microtime(true) * 1000);
  $event
    ->start();
  usleep(10000);
  $event
    ->stop();
  $event
    ->start();
  usleep(10000);
  $event
    ->stop();
  $end = $event
    ->getEndTime();
  $this
    ->assertTrue($end >= 11 && $end <= 29, $end . ' should be 20 (between 11 and 29)');
}