From 741592f280903d6f6bcca5453a7276fdf8037a9e Mon Sep 17 00:00:00 2001 From: Diego Saint Esteben Date: Sat, 9 May 2015 21:29:12 -0300 Subject: [PATCH] Fix volatile tests --- .../Component/Stopwatch/Tests/StopwatchEventTest.php | 4 +++- src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php | 9 ++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php b/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php index ccc4031967cb1..ae93869dc6306 100644 --- a/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php +++ b/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php @@ -113,7 +113,9 @@ public function testEnsureStopped() $event->start(); usleep(100000); $event->ensureStopped(); - $this->assertEquals(300, $event->getDuration(), null, self::DELTA); + $duration = $event->getDuration(); + usleep(100000); + $this->assertEquals($duration, $event->getDuration()); } public function testStartTime() diff --git a/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php b/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php index 6415bba9e5352..2274cb61ff301 100644 --- a/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php +++ b/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php @@ -20,8 +20,6 @@ */ class StopwatchTest extends \PHPUnit_Framework_TestCase { - const DELTA = 20; - public function testStart() { $stopwatch = new Stopwatch(); @@ -71,11 +69,12 @@ public function testStop() { $stopwatch = new Stopwatch(); $stopwatch->start('foo', 'cat'); - usleep(200000); + usleep(100000); $event = $stopwatch->stop('foo'); - + $duration = $event->getDuration(); + usleep(100000); $this->assertInstanceof('Symfony\Component\Stopwatch\StopwatchEvent', $event); - $this->assertEquals(200, $event->getDuration(), null, self::DELTA); + $this->assertEquals($duration, $event->getDuration()); } /**