You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
216 lines
7.2 KiB
216 lines
7.2 KiB
<?php
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
//use Database\{Connexion, AthleteGateway,AthleteEntity};
|
|
use Database\AthleteEntity;
|
|
use Database\AthleteGateway;
|
|
use Database\Connexion;
|
|
use Database\AthleteMapper;
|
|
use Database\CoachGateway;
|
|
use Database\CoachEntity;
|
|
use Database\CoachMapper;
|
|
|
|
class GatewayTest extends TestCase {
|
|
|
|
//Partie concernant les Athlètes
|
|
|
|
public function testGetAthlete() {
|
|
|
|
//$dsn = "pgsql:host=londres;port=8888;dbname=dbkemonteiro2;user=kemonteiro2;password=Mdp";
|
|
|
|
require "loginDatabase.php";
|
|
|
|
$connexion = new Connexion($dsn,$username,$password);
|
|
|
|
|
|
$athleteGateway = new AthleteGateway($connexion);
|
|
$result = $athleteGateway->getAthlete();
|
|
//var_dump($result);
|
|
}
|
|
|
|
/* Fonctionne mais en commentaire pour pas add et del a chaque fois
|
|
public function testAddAthlete(){
|
|
$dsn = "mysql:host=londres;dbname=dbkemonteiro2;";
|
|
$username = "kemonteiro2";
|
|
$password = "#Phpmyadmin63";
|
|
|
|
$connexion = new Connexion($dsn,$username,$password);
|
|
|
|
|
|
$athleteGateway = new AthleteGateway($connexion);
|
|
|
|
$dateSpecifique = "2023-11-26";
|
|
$timestamp = strtotime($dateSpecifique);
|
|
$dateSQL = date("Y-m-d", $timestamp);
|
|
|
|
$athleteEntity = new AthleteEntity();
|
|
$athleteEntity->setNom('John');
|
|
$athleteEntity->setPrenom('Doe');
|
|
$athleteEntity->setIdAthlete(1234);
|
|
$athleteEntity->setEmail('kevin.monteiro@gmail.fr');
|
|
$athleteEntity->setSexe('H');
|
|
$athleteEntity->setTaille(169);
|
|
$athleteEntity->setPoids(69);
|
|
$athleteEntity->setMotDePasse('motdepasse');
|
|
$athleteEntity->setDateNaissance($dateSQL);
|
|
|
|
$result2 = $athleteGateway->addAthlete($athleteEntity);
|
|
}
|
|
|
|
|
|
public function testDeleteAthlete(){
|
|
$dsn = "mysql:host=londres;dbname=dbkemonteiro2;";
|
|
$username = "kemonteiro2";
|
|
$password = "#Phpmyadmin63";
|
|
|
|
$connexion = new Connexion($dsn,$username,$password);
|
|
|
|
$athleteGateway = new AthleteGateway($connexion);
|
|
$result = $athleteGateway->deleteAthlete( //idAthlete );
|
|
var_dump($result);
|
|
|
|
}*/
|
|
|
|
public function testUpdateAthlete(){
|
|
$dsn = "mysql:host=londres;dbname=dbkemonteiro2;";
|
|
$username = "kemonteiro2";
|
|
$password = "#Phpmyadmin63";
|
|
|
|
$connexion = new Connexion($dsn,$username,$password);
|
|
|
|
$athleteGateway = new AthleteGateway($connexion);
|
|
|
|
$dateSpecifique = "2004-08-26";
|
|
$timestamp = strtotime($dateSpecifique);
|
|
$dateSQL = date("Y-m-d", $timestamp);
|
|
|
|
$athleteEntity = new AthleteEntity();
|
|
$athleteEntity->setNom('John');
|
|
$athleteEntity->setPrenom('Doe');
|
|
$athleteEntity->setIdAthlete(13);
|
|
$athleteEntity->setEmail('kevin.monteiro@gmail.fr');
|
|
$athleteEntity->setSexe('H');
|
|
$athleteEntity->setTaille(169);
|
|
$athleteEntity->setPoids(69);
|
|
$athleteEntity->setMotDePasse('motdepasse');
|
|
$athleteEntity->setDateNaissance($dateSQL);
|
|
$athleteEntity->setIsCoach(FALSE);
|
|
$athleteEntity->setCoachId(NULL);
|
|
|
|
$athleteEntity2 = new AthleteEntity();
|
|
$athleteEntity2->setNom('Monteiro');
|
|
$athleteEntity2->setPrenom('Kevin');
|
|
$athleteEntity2->setIdAthlete(13);
|
|
$athleteEntity2->setEmail('kevin.monteiro@gmail.fr');
|
|
$athleteEntity2->setSexe('H');
|
|
$athleteEntity2->setTaille(169);
|
|
$athleteEntity2->setPoids(69);
|
|
$athleteEntity2->setMotDePasse('motdepasse');
|
|
$athleteEntity2->setDateNaissance($dateSQL);
|
|
$athleteEntity2->setIsCoach(TRUE);
|
|
$athleteEntity2->setCoachId(1);
|
|
|
|
$result = $athleteGateway->updateAthlete($athleteEntity, $athleteEntity2);
|
|
}
|
|
|
|
//Partie concernant les Coachs
|
|
|
|
public function testGetCoach() {
|
|
|
|
//$dsn = "pgsql:host=londres;port=8888;dbname=dbkemonteiro2;user=kemonteiro2;password=Mdp";
|
|
|
|
$dsn = "mysql:host=londres;dbname=dbkemonteiro2;";
|
|
$username = "kemonteiro2";
|
|
$password = "#Phpmyadmin63";
|
|
|
|
$connexion = new Connexion($dsn,$username,$password);
|
|
|
|
|
|
$coachGateway = new CoachGateway($connexion);
|
|
$result = $coachGateway->getCoach();
|
|
var_dump($result);
|
|
}
|
|
/*
|
|
//Fonctionne PAS A PARTIR DE LA
|
|
public function testAddCoach(){
|
|
$dsn = "mysql:host=londres;dbname=dbkemonteiro2;";
|
|
$username = "kemonteiro2";
|
|
$password = "#Phpmyadmin63";
|
|
|
|
$connexion = new Connexion($dsn,$username,$password);
|
|
|
|
|
|
$coachGateway = new CoachGateway($connexion);
|
|
|
|
$dateSpecifique = "2023-11-26";
|
|
$timestamp = strtotime($dateSpecifique);
|
|
$dateSQL = date("Y-m-d", $timestamp);
|
|
|
|
$coachEntity = new CoachEntity();
|
|
$coachEntity->setNom('John');
|
|
$coachEntity->setPrenom('Doe');
|
|
$coachEntity->setIdCoach(1234);
|
|
$coachEntity->setEmail('kevin.monteiro@gmail.fr');
|
|
$coachEntity->setSexe('H');
|
|
$coachEntity->setTaille(169);
|
|
$coachEntity->setPoids(69);
|
|
$coachEntity->setMotDePasse('motdepasse');
|
|
$coachEntity->setDateNaissance($dateSQL);
|
|
|
|
$result2 = $coachGateway->addCoach($coachEntity);
|
|
}
|
|
|
|
|
|
public function testDeleteAthlete(){
|
|
$dsn = "mysql:host=londres;dbname=dbkemonteiro2;";
|
|
$username = "kemonteiro2";
|
|
$password = "#Phpmyadmin63";
|
|
|
|
$connexion = new Connexion($dsn,$username,$password);
|
|
|
|
$athleteGateway = new AthleteGateway($connexion);
|
|
$result = $athleteGateway->deleteAthlete( //idAthlete );
|
|
var_dump($result);
|
|
|
|
}*/
|
|
/*
|
|
public function testUpdateAthlete(){
|
|
$dsn = "mysql:host=londres;dbname=dbkemonteiro2;";
|
|
$username = "kemonteiro2";
|
|
$password = "#Phpmyadmin63";
|
|
|
|
$connexion = new Connexion($dsn,$username,$password);
|
|
|
|
$athleteGateway = new AthleteGateway($connexion);
|
|
|
|
$dateSpecifique = "2004-08-26";
|
|
$timestamp = strtotime($dateSpecifique);
|
|
$dateSQL = date("Y-m-d", $timestamp);
|
|
|
|
$athleteEntity = new AthleteEntity();
|
|
$athleteEntity->setNom('John');
|
|
$athleteEntity->setPrenom('Doe');
|
|
$athleteEntity->setIdAthlete(13);
|
|
$athleteEntity->setEmail('kevin.monteiro@gmail.fr');
|
|
$athleteEntity->setSexe('H');
|
|
$athleteEntity->setTaille(169);
|
|
$athleteEntity->setPoids(69);
|
|
$athleteEntity->setMotDePasse('motdepasse');
|
|
$athleteEntity->setDateNaissance($dateSQL);
|
|
|
|
$athleteEntity2 = new AthleteEntity();
|
|
$athleteEntity2->setNom('Monteiro');
|
|
$athleteEntity2->setPrenom('Kevin');
|
|
$athleteEntity2->setIdAthlete(13);
|
|
$athleteEntity2->setEmail('kevin.monteiro@gmail.fr');
|
|
$athleteEntity2->setSexe('H');
|
|
$athleteEntity2->setTaille(169);
|
|
$athleteEntity2->setPoids(69);
|
|
$athleteEntity2->setMotDePasse('motdepasse');
|
|
$athleteEntity2->setDateNaissance($dateSQL);
|
|
|
|
$result = $athleteGateway->updateAthlete($athleteEntity, $athleteEntity2);
|
|
}*/
|
|
}
|