projet-php/test/PatientRepoTest.php

55 lines
1.7 KiB
PHP
Raw Permalink Normal View History

<?php
/**
* Created by PhpStorm.
* User: seekdasky
* Date: 03/12/15
* Time: 12:31
*/
class PatientRepoTest extends PHPUnit_Framework_TestCase
{
private $repo;
public function __construct()
{
$this->repo = new PatientRepo();
}
public function testConstruct(){
$this->assertTrue(new PatientRepo() instanceof PatientRepo);
}
public function testGetById(){
$this->assertEquals($this->repo->getById(2)['Nom'],'KEMP');
}
public function testAddAndDeletePatient(){
$id = $this->repo->add('M','Lucas','Mascaro','3 rue des fleurs qui sentent bon',NULL,'Pimpous-Les-Bains','31524','1996-11-19','Toulouse','123456789876543', 69);
$this->assertNotNull($id);
$this->assertTrue($this->repo->delete($id));
}
public function testSearch(){
$this->assertEquals($this->repo->search('KEMP','Clay')[0]['Nom'],'KEMP');
}
public function testUpdateMedecinTraitant(){
$id = rand(0,100);
$this->repo->updateMedecinTraitant(2,$id);
$this->assertEquals($this->repo->getById(2)['MedecinTraitant'],$id);
}
public function testGetAll(){
$this->assertEquals(count($this->repo->getAll()),100);
}
public function testUpdate(){
$id = PatientRepo::add('M','Lucas','Mascaro','3 rue des fleurs qui sentent bon',NULL,'Pimpous-Les-Bains','31524','1996-11-19','Toulouse','123456789876543', 69);
2016-01-03 18:13:42 +00:00
$this->assertEquals(0,PatientRepo::update($id,'F','Lucas','Mascaro','3 rue des fleurs qui sentent bon','lol','Pimpous-Les-Bains','31524','19/11/1996','Toulouse','123456789876543', 69));
$patient = PatientRepo::getById($id);
$this->assertEquals('F',$patient['Civilite']);
PatientRepo::delete($id);
}
}