Merge pull request #17390 from mattwire/api3activitydatetimedefault
[civicrm-core.git] / tests / phpunit / CRM / Utils / MoneyTest.php
index 6d3044cd4a8977c0d34787ae632cb81fe2bfa415..ba6a3dc8ba7320686ecc688ba2a2f7de59dd0926 100644 (file)
@@ -24,26 +24,26 @@ 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));
   }
 
   /**
    * @return array
    */
   public function subtractCurrenciesDataProvider() {
-    return array(
-      array(number_format(300.00, 2), number_format(299.99, 2), 'USD', number_format(0.01, 2)),
-      array(2, 1, 'USD', 1),
-      array(0, 0, 'USD', 0),
-      array(1, 2, 'USD', -1),
-      array(number_format(19.99, 2), number_format(20.00, 2), 'USD', number_format(-0.01, 2)),
-      array('notanumber', 5.00, 'USD', NULL),
-    );
+    return [
+      [number_format(300.00, 2), number_format(299.99, 2), 'USD', number_format(0.01, 2)],
+      [2, 1, 'USD', 1],
+      [0, 0, 'USD', 0],
+      [1, 2, 'USD', -1],
+      [number_format(19.99, 2), number_format(20.00, 2), 'USD', number_format(-0.01, 2)],
+      ['notanumber', 5.00, 'USD', NULL],
+    ];
   }
 
   /**