Skip to content

Commit

Permalink
minor #32968 Use assertEqualsWithDelta when needed (jderusse)
Browse files Browse the repository at this point in the history
This PR was merged into the 3.4 branch.

Discussion
----------

Use assertEqualsWithDelta when needed

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #32844
| License       | MIT
| Doc PR        | NA

This PR replaces deprecated paramèter `$delta` of methods `assertEquals` by the dedicated method `assertEqualsWithDelta`

Commits
-------

3a0a901 Use assertEqualsWithDelta when required
  • Loading branch information
nicolas-grekas committed Aug 6, 2019
2 parents 443e923 + 3a0a901 commit 87c8561
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpFoundation/Tests/CookieTest.php
Expand Up @@ -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()
Expand Down
Expand Up @@ -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()
Expand Down
12 changes: 6 additions & 6 deletions src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php
Expand Up @@ -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();
Expand All @@ -83,15 +83,15 @@ 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()
{
$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();
Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down

0 comments on commit 87c8561

Please sign in to comment.