projet-php/test/RDVRepoTest.php

77 lines
2.3 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);
2016-01-03 19:25:25 +00:00
$this->assertFalse($this->repo->add(date('Y-m-d H:i:s',time()),30,2,1));
$this->assertTrue($this->repo->delete($id));
2016-01-03 17:26:34 +00:00
$this->assertFalse($this->repo->add(date('Y-m-d H:i:s',time()),30,2,-1));
}
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());
2016-01-03 17:02:05 +00:00
$this->assertTrue($this->repo->updateDateTime(1,$date,'00:30:00'));
$result = $this->repo->getById(1);
$this->assertEquals($date,$result['DateRDV']);
}
public function testGetByDate(){
$date = date('Y-m-d H:i:s',time());
2016-01-03 17:02:05 +00:00
$this->assertTrue($this->repo->updateDateTime(1,$date,'00:30:00'));
$result = $this->repo->getByDate(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';
2016-01-03 17:02:05 +00:00
$this->assertTrue($this->repo->updateDateTime(1,$date,'00:30:00'));
$result = $this->repo->getByPatientAndDate(14,date('Y-m-d',strtotime($date)));
$this->assertTrue(isset($result[0]));
$this->assertEquals($result[0]['Id'],1);
}
public function testGetAll(){
2016-01-03 17:02:05 +00:00
$this->assertEquals(count($this->repo->getAll(-1)),100);
$this->assertEquals(count($this->repo->getAll(0)),100);
2016-01-03 17:02:05 +00:00
$this->assertEquals(count($this->repo->getAll(1)),0);
}
2015-12-26 12:22:06 +00:00
public function testGetByMonth(){
$date = '2015-12-00 00:00:00';
2016-01-03 17:02:05 +00:00
$this->assertEquals(count($this->repo->getByMonth(strtotime($date))),13);
2015-12-26 12:22:06 +00:00
}
2016-01-03 17:26:34 +00:00
public function testGetForMonth(){
$this->assertEquals(count($this->repo->getForMonth('12','2015')),2);
}
}