Broaden timer tests limits
This commit is contained in:
parent
001c4fd064
commit
005d86f4db
@ -66,10 +66,10 @@ class StopwatchEventTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$event = new StopwatchEvent(microtime(true) * 1000);
|
$event = new StopwatchEvent(microtime(true) * 1000);
|
||||||
$event->start();
|
$event->start();
|
||||||
usleep(10000);
|
usleep(20000);
|
||||||
$event->stop();
|
$event->stop();
|
||||||
$total = $event->getTotalTime();
|
$total = $event->getTotalTime();
|
||||||
$this->assertTrue($total >= 9 && $total <= 20);
|
$this->assertTrue($total > 10 && $total <= 29, $total.' should be 20 (between 10 and 29)');
|
||||||
|
|
||||||
$event = new StopwatchEvent(microtime(true) * 1000);
|
$event = new StopwatchEvent(microtime(true) * 1000);
|
||||||
$event->start();
|
$event->start();
|
||||||
@ -79,7 +79,7 @@ class StopwatchEventTest extends \PHPUnit_Framework_TestCase
|
|||||||
usleep(10000);
|
usleep(10000);
|
||||||
$event->stop();
|
$event->stop();
|
||||||
$total = $event->getTotalTime();
|
$total = $event->getTotalTime();
|
||||||
$this->assertTrue($total >= 18 && $total <= 30);
|
$this->assertTrue($total > 10 && $total <= 29, $total.' should be 20 (between 10 and 29)');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -101,7 +101,7 @@ class StopwatchEventTest extends \PHPUnit_Framework_TestCase
|
|||||||
usleep(10000);
|
usleep(10000);
|
||||||
$event->ensureStopped();
|
$event->ensureStopped();
|
||||||
$total = $event->getTotalTime();
|
$total = $event->getTotalTime();
|
||||||
$this->assertTrue($total >= 27 && $total <= 40);
|
$this->assertTrue($total >= 21 && $total <= 39, $total.' should be 30 (between 21 and 39)');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testStartTime()
|
public function testStartTime()
|
||||||
@ -139,7 +139,7 @@ class StopwatchEventTest extends \PHPUnit_Framework_TestCase
|
|||||||
usleep(10000);
|
usleep(10000);
|
||||||
$event->stop();
|
$event->stop();
|
||||||
$end = $event->getEndTime();
|
$end = $event->getEndTime();
|
||||||
$this->assertTrue($end >= 18 && $end <= 30);
|
$this->assertTrue($end > 10 && $end <= 29, $end.' should be 20 (between 10 and 29)');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,12 +33,12 @@ class StopwatchTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$stopwatch = new Stopwatch();
|
$stopwatch = new Stopwatch();
|
||||||
$stopwatch->start('foo', 'cat');
|
$stopwatch->start('foo', 'cat');
|
||||||
usleep(10000);
|
usleep(20000);
|
||||||
$event = $stopwatch->stop('foo');
|
$event = $stopwatch->stop('foo');
|
||||||
|
|
||||||
$this->assertInstanceof('Symfony\Component\HttpKernel\Debug\StopwatchEvent', $event);
|
$this->assertInstanceof('Symfony\Component\HttpKernel\Debug\StopwatchEvent', $event);
|
||||||
$total = $event->getTotalTime();
|
$total = $event->getTotalTime();
|
||||||
$this->assertTrue($total >= 9 && $total <= 20);
|
$this->assertTrue($total > 10 && $total <= 29, $total.' should be 20 (between 10 and 29)');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLap()
|
public function testLap()
|
||||||
@ -52,7 +52,7 @@ class StopwatchTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$this->assertInstanceof('Symfony\Component\HttpKernel\Debug\StopwatchEvent', $event);
|
$this->assertInstanceof('Symfony\Component\HttpKernel\Debug\StopwatchEvent', $event);
|
||||||
$total = $event->getTotalTime();
|
$total = $event->getTotalTime();
|
||||||
$this->assertTrue($total >= 18 && $total <= 30);
|
$this->assertTrue($total > 10 && $total <= 29, $total.' should be 20 (between 10 and 29)');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user