Skip to content

Commit

Permalink
Merge pull request #259 from AOEpeople/security/update-packages
Browse files Browse the repository at this point in the history
use a better method to compore float values
  • Loading branch information
hacksch authored Oct 13, 2022
2 parents 503cb09 + 59ec86b commit 2236e5d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Check code formatting with PHP-CS-Fixer
run: |
rm composer.json composer.lock
composer require friendsofphp/php-cs-fixer
composer require friendsofphp/php-cs-fixer:3.4
vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist --diff --dry-run -v
lint:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ function ($node, $i) {
$transactionAmount += (float) trim(substr($transaction, 1, strpos($transaction, '')));
}

$calculatedBalance = round($previousBalance - $participationAmount + $transactionAmount, 2);
$this->assertEquals($currentBalance, $calculatedBalance);
$assumedTotalAmount = $previousBalance - $participationAmount + $transactionAmount;

$epsilon = 0.00001;
$this->assertTrue(abs($currentBalance - $assumedTotalAmount) < $epsilon);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,11 @@ public function testTransactionsSummedUpByLastMonth(): void
$usersTotalAmount = floatval($userData[$firstTransaction->getProfile()->getUsername()]['amount']);

// calculate sum of amount for tempTransactions
$assumedTotalAmount = round($this->getAssumedTotalAmountForTransactionsFromLastMonth($tempTransactions), 2);
$assumedTotalAmount = $this->getAssumedTotalAmountForTransactionsFromLastMonth($tempTransactions);

// compare both amounts
$this->assertEquals($usersTotalAmount, $assumedTotalAmount);
$epsilon = 0.00001;
$this->assertTrue(abs($usersTotalAmount - $assumedTotalAmount) < $epsilon);
}

/**
Expand Down

0 comments on commit 2236e5d

Please sign in to comment.