Commit 608bf5a0 authored by Okhin's avatar Okhin

Ne pas exécuter les ordres en mode Test

parent d316a401
...@@ -1341,7 +1341,7 @@ class Admin extends Controller ...@@ -1341,7 +1341,7 @@ class Admin extends Controller
if ($identifier && $transaction && $effect && $amount && $statut == false) { if ($identifier && $transaction && $effect && $amount && $statut == false) {
continue; continue;
} }
if ($statut == 'Refusé') { if ($statut == 'Refusé' and !$testing) {
$db->query("UPDATE dons SET status = 103 WHERE id='".$transaction."'"); $db->query("UPDATE dons SET status = 103 WHERE id='".$transaction."'");
continue; continue;
} }
...@@ -1378,7 +1378,7 @@ class Admin extends Controller ...@@ -1378,7 +1378,7 @@ class Admin extends Controller
$user = $f3->get('container')['user_finder']->findByPseudo($user_field); $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."')"); $db->query("INSERT INTO identifiers(user_id, identifier) VALUES ('".$user['id']."', '".$identifier."')");
$email = $user['email']; $email = $user['email'];
} else { } else {
...@@ -1393,7 +1393,9 @@ class Admin extends Controller ...@@ -1393,7 +1393,9 @@ class Admin extends Controller
$pseudo = $user_field; $pseudo = $user_field;
} }
$hash = hash('sha256', date("%Y-%m-%d %H:%i:%d").$email); $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 { } else {
$email = $result->fetch(\PDO::FETCH_ASSOC); $email = $result->fetch(\PDO::FETCH_ASSOC);
...@@ -1416,20 +1418,24 @@ class Admin extends Controller ...@@ -1416,20 +1418,24 @@ class Admin extends Controller
AND d.id='".$transaction."'"); AND d.id='".$transaction."'");
$result = $stmt->fetch(\PDO::FETCH_ASSOC); $result = $stmt->fetch(\PDO::FETCH_ASSOC);
if (!$result) { if (!$result) {
// don non trouvé en statut 101. On le crée (la banque à raison) if ($testing){
// statut = cumul $cumul = rand(50000, 70000);
$f3->get('container')['command_handler'] } else {
->handle(new DonationCreateCommand( // don non trouvé en statut 101. On le crée (la banque à raison)
$user['id'], // statut = cumul
101, $f3->get('container')['command_handler']
$new_effect, ->handle(new DonationCreateCommand(
$amount, $user['id'],
0, 101,
0 $new_effect,
)); $amount,
// Et on le récupère 0,
$cumul = $db->lastInsertId(); 0
$don = $f3->get('container')['donation_finder']->findById($cumul); ));
// Et on le récupère
$cumul = $db->lastInsertId();
$don = $f3->get('container')['donation_finder']->findById($cumul);
};
} else { } else {
$cumul = $result['id']; $cumul = $result['id'];
} }
...@@ -1447,19 +1453,21 @@ class Admin extends Controller ...@@ -1447,19 +1453,21 @@ class Admin extends Controller
if ($combien[0]==0) { if ($combien[0]==0) {
$update ++; $update ++;
// Don récurrent non comptabilisé, on l'ajoute // Don récurrent non comptabilisé, on l'ajoute
$query = "INSERT INTO dons (status, if (!$testing) {
datec, $query = "INSERT INTO dons (status,
somme, datec,
user_id, somme,
cumul, user_id,
identifier) cumul,
VALUES ( identifier)
102, VALUES (
'".$new_effect."', 102,
".$amount.", '".$new_effect."',
'".$user['id']."', ".$amount.",
'".$cumul."', '".$user['id']."',
'".$identifier."')"; '".$cumul."',
'".$identifier."')";
}
if (!$testing) { if (!$testing) {
$db->query($query); $db->query($query);
// On met alors à jour le cumul et le total de l'utilisateur concerné // On met alors à jour le cumul et le total de l'utilisateur concerné
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment