projet-php/test/RDVRepoTest.php

64 lines
1.8 KiB
PHP
Raw Normal View History

<?php
/**
* Created by PhpStorm.
* User: seekdasky
* Date: 08/12/15
* Time: 08:43
*/
class RDVRepoTest extends PHPUnit_Framework_TestCase
{
private $repo;
public function __construct()
{
$this->repo = new RDVRepo();
}
public function testConstruct(){
$this->assertTrue(new RDVRepo() instanceof RDVRepo);
}
public function testAdd(){
$id = $this->repo->add(date('Y-m-d H:i:s',time()),30,2,1);
$this->assertNotNull($id);
$this->assertNotFalse($id);
$this->assertTrue($this->repo->delete($id));
}
public function testGetById(){
$result = $this->repo->getById(1);
$this->assertEquals(1,$result['Id']);
}
public function testUpdateTime(){
$date = date('Y-m-d H:i:s',time());
$this->assertTrue($this->repo->updateDateTime(1,$date));
$result = $this->repo->getById(1);
$this->assertEquals($date,$result['DateRDV']);
}
public function testGetByDate(){
$date = date('Y-m-d H:i:s',time());
$this->assertTrue($this->repo->updateDateTime(1,$date));
$result = $this->repo->getByDate($date = date('Y-m-d',strtotime($date)));
$this->assertTrue(isset($result[0]));
$this->assertEquals($result[0]['Id'],1);
}
public function testGetByPAtientAndDate(){
$date = '2015-12-20 13:33:00';
$this->assertTrue($this->repo->updateDateTime(85,$date));
$result = $this->repo->getByPatientAndDate(14,date('Y-m-d',strtotime($date)));
$this->assertTrue(isset($result[0]));
$this->assertEquals($result[0]['Id'],85);
}
public function testGetAll(){
$this->assertEquals(count($this->repo->getAll(-1)),99);
$this->assertEquals(count($this->repo->getAll(0)),100);
$this->assertEquals(count($this->repo->getAll(1)),2);
}
}