From 86b6ca3f1979473c98dd006ec2310840a90e788c Mon Sep 17 00:00:00 2001 From: Martin Tepper Date: Thu, 13 Oct 2022 07:34:47 +0200 Subject: [PATCH 1/4] use a better method to compore float values --- .../Tests/Controller/Payment/CashControllerTest.php | 6 ++++-- .../Tests/Repository/TransactionRepositoryTest.php | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Mealz/AccountingBundle/Tests/Controller/Payment/CashControllerTest.php b/src/Mealz/AccountingBundle/Tests/Controller/Payment/CashControllerTest.php index fb40afae9..354e6f056 100644 --- a/src/Mealz/AccountingBundle/Tests/Controller/Payment/CashControllerTest.php +++ b/src/Mealz/AccountingBundle/Tests/Controller/Payment/CashControllerTest.php @@ -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); } } diff --git a/src/Mealz/AccountingBundle/Tests/Repository/TransactionRepositoryTest.php b/src/Mealz/AccountingBundle/Tests/Repository/TransactionRepositoryTest.php index 991855cf1..c125c3b9a 100644 --- a/src/Mealz/AccountingBundle/Tests/Repository/TransactionRepositoryTest.php +++ b/src/Mealz/AccountingBundle/Tests/Repository/TransactionRepositoryTest.php @@ -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); } /** From 6f8ef624b771cdf6f916fa4a0280c0a5c84ebfd0 Mon Sep 17 00:00:00 2001 From: Martin Tepper Date: Thu, 13 Oct 2022 07:45:34 +0200 Subject: [PATCH 2/4] use php-cs-fixer version from composer file --- .github/workflows/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d5625b812..122fcc905 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -31,7 +31,6 @@ jobs: tools: composer:v2 - name: Check code formatting with PHP-CS-Fixer run: | - rm composer.json composer.lock composer require friendsofphp/php-cs-fixer vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist --diff --dry-run -v From 53d0a1ed14b49e8de705b950a9e5aab7a65e7ac6 Mon Sep 17 00:00:00 2001 From: Martin Tepper Date: Thu, 13 Oct 2022 07:51:01 +0200 Subject: [PATCH 3/4] define version --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 122fcc905..0e3cf13a0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -31,7 +31,8 @@ jobs: tools: composer:v2 - name: Check code formatting with PHP-CS-Fixer run: | - composer require friendsofphp/php-cs-fixer + rm composer.json composer.lock + composer require friendsofphp/php-cs-fixer:^3.3 vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist --diff --dry-run -v lint: From 59ec86bf22207c737cad455bdfdfe63156206d7b Mon Sep 17 00:00:00 2001 From: Martin Tepper Date: Thu, 13 Oct 2022 07:52:44 +0200 Subject: [PATCH 4/4] define version --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0e3cf13a0..c0d721d49 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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:^3.3 + composer require friendsofphp/php-cs-fixer:3.4 vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist --diff --dry-run -v lint: