]> git.agnieray.net Git - galette.git/commitdiff
Prevent issue on empty amount; add test
authorJohan Cwiklinski <johan@x-tnd.be>
Sun, 7 Nov 2021 10:17:49 +0000 (11:17 +0100)
committerJohan Cwiklinski <johan@x-tnd.be>
Sun, 7 Nov 2021 10:17:49 +0000 (11:17 +0100)
closes #1593

galette/lib/Galette/Entity/Contribution.php
tests/Galette/Entity/tests/units/Contribution.php

index 4a85b17a56e4f3d498a8168080fb8fa80f632915..9efc1fc887747c3744d80bc099ae6ba5a6671ca5 100644 (file)
@@ -467,7 +467,9 @@ class Contribution
                         }
                         break;
                     case 'montant_cotis':
-                        $this->_amount = $value;
+                        if (!empty($value)) {
+                            $this->_amount = $value;
+                        }
                         $value = strtr($value, ',', '.');
                         if (!is_numeric($value) && $value !== '') {
                             $this->errors[] = _T("- The amount must be an integer!");
index eab88571706132cd8278a0505323d6bdf72a1bce..0466ea299ba7339813d995b5be945158f997cb5f 100644 (file)
@@ -287,19 +287,27 @@ class Contribution extends GaletteTestCase
             'date_enreg' => $bdate->format('Y-m-d'),
             'date_debut_cotis' => $bdate->format('Y-m-d'),
             'date_fin_cotis' => $edate->format('Y-m-d'),
-
         ];
-        $check = $this->contrib->check($data, [], []);
-        if (is_array($check)) {
-            var_dump($check);
-        }
-        $this->boolean($check)->isTrue();
-
-        $store = $this->contrib->store();
-        $this->boolean($store)->isTrue();
+        $this->createContrib($data);
 
         $contrib = new \Galette\Entity\Contribution($this->zdb, $this->login, $this->contrib->id);
         $this->variable($contrib->amount)->isIdenticalTo(1280);
+
+        //empty amount
+        $data = [
+            'id_adh' => $this->adh->id,
+            'id_type_cotis' => 4, //donation
+            'montant_cotis' => '',
+            'type_paiement_cotis' => 4,
+            'info_cotis' => 'FAKER' . $this->seed,
+            'date_enreg' => $bdate->format('Y-m-d'),
+            'date_debut_cotis' => $bdate->format('Y-m-d'),
+            'date_fin_cotis' => $edate->format('Y-m-d'),
+        ];
+        $this->createContrib($data);
+
+        $contrib = new \Galette\Entity\Contribution($this->zdb, $this->login, $this->contrib->id);
+        $this->variable($contrib->amount)->isIdenticalTo(0);
     }
 
     /**