tests: port assertEquals() with delta to assertEqualsWithDelta()

assertEquals() in phpunit 9.5 no longer takes a delta parameter
and has assertEqualsWithDelta() as a replacement. This means
float get compared without a delta atm, and a recent phpunit
release (9.5.25) has made float comparisons stricter resulting in
test suite errors such as:

1) SubtaskTimeTrackingModelTest::testCalculateSubtaskTime
Total spent
Failed asserting that 3.3000000000000003 matches expected 3.3.
tests/units/Model/SubtaskTimeTrackingModelTest.php:186

This replaces all assertEquals() calls that pass a delta value
with assertEqualsWithDelta().
This commit is contained in:
Christoph Reiter
2022-10-10 11:38:19 +02:00
committed by Frédéric Guillot
parent 2d4ee932da
commit 0b8a270bbb
17 changed files with 82 additions and 82 deletions

View File

@@ -25,8 +25,8 @@ class CommentModelTest extends Base
$this->assertEquals(1, $comment['task_id']);
$this->assertEquals(1, $comment['user_id']);
$this->assertEquals('admin', $comment['username']);
$this->assertEquals(time(), $comment['date_creation'], '', 3);
$this->assertEquals(time(), $comment['date_modification'], '', 3);
$this->assertEqualsWithDelta(time(), $comment['date_creation'], 3, '');
$this->assertEqualsWithDelta(time(), $comment['date_modification'], 3, '');
$comment = $commentModel->getById(2);
$this->assertNotEmpty($comment);
@@ -34,8 +34,8 @@ class CommentModelTest extends Base
$this->assertEquals(1, $comment['task_id']);
$this->assertEquals(0, $comment['user_id']);
$this->assertEquals('', $comment['username']);
$this->assertEquals(time(), $comment['date_creation'], '', 3);
$this->assertEquals(time(), $comment['date_modification'], '', 3);
$this->assertEqualsWithDelta(time(), $comment['date_creation'], 3, '');
$this->assertEqualsWithDelta(time(), $comment['date_modification'], 3, '');
}
public function testGetAll()
@@ -75,7 +75,7 @@ class CommentModelTest extends Base
$comment = $commentModel->getById(1);
$this->assertNotEmpty($comment);
$this->assertEquals('bla', $comment['comment']);
$this->assertEquals(time(), $comment['date_modification'], '', 3);
$this->assertEqualsWithDelta(time(), $comment['date_modification'], 3, '');
}
public function testRemove()