diff --git a/Website/gateways/GatewayChapter.php b/Website/gateways/GatewayChapter.php index ddbe63c..2cdba43 100755 --- a/Website/gateways/GatewayChapter.php +++ b/Website/gateways/GatewayChapter.php @@ -69,7 +69,12 @@ class GatewayChapter public function deleteChapter($id) { $query = "DELETE FROM chapters WHERE id = :id;"; - $this->con->executeQuery($query, array(':id' => array($id, PDO::PARAM_INT))); + $this->con->executeQuery( + $query, + array( + ':id' => array($id, PDO::PARAM_INT) + ) + ); return $this->con->getResults(); } diff --git a/Website/gateways/GatewayJouer.php b/Website/gateways/GatewayJouer.php index 916782c..952136e 100644 --- a/Website/gateways/GatewayJouer.php +++ b/Website/gateways/GatewayJouer.php @@ -12,6 +12,9 @@ class GatewayJouer public function __construct() { global $dns, $user, $pass; + if ($dns == NULL || $user == NULL || $pass == NULL) { + require_once(__DIR__ . '/../usages/Config_DB.php'); + } $this->con = new Connection($dns, $user, $pass); } @@ -37,7 +40,7 @@ class GatewayJouer ':idchapter' => array($jouer['idchapter'], PDO::PARAM_INT), ':idplayer' => array($jouer['idplayer'], PDO::PARAM_INT) ) - + ); $results = $this->con->getResults(); return $results[0]; @@ -67,6 +70,9 @@ class GatewayJouer ) ); $results = $this->con->getResults(); + if (count($results) == 0) { + return false; + } return $results[0]; } public function getMaxScoresWithChapter($player) @@ -81,4 +87,15 @@ class GatewayJouer $results = $this->con->getResults(); return $results; } + public function deleteJouer($jouer) + { + $query = "DELETE FROM jouer WHERE jouer.idplayer = :idplayer AND jouer.idchapter = :idchapter;"; + $this->con->executeQuery( + $query, + array( + ':idchapter' => array($jouer['idchapter'], PDO::PARAM_INT), + ':idplayer' => array($jouer['idplayer'], PDO::PARAM_INT) + ) + ); + } } \ No newline at end of file diff --git a/Website/gateways/GatewayLobby.php b/Website/gateways/GatewayLobby.php index ab50233..3fc41d9 100755 --- a/Website/gateways/GatewayLobby.php +++ b/Website/gateways/GatewayLobby.php @@ -12,19 +12,21 @@ class GatewayLobby public function __construct() { global $dns, $user, $pass; + if ($dns == NULL || $user == NULL || $pass == NULL) { + require_once(__DIR__ . '/../usages/Config_DB.php'); + } $this->con = new Connection($dns, $user, $pass); } - public function addLobby($lobby) { - $query = "insert into Lobbies(id,name,password,nbPlayer) values (:id,:name,:password,:nbPlayer);"; + $query = "insert into lobbies(id,name,password,nbplayers) values (:id,:name,:password,:nbplayers);"; $this->con->executeQuery( $query, array( ':id' => array($lobby->getId(), PDO::PARAM_INT), ':name' => array($lobby->getName(), PDO::PARAM_STR), ':password' => array($lobby->getPassword(), PDO::PARAM_STR), - ':nbPlayer' => array($lobby->getNbPlayer(), PDO::PARAM_INT) + ':nbplayers' => array($lobby->getNbPlayers(), PDO::PARAM_INT) ) ); } @@ -34,13 +36,13 @@ class GatewayLobby $query = "SELECT * FROM lobbies;"; $this->con->executeQuery($query); $results = $this->con->getResults(); - + return $results; } public function getLobbyByName($name) { - $query = "SELECT * FROM Lobbies WHERE name = :name;"; + $query = "SELECT * FROM lobbies WHERE name = :name;"; $this->con->executeQuery($query, array(':name' => array($name, PDO::PARAM_STR))); $results = $this->con->getResults(); if ($results == NULL) { @@ -52,7 +54,7 @@ class GatewayLobby public function deleteLobby($id) { - $query = "DELETE FROM Lobbies WHERE id = :id;"; + $query = "DELETE FROM lobbies WHERE id = :id;"; $this->con->executeQuery($query, array(':id' => array($id, PDO::PARAM_INT))); } diff --git a/Website/gateways/GatewayPlayer.php b/Website/gateways/GatewayPlayer.php index 69f1846..43064fd 100755 --- a/Website/gateways/GatewayPlayer.php +++ b/Website/gateways/GatewayPlayer.php @@ -12,12 +12,14 @@ class GatewayPlayer public function __construct() { global $dns, $user, $pass; + if ($dns == NULL || $user == NULL || $pass == NULL) { + require_once(__DIR__ . '/../usages/Config_DB.php'); + } $this->con = new Connection($dns, $user, $pass); } public function addPlayer($player) { - var_dump($player); $query = "insert into players(nickname,password) values (:nickname,:password);"; $this->con->executeQuery( $query, @@ -72,7 +74,7 @@ class GatewayPlayer ); } - public function updatePlayerPassword($id,$password) + public function updatePlayerPassword($id, $password) { $query = "UPDATE players SET password = :password WHERE id = :id;"; $this->con->executeQuery( diff --git a/Website/gateways/GatewayQuestion.php b/Website/gateways/GatewayQuestion.php index c74b98c..e6d0181 100755 --- a/Website/gateways/GatewayQuestion.php +++ b/Website/gateways/GatewayQuestion.php @@ -12,6 +12,9 @@ class GatewayQuestion public function __construct() { global $dns, $user, $pass; + if ($dns == NULL || $user == NULL || $pass == NULL) { + require_once(__DIR__ . '/../usages/Config_DB.php'); + } $this->con = new Connection($dns, $user, $pass); } @@ -36,7 +39,6 @@ class GatewayQuestion $query = "SELECT * FROM questions WHERE id = :id;"; $this->con->executeQuery($query, array(':id' => array($id, PDO::PARAM_INT))); $results = $this->con->getResults(); - return $results[0]; } @@ -62,8 +64,8 @@ class GatewayQuestion ); } - public function updateNbFails($question){ - // var_dump($question); + public function updateNbFails($question) + { $query = "UPDATE questions SET nbfails = :nbfails WHERE id = :id;"; $this->con->executeQuery( $query, @@ -74,7 +76,8 @@ class GatewayQuestion ); } - public function updateDifficulty($question){ + public function updateDifficulty($question) + { $query = "UPDATE questions SET difficulty = :difficulty WHERE id = :id;"; $this->con->executeQuery( $query, @@ -88,7 +91,12 @@ class GatewayQuestion public function deleteQuestionByID($id) { $query = "DELETE FROM questions WHERE id = :id;"; - $this->con->executeQuery($query, array(':id' => array($id, PDO::PARAM_INT))); + $this->con->executeQuery( + $query, + array( + ':id' => array($id, PDO::PARAM_INT) + ) + ); } public function getQuestionsByChapterAndDifficulty($idChapter, $difficulty) diff --git a/Website/tests/testControllers/testAdminAdministrators.php b/Website/tests/testControllers/testAdminAdministrators.php deleted file mode 100644 index 5f35f95..0000000 --- a/Website/tests/testControllers/testAdminAdministrators.php +++ /dev/null @@ -1,92 +0,0 @@ -expectOutputString('Location:/loginAdmin'); - $this->assertInstanceOf(ControllerAdminAdministrators::class, $controller); - } - - public function testDelete() - { - $controller = new ControllerAdminAdministrators(); - $controller->delete(["id" => 1]); - //$this->expectOutputString('Location:/admin/administrators'); - } - - public function testAdd() - { - $controller = new ControllerAdminAdministrators(); - $_SERVER['REQUEST_METHOD'] = 'POST'; - $_POST['username'] = 'test'; - $_POST['password'] = 'test'; - $controller->add(["id" => 1]); - $this->expectOutputString('Location:/admin/administrators'); - - $_SERVER['REQUEST_METHOD'] = 'GET'; - $controller->add(["id" => 1]); - $this->expectOutputString('Location:/admin/administrators'); - - $_SERVER['REQUEST_METHOD'] = 'POST'; - $_POST['username'] = ''; - $_POST['password'] = ''; - $controller->add(["id" => 1]); - $this->expectOutputString('Location:/admin/administrators'); - - $_SERVER['REQUEST_METHOD'] = 'POST'; - $_POST['username'] = 'test'; - $_POST['password'] = ''; - $controller->add(["id" => 1]); - $this->expectOutputString('Location:/admin/administrators'); - - $_SERVER['REQUEST_METHOD'] = 'POST'; - $_POST['username'] = ''; - $_POST['password'] = 'test'; - $controller->add(["id" => 1]); - $this->expectOutputString('Location:/admin/administrators'); - } - - public function testUpdateModal() - { - $controller = new ControllerAdminAdministrators(); - $controller->updateModal(["id" => 121]); - $this->expectOutputString('Location:/admin/administrators'); - } - - public function testUpdate() - { - $controller = new ControllerAdminAdministrators(); - $_SERVER['REQUEST_METHOD'] = 'POST'; - $_POST['username'] = 'test'; - $_POST['password'] = 'test'; - $controller->update(["id" => 1]); - $this->expectOutputString('Location:/admin/administrators'); - - $_SERVER['REQUEST_METHOD'] = 'GET'; - $controller->update(["id" => 1]); - $this->expectOutputString('Location:/admin/administrators'); - - $_SERVER['REQUEST_METHOD'] = 'POST'; - $_POST['username'] = ''; - $_POST['password'] = ''; - $controller->update(["id" => 1]); - $this->expectOutputString('Location:/admin/administrators'); - - $_SERVER['REQUEST_METHOD'] = 'POST'; - $_POST['username'] = 'test'; - $_POST['password'] = ''; - $controller->update(["id" => 1]); - $this->expectOutputString('Location:/admin/administrators'); - - $_SERVER['REQUEST_METHOD'] = 'POST'; - $_POST['username'] = ''; - $_POST['password'] = 'test'; - $controller->update(["id" => 1]); - $this->expectOutputString('Location:/admin/administrators'); - } -} diff --git a/Website/tests/testControllers/testAdminChapters.php b/Website/tests/testControllers/testAdminChapters.php deleted file mode 100644 index 13845c2..0000000 --- a/Website/tests/testControllers/testAdminChapters.php +++ /dev/null @@ -1,60 +0,0 @@ -expectOutputString('Location:/loginAdmin'); - $this->assertInstanceOf(ControllerAdminChapters::class, $controller); - } - - public function testDelete() - { - $controller = new ControllerAdminChapters(); - $controller->delete(["id" => 1]); - $this->expectOutputString('Location:/admin/chapters'); - } - - public function testAdd() - { - $controller = new ControllerAdminChapters(); - $_SERVER['REQUEST_METHOD'] = 'POST'; - $_POST['title'] = 'test'; - $_POST['content'] = 'test'; - $controller->add(["id" => 1]); - $this->expectOutputString('Location:/admin/chapters'); - - $_SERVER['REQUEST_METHOD'] = 'GET'; - $controller->add(["id" => 1]); - $this->expectOutputString('Location:/admin/chapters'); - - $_SERVER['REQUEST_METHOD'] = 'POST'; - $_POST['title'] = ''; - $_POST['content'] = ''; - $controller->add(["id" => 1]); - $this->expectOutputString('Location:/admin/chapters'); - - $_SERVER['REQUEST_METHOD'] = 'POST'; - $_POST['title'] = 'test'; - $_POST['content'] = ''; - $controller->add(["id" => 1]); - $this->expectOutputString('Location:/admin/chapters'); - - $_SERVER['REQUEST_METHOD'] = 'POST'; - $_POST['title'] = ''; - $_POST['content'] = 'test'; - $controller->add(["id" => 1]); - $this->expectOutputString('Location:/admin/chapters'); - } - - public function testUpdateModal() - { - $controller = new ControllerAdminChapters(); - $controller->updateModal(["id" => 121]); - $this->expectOutputString('Location:/admin/chapters'); - } -} \ No newline at end of file diff --git a/Website/tests/testControllers/testAdminQuestions.php b/Website/tests/testControllers/testAdminQuestions.php deleted file mode 100644 index 1c92631..0000000 --- a/Website/tests/testControllers/testAdminQuestions.php +++ /dev/null @@ -1,60 +0,0 @@ -expectOutputString('Location:/loginAdmin'); - $this->assertInstanceOf(ControllerAdminQuestions::class, $controller); - } - - public function testDelete() - { - $controller = new ControllerAdminQuestions(); - $controller->delete(["id" => 1]); - $this->expectOutputString('Location:/admin/questions'); - } - - public function testAdd() - { - $controller = new ControllerAdminQuestions(); - $_SERVER['REQUEST_METHOD'] = 'POST'; - $_POST['title'] = 'test'; - $_POST['content'] = 'test'; - $controller->add(["id" => 1]); - $this->expectOutputString('Location:/admin/questions'); - - $_SERVER['REQUEST_METHOD'] = 'GET'; - $controller->add(["id" => 1]); - $this->expectOutputString('Location:/admin/questions'); - - $_SERVER['REQUEST_METHOD'] = 'POST'; - $_POST['title'] = ''; - $_POST['content'] = ''; - $controller->add(["id" => 1]); - $this->expectOutputString('Location:/admin/questions'); - - $_SERVER['REQUEST_METHOD'] = 'POST'; - $_POST['title'] = 'test'; - $_POST['content'] = ''; - $controller->add(["id" => 1]); - $this->expectOutputString('Location:/admin/questions'); - - $_SERVER['REQUEST_METHOD'] = 'POST'; - $_POST['title'] = ''; - $_POST['content'] = 'test'; - $controller->add(["id" => 1]); - $this->expectOutputString('Location:/admin/questions'); - } - - public function testUpdateModal() - { - $controller = new ControllerAdminQuestions(); - $controller->updateModal(["id" => 121]); - $this->expectOutputString('Location:/admin/questions'); - } -} \ No newline at end of file diff --git a/Website/tests/testControllers/testFrontController.php b/Website/tests/testControllers/testFrontController.php deleted file mode 100644 index e69de29..0000000 diff --git a/Website/tests/testControllers/testUser.php b/Website/tests/testControllers/testUser.php deleted file mode 100644 index e69de29..0000000 diff --git a/Website/tests/testControllers/testUserLobby.php b/Website/tests/testControllers/testUserLobby.php deleted file mode 100644 index e69de29..0000000 diff --git a/Website/tests/testControllers/testUserPlayers.php b/Website/tests/testControllers/testUserPlayers.php deleted file mode 100644 index e69de29..0000000 diff --git a/Website/tests/testGateways/testAnswers.php b/Website/tests/testGateways/testAnswers.php index 49eec28..f4ee9f5 100644 --- a/Website/tests/testGateways/testAnswers.php +++ b/Website/tests/testGateways/testAnswers.php @@ -13,13 +13,14 @@ class testAnswers extends TestCase $gateway = new GatewayAnswer(); $answer = array( 'content' => 'This is a test answer', - 'idquestion' => 1 + 'idquestion' => 2 ); $answerId = $gateway->addAnswer($answer); assertNotEquals($answerId, null); $gateway->deleteAnswer($answerId); $answerId = $gateway->getAnswerByID($answerId); assertEquals($answerId, null); + $gateway->deleteAnswer($answerId); } public function testGetAnswerByID() @@ -32,11 +33,11 @@ class testAnswers extends TestCase public function testGetAnswersByIDQuestions() { $gateway = new GatewayAnswer(); - $answers = $gateway->getAnswersByIDQuestions(1); - assertEquals($answers[0]['content'], '4log_2(1)'); - assertEquals($answers[1]['content'], '1 – log_2(4)'); - assertEquals($answers[2]['content'], '-2'); - assertEquals($answers[3]['content'], '{log_2(1)}/{log_2(4)}'); + $answers = $gateway->getAnswersByIDQuestions(2); + assertEquals($answers[0]['content'], '4'); + assertEquals($answers[1]['content'], '-4'); + assertEquals($answers[2]['content'], 'on ne peut pas simplifier'); + assertEquals($answers[3]['content'], '1'); } public function testUpdateAnswer() @@ -44,13 +45,13 @@ class testAnswers extends TestCase $gateway = new GatewayAnswer(); $answer = array( 'content' => 'This is a test answer', - 'idquestion' => 1 + 'idquestion' => 2 ); $answerId = $gateway->addAnswer($answer); $answer = array( 'id' => $answerId, 'content' => 'This is a test answer updated', - 'idquestion' => 1 + 'idquestion' => 2 ); $gateway->updateAnswer($answerId, $answer); $answer = $gateway->getAnswerByID($answerId); diff --git a/Website/tests/testGateways/testJouer.php b/Website/tests/testGateways/testJouer.php new file mode 100644 index 0000000..cafb8a9 --- /dev/null +++ b/Website/tests/testGateways/testJouer.php @@ -0,0 +1,105 @@ +getPlayerByNickname("testUnit"); + if ($gatewayAnswer) { + $gwayPlayer->deletePlayerByID($gatewayAnswer['id']); + } + + $gatewayAnswer = $gwayChapter->verifyChapterByName("testUnit"); + if ($gatewayAnswer) { + $gwayChapter->deleteChapter($gatewayAnswer['id']); + } + + $gwayChapter->addChapter($chapterArray); + $gwayPlayer->addPlayer($playerArray); + $playerFromGWay = $gwayPlayer->getPlayerByNickname("testUnit"); + $chapterFromGWay = $gwayChapter->verifyChapterByName("testUnit"); + + $gway = new GatewayJouer(); + $gway->addJouer( + array( + 'idchapter' => $chapterFromGWay['id'], + 'idplayer' => $playerFromGWay['id'], + 'maxscore' => 0 + ) + ); + $maxScore = $gway->getMaxScoreByPlayerAndChapter( + array( + 'idchapter' => $chapterFromGWay['id'], + 'idplayer' => $playerFromGWay['id'] + ) + ); + assertEquals(0, $maxScore['maxscore']); + + $gway->updateJouer( + array( + 'idchapter' => $chapterFromGWay['id'], + 'idplayer' => $playerFromGWay['id'], + 'maxscore' => 10 + ) + ); + $maxScore = $gway->getMaxScoreByPlayerAndChapter( + array( + 'idchapter' => $chapterFromGWay['id'], + 'idplayer' => $playerFromGWay['id'] + ) + ); + assertEquals(10, $maxScore['maxscore']); + + $jouer = $gway->verifyJouer( + array( + 'idchapter' => $chapterFromGWay['id'], + 'idplayer' => $playerFromGWay['id'] + ) + ); + assertEquals($chapterFromGWay['id'], $jouer['idchapter']); + assertEquals($playerFromGWay['id'], $jouer['idplayer']); + + $player = new Player($playerFromGWay['id'], $playerFromGWay['nickname'], "testUnit"); + $maxScoreAndChapter = $gway->getMaxScoresWithChapter($player); + assertEquals(10, $maxScoreAndChapter[0]['maxscore']); + assertEquals($chapterFromGWay['id'], $maxScoreAndChapter[0]['idchapter']); + + $gway->deleteJouer( + array( + 'idchapter' => $chapterFromGWay['id'], + 'idplayer' => $playerFromGWay['id'] + ) + ); + $jouer = $gway->verifyJouer( + array( + 'idchapter' => $chapterFromGWay['id'], + 'idplayer' => $playerFromGWay['id'] + ) + ); + assertEquals(false, $jouer); + $gwayPlayer->deletePlayerByID($playerFromGWay['id']); + $gwayChapter->deleteChapter($chapterFromGWay['id']); + } + +} \ No newline at end of file diff --git a/Website/tests/testGateways/testLobby.php b/Website/tests/testGateways/testLobby.php index e69de29..ff426b8 100644 --- a/Website/tests/testGateways/testLobby.php +++ b/Website/tests/testGateways/testLobby.php @@ -0,0 +1,64 @@ +deleteLobby($gateway->getLobbyByName("testUnit")); + $gateway->addLobby($lobby); + $lobbyArray = $gateway->getLobbyByName("testUnit"); + $lobby2 = new Lobby($lobbyArray['id'], $lobbyArray['name'], $lobbyArray['password'], $lobbyArray['nbplayers']); + assertEquals($lobby->getId(), $lobby2->getId()); + assertEquals($lobby->getName(), $lobby2->getName()); + assertEquals($lobby->getPassword(), $lobby2->getPassword()); + assertEquals($lobby->getNbPlayers(), $lobby2->getNbPlayers()); + $gateway->deleteLobby($lobby->getId()); + } + + public function testGetLobbies() + { + $gateway = new GatewayLobby(); + $lobbies = $gateway->getLobbies(); + assertNotEquals(0, count($lobbies)); + } + + public function testGetLobbyByName() + { + $lobby = new Lobby(1, "testUnit", "testUnit", 1); + $gateway = new GatewayLobby(); + $gateway->deleteLobby($gateway->getLobbyByName("testUnit")); + $gateway->addLobby($lobby); + $lobbyArray = $gateway->getLobbyByName("testUnit"); + $lobby2 = new Lobby( + $lobbyArray['id'], + $lobbyArray['name'], + $lobbyArray['password'], + $lobbyArray['nbplayers'] + ); + assertEquals($lobby->getId(), $lobby2->getId()); + assertEquals($lobby->getName(), $lobby2->getName()); + assertEquals($lobby->getPassword(), $lobby2->getPassword()); + assertEquals($lobby->getNbPlayers(), $lobby2->getNbPlayers()); + $gateway->deleteLobby($lobby->getId()); + } + + public function testDeleteLobby() + { + $lobby = new Lobby(1, "testUnit", "testUnit", 1); + $gateway = new GatewayLobby(); + $gateway->deleteLobby($gateway->getLobbyByName("testUnit")); + $gateway->addLobby($lobby); + $gateway->deleteLobby($lobby->getId()); + $lobby2 = $gateway->getLobbyByName("testUnit"); + assertEquals(false, $lobby2); + } +} \ No newline at end of file diff --git a/Website/tests/testGateways/testPlayer.php b/Website/tests/testGateways/testPlayer.php index e69de29..0096476 100644 --- a/Website/tests/testGateways/testPlayer.php +++ b/Website/tests/testGateways/testPlayer.php @@ -0,0 +1,72 @@ +getPlayerByNickname("testUnit"); + if ($gatewayAnswer) { + $gateway->deletePlayerByID($gatewayAnswer['id']); + } + $gateway->addPlayer($player); + $player2 = $gateway->getPlayerByNickname("testUnit"); + assertEquals($player['nickname'], $player2['nickname']); + $gateway->deletePlayerByID($player['id']); + } + + public function testGetPlayers() + { + $gateway = new GatewayPlayer(); + $players = $gateway->getPlayers(); + assertNotEquals(0, count($players)); + } + + public function testGetPlayerByNickname() + { + $player = []; + $player['id'] = 1; + $player['nickname'] = "testUnit"; + $player['password'] = "testUnit"; + $gateway = new GatewayPlayer(); + $gatewayAnswer = $gateway->getPlayerByNickname("testUnit"); + if ($gatewayAnswer) { + $gateway->deletePlayerByID($gatewayAnswer['id']); + } + $gateway->addPlayer($player); + $player2 = $gateway->getPlayerByNickname("testUnit"); + assertEquals($player['nickname'], $player2['nickname']); + $gateway->deletePlayerByID($player['id']); + } + + public function testDeletePlayer() + { + $player = []; + $player['id'] = 1; + $player['nickname'] = "testUnit"; + $player['password'] = "testUnit"; + $gateway = new GatewayPlayer(); + $gatewayAnswer = $gateway->getPlayerByNickname("testUnit"); + if ($gatewayAnswer) { + $gateway->deletePlayerByID($gatewayAnswer['id']); + } + $gateway->addPlayer($player); + $gatewayAnswer = $gateway->getPlayerByNickname("testUnit"); + if ($gatewayAnswer) { + $gateway->deletePlayerByID($gatewayAnswer['id']); + } + $player2 = $gateway->getPlayerByNickname("testUnit"); + assertEquals(false, $player2); + } +} \ No newline at end of file diff --git a/Website/tests/testGateways/testQuestion.php b/Website/tests/testGateways/testQuestion.php index e69de29..3c697cc 100644 --- a/Website/tests/testGateways/testQuestion.php +++ b/Website/tests/testGateways/testQuestion.php @@ -0,0 +1,98 @@ +getQuestions()); + $lenght2 = count($gateway->getQuestionsByChapterAndDifficulty(1, 1)); + $question['id'] = $gateway->addQuestion($question); + + $gwayAnswer = new GatewayAnswer(); + $answer = array( + 'content' => 'This is a test answer', + 'idquestion' => $question['id'] + ); + $answer2 = array( + 'content' => 'This is a test answer 2', + 'idquestion' => $question['id'] + ); + $answer3 = array( + 'content' => 'This is a test answer 3', + 'idquestion' => $question['id'] + ); + $answer4 = array( + 'content' => 'This is a test answer 4', + 'idquestion' => $question['id'] + ); + $answerId1 = $gwayAnswer->addAnswer($answer); + $answerId2 = $gwayAnswer->addAnswer($answer2); + $answerId3 = $gwayAnswer->addAnswer($answer3); + $answerId4 = $gwayAnswer->addAnswer($answer4); + $question['idanswergood'] = $answerId1; + + $question2 = $gateway->getQuestionByID($question['id']); + assertEquals($question['content'], $question2['content']); + assertEquals($lenght + 1, count($gateway->getQuestions())); + assertEquals($lenght2 + 1, count($gateway->getQuestionsByChapterAndDifficulty(1, 1))); + + + $question['content'] = "test Unit 2_"; + $gateway->updateQuestion($question['id'], $question); + $question2 = $gateway->getQuestionByID($question['id']); + assertEquals($question['content'], $question2['content']); + + $question['difficulty'] = 2; + $questionInstance = new Question( + $question['id'], + $question['content'], + $question['idchapter'], + $question['difficulty'], + $question['nbfails'] + ); + $questionInstance->setDifficulty($question['difficulty']); + $gateway->updateDifficulty($questionInstance); + $question3 = $gateway->getQuestionByID($question['id']); + assertEquals($question['difficulty'], $question3['difficulty']); + + $question['nbfails'] = 1; + $questionInstance = new Question( + $question['id'], + $question['content'], + $question['idchapter'], + $question['difficulty'], + $question['nbfails'] + ); + $questionInstance->setNbFails($question['nbfails']); + $gateway->updateNbFails($questionInstance); + $question2 = $gateway->getQuestionByID($question['id']); + assertEquals($question['nbfails'], $question2['nbfails']); + + + $gateway->deleteQuestionByID($question['id']); + assertEquals($lenght, count($gateway->getQuestions())); + $gwayAnswer->deleteAnswer($answerId1); + $gwayAnswer->deleteAnswer($answerId2); + $gwayAnswer->deleteAnswer($answerId3); + $gwayAnswer->deleteAnswer($answerId4); + + } +} \ No newline at end of file diff --git a/Website/tests/testModels/testAdministrators.php b/Website/tests/testModels/testAdministrators.php deleted file mode 100644 index e69de29..0000000 diff --git a/Website/tests/testModels/testAsnwer.php b/Website/tests/testModels/testAsnwer.php deleted file mode 100644 index e69de29..0000000 diff --git a/Website/tests/testModels/testChapter.php b/Website/tests/testModels/testChapter.php deleted file mode 100644 index e69de29..0000000 diff --git a/Website/tests/testModels/testLobby.php b/Website/tests/testModels/testLobby.php deleted file mode 100644 index e69de29..0000000 diff --git a/Website/tests/testModels/testPlayer.php b/Website/tests/testModels/testPlayer.php deleted file mode 100644 index e69de29..0000000 diff --git a/Website/tests/testModels/testQuestion.php b/Website/tests/testModels/testQuestion.php deleted file mode 100644 index e69de29..0000000