From 3ee2764220ffcf199f268b933104873dc7689601 Mon Sep 17 00:00:00 2001 From: "dorian.hodin" Date: Sat, 25 Mar 2023 12:03:15 +0100 Subject: [PATCH] Merging Unit Test into Master --- Source/Config/Validate.php | 9 ++------- Source/Model/ModelAdmin.php | 2 +- Source/Model/ModelCandidate.php | 5 +---- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/Source/Config/Validate.php b/Source/Config/Validate.php index 2b10e51..3f0f7bf 100644 --- a/Source/Config/Validate.php +++ b/Source/Config/Validate.php @@ -102,7 +102,7 @@ class Validate /** * Vérifie si le nom est valide. * - * @param string $name Le nom a vérifié. + * @param string $username * @return bool Vrai si le nom est valide, faux sinon. */ @@ -117,7 +117,7 @@ class Validate /** * Vérifie si la description est valide. * - * @param string $description La description a vérifié. + * @param array $categories * @return bool Vrai si la description est valide, faux sinon. */ @@ -132,9 +132,4 @@ class Validate return true; } - public static function answer(string $answer): bool - { - global $answerMaxLength; - return (strlen($answer) <= $answerMaxLength); - } } \ No newline at end of file diff --git a/Source/Model/ModelAdmin.php b/Source/Model/ModelAdmin.php index 037c241..a586835 100644 --- a/Source/Model/ModelAdmin.php +++ b/Source/Model/ModelAdmin.php @@ -119,7 +119,7 @@ class ModelAdmin } $res = $this->client->request('POST', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/insertResponseInQuestion? response='.$response.'& - categories='.$categories.'& + categories='.json_encode($categories).'& $idQuestion='.$idQuestion ); if ($res->getStatusCode()!=200){ diff --git a/Source/Model/ModelCandidate.php b/Source/Model/ModelCandidate.php index 2cb62f9..8ac6939 100644 --- a/Source/Model/ModelCandidate.php +++ b/Source/Model/ModelCandidate.php @@ -46,7 +46,7 @@ class ModelCandidate if( count($exploded) == 3 ){ $questionsId[] = Clean::int($exploded[0]); $answer[] = Clean::simpleString($exploded[1]); - $categs = Clean::simpleStringArray($exploded[2]); + $categs = Clean::simpleString($exploded[2]); $categs = explode("_", $categs); array_pop($categs); $category[] = $categs; @@ -58,9 +58,6 @@ class ModelCandidate } } try { - if(!Validate::answer($answer) || !Validate::category($category)){ - throw new Exception("Les réponses ne sont pas valides"); - } $res = $this->client->request('GET', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/getForm'); if ($res->getStatusCode()!=200){ throw new Exception('GetForm failed');