📄 leaverequeststest.php
字号:
$this->assertNotNull($res, 'Record not found');
$this->assertSame(2, count($res), 'Wrong number of records found');
// Change status to Cancelled - not shown
$this->assertTrue(mysql_query("UPDATE `hs_hr_leave` SET `leave_status`=". Leave::LEAVE_STATUS_LEAVE_CANCELLED." WHERE leave_request_id = 10"), mysql_error());
$this->assertTrue(mysql_query("UPDATE `hs_hr_leave` SET `leave_status`=". Leave::LEAVE_STATUS_LEAVE_CANCELLED." WHERE leave_request_id = 11"), mysql_error());
$res = $leaveObj->retriveLeaveRequestsSupervisor($supervisorId);
$this->assertNull($res, 'Should not return any results');
// Change status to Taken - not shown
$this->assertTrue(mysql_query("UPDATE `hs_hr_leave` SET `leave_status`=". Leave::LEAVE_STATUS_LEAVE_TAKEN." WHERE leave_request_id = 10"), mysql_error());
$this->assertTrue(mysql_query("UPDATE `hs_hr_leave` SET `leave_status`=". Leave::LEAVE_STATUS_LEAVE_TAKEN." WHERE leave_request_id = 11"), mysql_error());
$res = $leaveObj->retriveLeaveRequestsSupervisor($supervisorId);
$this->assertNull($res, 'Should not return any results');
}
public function testApplyLeave1() {
$employeeId = '012';
$this->classLeaveRequest->setEmployeeId($employeeId);
$this->classLeaveRequest->setLeaveTypeId("LTY010");
$this->classLeaveRequest->setLeaveFromDate(date('Y-m-d', time()+3600*24));
$this->classLeaveRequest->setLeaveToDate(date('Y-m-d', time()+3600*24));
$this->classLeaveRequest->setLeaveLengthHours($this->classLeaveRequest->lengthFullDay);
$this->classLeaveRequest->setLeaveStatus("1");
$this->classLeaveRequest->setLeaveComments("New Leave 1");
$this->classLeaveRequest->applyLeaveRequest();
$newId = $this->classLeaveRequest->getLeaveRequestId();
$leaveObj = $this->classLeaveRequest;
$res = $leaveObj->retriveLeaveRequestsEmployee($employeeId);
$this->assertNotNull($res, 'Record not found');
$this->assertSame(1, count($res), 'Wrong number of records found');
$expected[0] = array($newId, 'Medical', date('Y-m-d', time()+3600*24), null, '8.00', '1.00');
for ($i=0; $i<count($res); $i++) {
$this->assertSame($expected[$i][0], $res[$i]->getLeaveRequestId(), 'Wrong Leave Request Id');
$this->assertSame($expected[$i][1], $res[$i]->getLeaveTypeName(), 'Wrong Leave Type Name');
$this->assertSame($expected[$i][2], $res[$i]->getLeaveFromDate(), 'Wrong From Date');
$this->assertSame($expected[$i][3], $res[$i]->getLeaveToDate(), 'Wrong To Date');
$this->assertSame($expected[$i][4], $res[$i]->getLeaveLengthHours(), "Wrong length(hours)");
$this->assertEquals($expected[$i][5], $res[$i]->getNoDays(), "Wrong length(days)");
}
}
public function testApplyLeave2() {
$employeeId = '012';
$this->classLeaveRequest->setEmployeeId($employeeId);
$this->classLeaveRequest->setLeaveTypeId("LTY010");
$this->classLeaveRequest->setLeaveFromDate(date('Y-m-d', time()+3600*24));
$this->classLeaveRequest->setLeaveToDate(date('Y-m-d', time()+3600*24*3));
$this->classLeaveRequest->setLeaveLengthHours($this->classLeaveRequest->lengthFullDay);
$this->classLeaveRequest->setLeaveStatus("1");
$this->classLeaveRequest->setLeaveComments("New Leave 1");
$this->classLeaveRequest->applyLeaveRequest();
$newId = $this->classLeaveRequest->getLeaveRequestId();
$leaveObj = $this->classLeaveRequest;
$res = $leaveObj->retriveLeaveRequestsEmployee($employeeId);
$this->assertNotNull($res, 'Record not found');
$this->assertSame(1, count($res), 'Wrong number of records found');
$expected[0] = array($newId, 'Medical', date('Y-m-d', time()+3600*24), date('Y-m-d', time()+3600*24*3), '24.00', '3.00');
for ($i=0; $i<count($res); $i++) {
$this->assertSame($expected[$i][0], $res[$i]->getLeaveRequestId(), 'Wrong Leave Request Id');
$this->assertSame($expected[$i][1], $res[$i]->getLeaveTypeName(), 'Wrong Leave Type Name');
$this->assertSame($expected[$i][2], $res[$i]->getLeaveFromDate(), 'Wrong From Date');
$this->assertSame($expected[$i][3], $res[$i]->getLeaveToDate(), 'Wrong To Date');
$this->assertSame($expected[$i][4], $res[$i]->getLeaveLengthHours(), "Wrong length(hours)");
$this->assertSame($expected[$i][5], $res[$i]->getNoDays(), "Wrong length(days)");
}
}
public function testApplyLeave3() {
// Mark Sunday as weekend
$this->assertTrue(mysql_query("UPDATE `hs_hr_weekends` SET length=8 WHERE day=7"), mysql_error());
$employeeId = '012';
$this->classLeaveRequest = null;
$this->classLeaveRequest = new LeaveRequests();
$this->classLeaveRequest->setEmployeeId($employeeId);
$this->classLeaveRequest->setLeaveTypeId("LTY010");
$this->classLeaveRequest->setLeaveFromDate(date('Y-m-d', time()+3600*24));
$this->classLeaveRequest->setLeaveToDate(date('Y-m-d', time()+3600*24*7));
$this->classLeaveRequest->setLeaveLengthHours($this->classLeaveRequest->lengthFullDay);
$this->classLeaveRequest->setLeaveStatus("1");
$this->classLeaveRequest->setLeaveComments("New Leave 1");
$this->classLeaveRequest->applyLeaveRequest();
$newId = $this->classLeaveRequest->getLeaveRequestId();
$leaveObj = $this->classLeaveRequest;
$res = $leaveObj->retriveLeaveRequestsEmployee($employeeId);
$this->assertNotNull($res, 'Record not found');
$this->assertSame(1, count($res), 'Wrong number of records found');
$expected[0] = array($newId, 'Medical', date('Y-m-d', time()+3600*24), date('Y-m-d', time()+3600*24*7), '48.00', '6.00');
for ($i=0; $i<count($res); $i++) {
$this->assertSame($expected[$i][0], $res[$i]->getLeaveRequestId(), 'Wrong Leave Request Id');
$this->assertSame($expected[$i][1], $res[$i]->getLeaveTypeName(), 'Wrong Leave Type Name');
$this->assertSame($expected[$i][2], $res[$i]->getLeaveFromDate(), 'Wrong From Date');
$this->assertSame($expected[$i][3], $res[$i]->getLeaveToDate(), "Wrong To Date");
$this->assertSame($expected[$i][4], $res[$i]->getLeaveLengthHours(), "Wrong length(hours) {$expected[$i][4]} {$res[$i]->getLeaveLengthHours()}");
$this->assertSame($expected[$i][5], $res[$i]->getNoDays(), "Wrong length(days)");
}
}
public function testApplyLeave4() {
// Mark Saturday and Sunday as weekend
$this->assertTrue(mysql_query("UPDATE `hs_hr_weekends` SET length=8 WHERE day=7 OR day=6"), mysql_error());
$employeeId = '012';
$this->classLeaveRequest = null;
$this->classLeaveRequest = new LeaveRequests();
$this->classLeaveRequest->setEmployeeId($employeeId);
$this->classLeaveRequest->setLeaveTypeId("LTY010");
$this->classLeaveRequest->setLeaveFromDate(date('Y-m-d', time()+3600*24));
$this->classLeaveRequest->setLeaveToDate(date('Y-m-d', time()+3600*24*7));
$this->classLeaveRequest->setLeaveLengthHours($this->classLeaveRequest->lengthFullDay);
$this->classLeaveRequest->setLeaveStatus("1");
$this->classLeaveRequest->setLeaveComments("New Leave 1");
$this->classLeaveRequest->applyLeaveRequest();
$newId = $this->classLeaveRequest->getLeaveRequestId();
$leaveObj = $this->classLeaveRequest;
$res = $leaveObj->retriveLeaveRequestsEmployee($employeeId);
$this->assertNotNull($res, 'Record not found');
$this->assertSame(1, count($res), 'Wrong number of records found');
$expected[0] = array($newId, 'Medical', date('Y-m-d', time()+3600*24), date('Y-m-d', time()+3600*24*7), '40.00', '5.00');
for ($i=0; $i<count($res); $i++) {
$this->assertSame($expected[$i][0], $res[$i]->getLeaveRequestId(), 'Wrong Leave Request Id');
$this->assertSame($expected[$i][1], $res[$i]->getLeaveTypeName(), 'Wrong Leave Type Name');
$this->assertSame($expected[$i][2], $res[$i]->getLeaveFromDate(), 'Wrong From Date');
$this->assertSame($expected[$i][3], $res[$i]->getLeaveToDate(), 'Wrong To Date');
$this->assertSame($expected[$i][4], $res[$i]->getLeaveLengthHours(), "Wrong length(hours) {$expected[$i][4]} {$res[$i]->getLeaveLengthHours()}");
$this->assertSame($expected[$i][5], $res[$i]->getNoDays(), "Wrong length(days)");
}
}
public function testApplyLeave5() {
// Mark Saturday as half day
$this->assertTrue(mysql_query("UPDATE `hs_hr_weekends` SET length=4 WHERE day=6"), mysql_error());
// Mark Sunday as weekend
$this->assertTrue(mysql_query("UPDATE `hs_hr_weekends` SET length=8 WHERE day=7"), mysql_error());
$employeeId = '012';
$this->classLeaveRequest = null;
$this->classLeaveRequest = new LeaveRequests();
$this->classLeaveRequest->setEmployeeId($employeeId);
$this->classLeaveRequest->setLeaveTypeId("LTY010");
$this->classLeaveRequest->setLeaveFromDate(date('Y-m-d', time()+3600*24));
$this->classLeaveRequest->setLeaveToDate(date('Y-m-d', time()+3600*24*7));
$this->classLeaveRequest->setLeaveLengthHours($this->classLeaveRequest->lengthFullDay);
$this->classLeaveRequest->setLeaveStatus("1");
$this->classLeaveRequest->setLeaveComments("New Leave 1");
$this->classLeaveRequest->applyLeaveRequest();
$newId = $this->classLeaveRequest->getLeaveRequestId();
$leaveObj = $this->classLeaveRequest;
$res = $leaveObj->retriveLeaveRequestsEmployee($employeeId);
$this->assertNotNull($res, 'Record not found');
$this->assertSame(1, count($res), 'Wrong number of records found');
$expected[0] = array($newId, 'Medical', date('Y-m-d', time()+3600*24), date('Y-m-d', time()+3600*24*7), '44.00', '5.50');
for ($i=0; $i<count($res); $i++) {
$this->assertSame($expected[$i][0], $res[$i]->getLeaveRequestId(), 'Wrong Leave Request Id');
$this->assertSame($expected[$i][1], $res[$i]->getLeaveTypeName(), 'Wrong Leave Type Name');
$this->assertSame($expected[$i][2], $res[$i]->getLeaveFromDate(), 'Wrong From Date');
$this->assertSame($expected[$i][3], $res[$i]->getLeaveToDate(), 'Wrong To Date');
$this->assertSame($expected[$i][4], $res[$i]->getLeaveLengthHours(), "Wrong length(hours) {$expected[$i][4]} {$res[$i]->getLeaveLengthHours()}");
$this->assertSame($expected[$i][5], $res[$i]->getNoDays(), "Wrong length(days)");
}
}
}
// Call LeaveRequestTest::main() if this source file is executed directly.
if (PHPUnit_MAIN_METHOD == "LeaveRequestsTest::main") {
LeaveRequestsTest::main();
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -