Commit 608bf5a0 authored by okhin's avatar okhin 🚴

Ne pas exécuter les ordres en mode Test

parent d316a401
Pipeline #2409 failed with stages
in 14 minutes and 42 seconds
......@@ -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é
......
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