diff --git a/app/controller/admin.php b/app/controller/admin.php index 245291f5c443b9063b23cb56294bbfa7ec499eef..3e36887afac4a1da11e50c2f242cd2538a5f941b 100644 --- a/app/controller/admin.php +++ b/app/controller/admin.php @@ -1341,7 +1341,7 @@ class Admin extends Controller if ($identifier && $transaction && $effect && $amount && $statut == false) { continue; } - if ($statut == 'Refusé') { + if ($statut == 'Refusé' and !$testing) { $db->query("UPDATE dons SET status = 103 WHERE id='".$transaction."'"); continue; } @@ -1378,7 +1378,7 @@ class Admin extends Controller $user = $f3->get('container')['user_finder']->findByPseudo($user_field); } - if ($user) { + if ($user and !$testing) { $db->query("INSERT INTO identifiers(user_id, identifier) VALUES ('".$user['id']."', '".$identifier."')"); $email = $user['email']; } else { @@ -1393,7 +1393,9 @@ class Admin extends Controller $pseudo = $user_field; } $hash = hash('sha256', date("%Y-%m-%d %H:%i:%d").$email); - $f3->get('container')['command_handler']->handle(new UserCreateCommand($email, $hash, $pseudo, 0, 0)); + if (!$testing) { + $f3->get('container')['command_handler']->handle(new UserCreateCommand($email, $hash, $pseudo, 0, 0)); + }; } } else { $email = $result->fetch(\PDO::FETCH_ASSOC); @@ -1416,20 +1418,24 @@ class Admin extends Controller AND d.id='".$transaction."'"); $result = $stmt->fetch(\PDO::FETCH_ASSOC); if (!$result) { - // don non trouvé en statut 101. On le crée (la banque à raison) - // statut = cumul - $f3->get('container')['command_handler'] - ->handle(new DonationCreateCommand( - $user['id'], - 101, - $new_effect, - $amount, - 0, - 0 - )); - // Et on le récupère - $cumul = $db->lastInsertId(); - $don = $f3->get('container')['donation_finder']->findById($cumul); + if ($testing){ + $cumul = rand(50000, 70000); + } else { + // don non trouvé en statut 101. On le crée (la banque à raison) + // statut = cumul + $f3->get('container')['command_handler'] + ->handle(new DonationCreateCommand( + $user['id'], + 101, + $new_effect, + $amount, + 0, + 0 + )); + // Et on le récupère + $cumul = $db->lastInsertId(); + $don = $f3->get('container')['donation_finder']->findById($cumul); + }; } else { $cumul = $result['id']; } @@ -1447,19 +1453,21 @@ class Admin extends Controller if ($combien[0]==0) { $update ++; // Don récurrent non comptabilisé, on l'ajoute - $query = "INSERT INTO dons (status, - datec, - somme, - user_id, - cumul, - identifier) - VALUES ( - 102, - '".$new_effect."', - ".$amount.", - '".$user['id']."', - '".$cumul."', - '".$identifier."')"; + if (!$testing) { + $query = "INSERT INTO dons (status, + datec, + somme, + user_id, + cumul, + identifier) + VALUES ( + 102, + '".$new_effect."', + ".$amount.", + '".$user['id']."', + '".$cumul."', + '".$identifier."')"; + } if (!$testing) { $db->query($query); // On met alors à jour le cumul et le total de l'utilisateur concerné