76 lines
2.2 KiB
PHP
Executable File
76 lines
2.2 KiB
PHP
Executable File
<?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));
|
|
|
|
$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());
|
|
$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());
|
|
$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';
|
|
$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(){
|
|
$this->assertEquals(count($this->repo->getAll(-1)),100);
|
|
$this->assertEquals(count($this->repo->getAll(0)),100);
|
|
$this->assertEquals(count($this->repo->getAll(1)),0);
|
|
}
|
|
|
|
public function testGetByMonth(){
|
|
$date = '2015-12-00 00:00:00';
|
|
$this->assertEquals(count($this->repo->getByMonth(strtotime($date))),13);
|
|
}
|
|
|
|
public function testGetForMonth(){
|
|
$this->assertEquals(count($this->repo->getForMonth('12','2015')),2);
|
|
}
|
|
|
|
}
|