2015-12-08 08:31:47 +00:00
|
|
|
<?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);
|
2015-12-09 12:36:30 +00:00
|
|
|
$this->assertTrue($this->repo->delete($id));
|
2015-12-08 08:31:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetById(){
|
2015-12-09 12:36:30 +00:00
|
|
|
$result = $this->repo->getById(1);
|
|
|
|
$this->assertEquals(1,$result['Id']);
|
2015-12-08 08:31:47 +00:00
|
|
|
}
|
|
|
|
|
2015-12-09 12:36:30 +00:00
|
|
|
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']);
|
2015-12-08 08:31:47 +00:00
|
|
|
}
|
2015-12-09 12:36:30 +00:00
|
|
|
|
|
|
|
public function testGetByDate(){
|
|
|
|
$date = date('Y-m-d H:i:s',time());
|
|
|
|
$this->assertTrue($this->repo->updateDateTime(1,$date));
|
2015-12-10 10:52:08 +00:00
|
|
|
$result = $this->repo->getByDate($date = date('Y/m/d',strtotime($date)));
|
2015-12-09 12:36:30 +00:00
|
|
|
$this->assertTrue(isset($result[0]));
|
|
|
|
$this->assertEquals($result[0]['Id'],1);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetByPAtientAndDate(){
|
|
|
|
$date = '2015-12-20 13:33:00';
|
2015-12-10 08:04:19 +00:00
|
|
|
$this->assertTrue($this->repo->updateDateTime(1,$date));
|
2015-12-09 12:36:30 +00:00
|
|
|
$result = $this->repo->getByPatientAndDate(14,date('Y-m-d',strtotime($date)));
|
|
|
|
$this->assertTrue(isset($result[0]));
|
2015-12-10 08:04:19 +00:00
|
|
|
$this->assertEquals($result[0]['Id'],1);
|
2015-12-09 12:36:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetAll(){
|
2015-12-10 09:56:06 +00:00
|
|
|
$this->assertEquals(count($this->repo->getAll(-1)),99);
|
2015-12-09 12:36:30 +00:00
|
|
|
$this->assertEquals(count($this->repo->getAll(0)),100);
|
2015-12-10 09:56:06 +00:00
|
|
|
$this->assertEquals(count($this->repo->getAll(1)),1);
|
2015-12-09 12:36:30 +00:00
|
|
|
}
|
|
|
|
|
2015-12-08 08:31:47 +00:00
|
|
|
}
|