From 3d5246e2fa271c0f2e218b205345618f3d9ba73d Mon Sep 17 00:00:00 2001 From: Francis Whittle Date: Mon, 18 Nov 2019 13:35:26 +1100 Subject: [PATCH] CIVICRM-1268: Update CRM_Utils_MoneyTest::testEquals to match rounding behaviour. Existing test parameters were wrong. --- tests/phpunit/CRM/Utils/MoneyTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/CRM/Utils/MoneyTest.php b/tests/phpunit/CRM/Utils/MoneyTest.php index 41c5e7c985..ba6a3dc8ba 100644 --- a/tests/phpunit/CRM/Utils/MoneyTest.php +++ b/tests/phpunit/CRM/Utils/MoneyTest.php @@ -24,12 +24,12 @@ class CRM_Utils_MoneyTest extends CiviUnitTestCase { public function testEquals() { $testValue = 0.01; - for ($i = 0; $i <= 10; $i++) { - $equalValues = CRM_Utils_Money::equals($testValue, $testValue + ($i * 0.0001), 'USD'); - $this->assertTrue($equalValues); + for ($i = 0; $i < 10; $i++) { + $equalValues = CRM_Utils_Money::equals($testValue, $testValue + ($i * 0.0005), 'USD'); + $this->assertTrue($equalValues, 'Currency - USD' . $testValue . ' is equal to USD' . ($testValue + ($i * 0.0005))); } - $this->assertFalse(CRM_Utils_Money::equals($testValue, $testValue + 0.001000000001, 'USD')); + $this->assertFalse(CRM_Utils_Money::equals($testValue + 0.004, $testValue + 0.006, 'USD'), 'Currency - USD' . ($testValue + 0.004) . ' is different to USD' . ($testValue + 0.006)); } /** -- 2.25.1