From 3a0a901fdb49961020795f5cebc17c05d975ba10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Mon, 5 Aug 2019 23:18:16 +0200 Subject: [PATCH] Use assertEqualsWithDelta when required --- .../Component/HttpFoundation/Tests/CookieTest.php | 2 +- .../NumberFormatter/AbstractNumberFormatterTest.php | 2 +- .../Component/Stopwatch/Tests/StopwatchEventTest.php | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php b/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php index e382182b4d60..38c195df36a1 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php @@ -119,7 +119,7 @@ public function testGetExpiresTimeWithStringValue() $cookie = new Cookie('foo', 'bar', $value); $expire = strtotime($value); - $this->assertEquals($expire, $cookie->getExpiresTime(), '->getExpiresTime() returns the expire date', 1); + $this->assertEqualsWithDelta($expire, $cookie->getExpiresTime(), 1, '->getExpiresTime() returns the expire date'); } public function testGetDomain() diff --git a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php index 464a0aac0c7c..9e8499eba963 100644 --- a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php @@ -806,7 +806,7 @@ public function testParseTypeDouble($value, $expectedValue) { $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); $parsedValue = $formatter->parse($value, NumberFormatter::TYPE_DOUBLE); - $this->assertEquals($expectedValue, $parsedValue, '', 0.001); + $this->assertEqualsWithDelta($expectedValue, $parsedValue, 0.001); } public function parseTypeDoubleProvider() diff --git a/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php b/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php index 1b53694a63ad..86a02b153591 100644 --- a/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php +++ b/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php @@ -73,7 +73,7 @@ public function testDuration() $event->start(); usleep(200000); $event->stop(); - $this->assertEquals(200, $event->getDuration(), '', self::DELTA); + $this->assertEqualsWithDelta(200, $event->getDuration(), self::DELTA); $event = new StopwatchEvent(microtime(true) * 1000); $event->start(); @@ -83,7 +83,7 @@ public function testDuration() $event->start(); usleep(100000); $event->stop(); - $this->assertEquals(200, $event->getDuration(), '', self::DELTA); + $this->assertEqualsWithDelta(200, $event->getDuration(), self::DELTA); } public function testDurationBeforeStop() @@ -91,7 +91,7 @@ public function testDurationBeforeStop() $event = new StopwatchEvent(microtime(true) * 1000); $event->start(); usleep(200000); - $this->assertEquals(200, $event->getDuration(), '', self::DELTA); + $this->assertEqualsWithDelta(200, $event->getDuration(), self::DELTA); $event = new StopwatchEvent(microtime(true) * 1000); $event->start(); @@ -100,7 +100,7 @@ public function testDurationBeforeStop() usleep(50000); $event->start(); usleep(100000); - $this->assertEquals(100, $event->getDuration(), '', self::DELTA); + $this->assertEqualsWithDelta(100, $event->getDuration(), self::DELTA); } public function testStopWithoutStart() @@ -132,7 +132,7 @@ public function testEnsureStopped() $event->start(); usleep(100000); $event->ensureStopped(); - $this->assertEquals(300, $event->getDuration(), '', self::DELTA); + $this->assertEqualsWithDelta(300, $event->getDuration(), self::DELTA); } public function testStartTime() @@ -149,7 +149,7 @@ public function testStartTime() $event->start(); usleep(100000); $event->stop(); - $this->assertEquals(0, $event->getStartTime(), '', self::DELTA); + $this->assertEqualsWithDelta(0, $event->getStartTime(), self::DELTA); } public function testInvalidOriginThrowsAnException()