<?php
use PHPUnit\Framework\TestCase;

use Model\User;
use Database\AthleteEntity;
use Database\AthleteGateway;
use Database\Connexion;
use Database\AthleteMapper;

class MapperTest extends TestCase {

    public function testMapperAthlete() {

        //$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);


        $athleteGateway = new AthleteGateway($connexion);
        $result = $athleteGateway->getAthlete();

        $map = new AthleteMapper ();
        //SQL To AthleteEntity
        $athleteEntity = $map->athleteSqlToEntity($result);


        foreach($athleteEntity as $ath){

            $result = $ath->getNom();
            var_dump($result);
            //Pour chaque AthleteEntity : Athlete Entity To User avec Role Athlete(Model)
            $user = $map->athleteEntityToModel($ath);
            var_dump($user->getId());
            //Pour chaque Athlete du Model -> Athlete Entity
            $res = $map->athleteToEntity($user);
            var_dump($res->getIdAthlete());
        }
    }
}