/** * @group orangehrmAttendancePlugin */ public function testSavePunchRecordForExistingPunchRecord() { $attendanceRecord = TestDataService::fetchObject('AttendanceRecord', 1); $attendanceRecord->setState("PUNCHED IN"); $saveRecord = $this->attendanceDao->savePunchRecord($attendanceRecord); $this->assertEquals($saveRecord->getState(), 'PUNCHED IN'); $this->assertEquals($saveRecord->getPunchInTimeOffset(), 'Asia/Calcutta'); }
public function testDeleteSubunit() { $subunitList = TestDataService::loadObjectList('Subunit', $this->fixture, 'Subunit'); $subunit = $subunitList[2]; $this->assertTrue($this->companyStructureDao->deleteSubunit($subunit)); $result = TestDataService::fetchObject('Subunit', 3); $this->assertFalse($result); }
public function testEditLanguage() { $language = TestDataService::fetchObject('Language', 3); $language->setName('Canadian French'); $this->languageDao->saveLanguage($language); $savedLanguage = TestDataService::fetchLastInsertedRecord('Language', 'id'); $this->assertTrue($savedLanguage instanceof Language); $this->assertEquals('Canadian French', $savedLanguage->getName()); }
public function testEditTerminationReason() { $terminationReason = TestDataService::fetchObject('TerminationReason', 3); $terminationReason->setName('2011 Layed off'); $this->terminationReasonDao->saveTerminationReason($terminationReason); $savedTerminationReason = TestDataService::fetchLastInsertedRecord('TerminationReason', 'id'); $this->assertTrue($savedTerminationReason instanceof TerminationReason); $this->assertEquals('2011 Layed off', $savedTerminationReason->getName()); }
public function testEditLicense() { $license = TestDataService::fetchObject('License', 3); $license->setName('Moon Pilot'); $this->licenseDao->saveLicense($license); $savedLicense = TestDataService::fetchLastInsertedRecord('License', 'id'); $this->assertTrue($savedLicense instanceof License); $this->assertEquals('Moon Pilot', $savedLicense->getName()); }
public function testEditReportingMethod() { $reportingMethod = TestDataService::fetchObject('ReportingMethod', 3); $reportingMethod->setName('Finance HR'); $this->reportingMethodDao->saveReportingMethod($reportingMethod); $savedReportingMethod = TestDataService::fetchLastInsertedRecord('ReportingMethod', 'id'); $this->assertTrue($savedReportingMethod instanceof ReportingMethod); $this->assertEquals('Finance HR', $savedReportingMethod->getName()); }
public function testEditEducation() { $education = TestDataService::fetchObject('Education', 3); $education->setName('MSc New'); $this->educationDao->saveEducation($education); $savedEducation = TestDataService::fetchLastInsertedRecord('Education', 'id'); $this->assertTrue($savedEducation instanceof Education); $this->assertEquals('MSc New', $savedEducation->getName()); }
public function testEditSkill() { $skill = TestDataService::fetchObject('Skill', 3); $skill->setDescription('Ability to help disabled people'); $this->skillDao->saveSkill($skill); $savedSkill = TestDataService::fetchLastInsertedRecord('Skill', 'id'); $this->assertTrue($savedSkill instanceof Skill); $this->assertEquals('Sign Language', $savedSkill->getName()); $this->assertEquals('Ability to help disabled people', $savedSkill->getDescription()); }
public function testUpdateModuleStatusWithNoChange() { $moduleList = array('leave', 'time'); $status = Module::ENABLED; $result = $this->moduleDao->updateModuleStatus($moduleList, $status); $this->assertEquals(0, $result); $module = TestDataService::fetchObject('Module', 3); $this->assertEquals(Module::ENABLED, $module->getStatus()); $module = TestDataService::fetchObject('Module', 4); $this->assertEquals(Module::ENABLED, $module->getStatus()); }
public function testDeleteSubunit() { $subunit = TestDataService::fetchObject('Subunit', 1); $parentSubunit = new Subunit(); $parentSubunit->setName("new subunit"); $compStructureDao = $this->getMock('CompanyStructureDao'); $compStructureDao->expects($this->once())->method('deleteSubunit')->with($subunit)->will($this->returnValue(true)); $this->companyStructureService->setCompanyStructureDao($compStructureDao); $result = $this->companyStructureService->deleteSubunit($subunit); $this->assertTrue($result); }
public function testDeleteCustomFields() { $result = $this->customFieldConfigurationDao->deleteCustomFields(array(1, 3)); $this->assertEquals(2, $result); /*Checking whether the correct fields were deleted*/ $result = TestDataService::fetchObject('CustomField', 1); $this->assertTrue(empty($result)); $result = TestDataService::fetchObject('CustomField', 3); $this->assertTrue(empty($result)); $result = TestDataService::fetchObject('CustomField', 2); $this->assertTrue($result instanceof CustomField); }
public function testGetActionableStates() { $actions = array("APPROVE", "REJECT"); $workFlow = "Time"; $userRole = "ADMIN"; $fetchedRecord1 = TestDataService::fetchObject('WorkflowStateMachine', 1); $fetchedRecord2 = TestDataService::fetchObject('WorkflowStateMachine', 5); $tempArray = array($fetchedRecord1, $fetchedRecord2); $acessFlowStateMachineDaoMock = $this->getMock('AccessFlowStateMachineDao', array('getActionableStates')); $acessFlowStateMachineDaoMock->expects($this->once())->method('getActionableStates')->with($workFlow, $userRole, $actions)->will($this->returnValue($tempArray)); $this->accessFlowStateMachineService->setAccessFlowStateMachineDao($acessFlowStateMachineDaoMock); $record = $this->accessFlowStateMachineService->getActionableStates($workFlow, $userRole, $actions); $this->assertEquals(2, count($record)); $this->assertEquals($fetchedRecord1->getState(), $record[0]); $this->assertEquals($fetchedRecord2->getState(), $record[1]); }
public function testSaveLeavePeriodException() { $leavePeriod = TestDataService::fetchObject('LeavePeriod', 1); $leavePeriod->setStartDate("2008-01-31"); $leavePeriod->setEndDate("2009-01-31"); $leavePeriod->setLeavePeriodId("california"); try { $this->leavePeriodDao->saveLeavePeriod($leavePeriod); } catch (Exception $e) { $this->assertTrue($e instanceof DaoException); } }
public function testCheckForMatchingTimesheetForCurrentDate() { $employeeId = 6; $currentDate = "2011-02-24"; $timesheetId = 9; $timesheet = TestDataService::fetchObject('Timesheet', $timesheetId); $timehseetDaoMock = $this->getMock('TimesheetDao', array('checkForMatchingTimesheetForCurrentDate')); $timehseetDaoMock->expects($this->once())->method('checkForMatchingTimesheetForCurrentDate')->with($employeeId, $currentDate)->will($this->returnValue($timesheet)); $this->timesheetService->setTimesheetDao($timehseetDaoMock); $testTimesheet = $this->timesheetService->checkForMatchingTimesheetForCurrentDate($employeeId, $currentDate); $this->assertTrue($testTimesheet instanceof Timesheet); $this->assertEquals($timesheet, $testTimesheet); }
public function testUndeleteLeaveTypeValues() { $this->assertTrue($this->leaveTypeDao->undeleteLeaveType('LTY003')); $undeletedTypeObject = TestDataService::fetchObject('LeaveType', 'LTY003'); $this->assertEquals('LTY003', $undeletedTypeObject->getLeaveTypeId()); $this->assertEquals(1, $undeletedTypeObject->getAvailableFlag()); }
public function testDeleteHoliday() { $this->assertTrue($this->holidayDao->deleteHoliday(array(1, 2))); $holiday = TestDataService::fetchObject('Holiday', 2); $this->assertFalse($holiday instanceof Holiday); }
/** * Test for getEmployeeTaxExemptions returns Object */ public function testGetEmployeeTaxExemptions() { $empTaxExemption = TestDataService::fetchObject('EmpUsTaxExemption', 1); $taxObject = $this->employeeDao->getEmployeeTaxExemptions($empTaxExemption->getEmpNumber()); $this->assertTrue($taxObject instanceof EmpUsTaxExemption); }
public function xtestModifyOverlapLeaveRequest() { /* Preparing required data */ $leaveRequest = new LeaveRequest(); $leaveRequest->setLeavePeriodId(1); $leaveRequest->setLeaveTypeId('LTY001'); $leaveRequest->setLeaveTypeName('Casual'); $leaveRequest->setDateApplied('2010-12-01'); $leaveRequest->setEmpNumber(1); $leave[0] = new Leave(); $leave[0]->setLeaveLengthHours(8); $leave[0]->setLeaveLengthDays(1); $leave[0]->setLeaveDate('2010-12-30'); $leave[0]->setLeaveStatus(1); $leave[1] = new Leave(); $leave[1]->setLeaveLengthHours(8); $leave[1]->setLeaveLengthDays(1); $leave[1]->setLeaveDate('2010-12-31'); $leave[1]->setLeaveStatus(1); $leave[2] = new Leave(); $leave[2]->setLeaveLengthHours(8); $leave[2]->setLeaveLengthDays(1); $leave[2]->setLeaveDate('2011-01-01'); $leave[2]->setLeaveStatus(1); $leave[3] = new Leave(); $leave[3]->setLeaveLengthHours(8); $leave[3]->setLeaveLengthDays(1); $leave[3]->setLeaveDate('2011-01-02'); $leave[3]->setLeaveStatus(1); $leavePeriod = TestDataService::fetchObject('LeavePeriod', 1); /* Executing tests */ /* At use, modifyOverlapLeaveRequest() is called after calling * saveLeaveRequest() */ $leaveRequest = $this->leaveRequestDao->saveLeaveRequest($leaveRequest, $leave); $this->assertTrue($leaveRequest instanceof LeaveRequest); $this->assertTrue($this->leaveRequestDao->modifyOverlapLeaveRequest($leaveRequest, $leave, $leavePeriod)); $leaveRequestList = TestDataService::fetchLastInsertedRecords('LeaveRequest', 2); $this->assertEquals(21, $leaveRequestList[0]->getLeaveRequestId()); $this->assertEquals('LTY001', $leaveRequestList[0]->getLeaveTypeId()); $this->assertEquals('Casual', $leaveRequestList[0]->getLeaveTypeName()); $this->assertEquals('2010-12-01', $leaveRequestList[0]->getDateApplied()); $this->assertEquals(1, $leaveRequestList[0]->getEmpNumber()); $this->assertEquals(22, $leaveRequestList[1]->getLeaveRequestId()); $this->assertEquals('LTY001', $leaveRequestList[1]->getLeaveTypeId()); $this->assertEquals('Casual', $leaveRequestList[1]->getLeaveTypeName()); $this->assertEquals('2010-12-01', $leaveRequestList[1]->getDateApplied()); $this->assertEquals(1, $leaveRequestList[1]->getEmpNumber()); $leaveList = TestDataService::fetchLastInsertedRecords('Leave', 4); $this->assertEquals(36, $leaveList[0]->getId()); $this->assertEquals(8, $leaveList[0]->getLengthHours()); $this->assertEquals(1, $leaveList[0]->getLengthDays()); $this->assertEquals(21, $leaveList[0]->getLeaveRequestId()); $this->assertEquals('LTY001', $leaveList[0]->getLeaveTypeId()); $this->assertEquals(1, $leaveList[0]->getEmpNumber()); $this->assertEquals('2010-12-30', $leaveList[0]->getDate()); $this->assertEquals(1, $leaveList[0]->getStatus()); $this->assertEquals(37, $leaveList[1]->getId()); $this->assertEquals(8, $leaveList[1]->getLengthHours()); $this->assertEquals(1, $leaveList[1]->getLengthDays()); $this->assertEquals(21, $leaveList[1]->getLeaveRequestId()); $this->assertEquals('LTY001', $leaveList[1]->getLeaveTypeId()); $this->assertEquals(1, $leaveList[1]->getEmpNumber()); $this->assertEquals('2010-12-31', $leaveList[1]->getDate()); $this->assertEquals(1, $leaveList[1]->getStatus()); $this->assertEquals(38, $leaveList[2]->getId()); $this->assertEquals(8, $leaveList[2]->getLengthHours()); $this->assertEquals(1, $leaveList[2]->getLengthDays()); $this->assertEquals(22, $leaveList[2]->getLeaveRequestId()); $this->assertEquals('LTY001', $leaveList[2]->getLeaveTypeId()); $this->assertEquals(1, $leaveList[2]->getEmpNumber()); $this->assertEquals('2011-01-01', $leaveList[2]->getDate()); $this->assertEquals(1, $leaveList[2]->getStatus()); $this->assertEquals(39, $leaveList[3]->getId()); $this->assertEquals(8, $leaveList[3]->getLengthHours()); $this->assertEquals(1, $leaveList[3]->getLengthDays()); $this->assertEquals(22, $leaveList[3]->getLeaveRequestId()); $this->assertEquals('LTY001', $leaveList[3]->getLeaveTypeId()); $this->assertEquals(1, $leaveList[3]->getEmpNumber()); $this->assertEquals('2011-01-02', $leaveList[3]->getDate()); $this->assertEquals(1, $leaveList[3]->getStatus()); }
public function testGetSubordinatePropertyListBySupervisorId() { $properties = array('empNumber', 'firstName', 'lastName', 'middleName', 'employeeId'); $emplyee1 = TestDataService::fetchObject('Employee', 1); $emplyee2 = TestDataService::fetchObject('Employee', 2); $employees = array($emplyee1, $emplyee2); $subordinatePropertyArray = array(); foreach ($employees as $employee) { $subordinatePropertyArray[$employee['empNumber']] = array('empNumber' => $employee['empNumber'], 'firstName' => $employee['firstName'], 'lastName' => $employee['lastName'], 'middleName' => $employee['middleName'], 'employeeId' => $employee['employeeId']); } $configServiceMock = $this->getMock('ConfigService'); $configServiceMock->expects($this->once())->method('isSupervisorChainSuported')->will($this->returnValue(true)); $mockDao = $this->getMock('EmployeeDao'); $mockDao->expects($this->once())->method('getSubordinatePropertyListBySupervisorId')->with(3, $properties, true, 'empNumber', 'ASC')->will($this->returnValue($subordinatePropertyArray)); $this->employeeService->setEmployeeDao($mockDao); $this->employeeService->setConfigurationService($configServiceMock); $result = $this->employeeService->getSubordinatePropertyListBySupervisorId(3, $properties, 'empNumber', 'ASC', true); $this->compareArrays($subordinatePropertyArray, $result); }
/** * */ public function testSaveCandidateAttachment() { $file = tmpfile(); fwrite($file, "writing to tempfile"); fseek($file, 0); $resume = new JobCandidateAttachment(); $resume->id = 5; $resume->candidateId = 1; $resume->fileName = "abc.txt"; $resume->fileType = ".txt"; $resume->fileSize = '512'; $this->recruitmentAttachmentDao->saveCandidateAttachment($resume); $resume = TestDataService::fetchObject('JobCandidateAttachment', 5); $this->assertNotNull($resume->getId()); $this->assertEquals($resume->getFileName(), "abc.txt"); $this->assertEquals($resume->getFileType(), ".txt"); $this->assertEquals($resume->getFileSize(), '512'); }
public function testSearchVacancies() { $srchParams = array('jobTitle' => 'JOB002', 'jobVacancy' => '2', 'hiringManager' => '2', 'status' => '1'); $vacancyList = TestDataService::fetchObject('JobVacancy', 2); $vacancyDao = $this->getMock('VacancyDao'); $vacancyDao->expects($this->once())->method('searchVacancies')->with($srchParams)->will($this->returnValue($vacancyList)); $this->vacancyService->setVacancyDao($vacancyDao); $result = $this->vacancyService->searchVacancies($srchParams); $this->assertEquals($result, $vacancyList); }
public function testUndeleteLeaveTypeValues() { $this->assertTrue($this->dao->undeleteLeaveType(3)); $undeletedTypeObject = TestDataService::fetchObject('LeaveType', 3); $this->assertEquals(3, $undeletedTypeObject->getId()); $this->assertEquals(0, $undeletedTypeObject->getDeleted()); }
/** * Testing searchVacancies */ public function testSearchVacanciesWithEmployeeFirstName() { $srchParams = array('jobTitle' => 2, 'jobVacancy' => 2, 'hiringManager' => 2, 'status' => 1, 'offset' => 0, 'noOfRecords' => 1, 'orderField' => 'e.emp_firstname'); $vacancyList = TestDataService::fetchObject('JobVacancy', 2); $result = $this->vacancyDao->searchVacancies($srchParams); $this->assertEquals($vacancyList, $result[0]); }
public function testSaveEmployeeLeaveEntitlementCollection() { $leaveEntitilementFixture = sfConfig::get('sf_plugins_dir') . '/orangehrmCoreLeavePlugin/test/fixtures/leaveEntitlement.yml'; TestDataService::populate($leaveEntitilementFixture); $leaveEntitlementList = array(); $employeeLeaveEntitlement = new EmployeeLeaveEntitlement(); $employeeLeaveEntitlement->setLeaveTypeId('LTY002'); $employeeLeaveEntitlement->setEmployeeId(2); $employeeLeaveEntitlement->setLeavePeriodId(1); $employeeLeaveEntitlement->setNoOfDaysAllotted(40); $leaveEntitlementList[] = $employeeLeaveEntitlement; $employeeLeaveEntitlement = TestDataService::fetchObject('EmployeeLeaveEntitlement', array('LTY001', 1, 1)); //$employeeLeaveEntitlement = $this->leaveEntitlementDao->getEmployeeLeaveEntitlement(1, 'LTY001', 1); $employeeLeaveEntitlement->setNoOfDaysAllotted(50); $leaveEntitlementList[] = $employeeLeaveEntitlement; $results = $this->leaveEntitlementDao->saveEmployeeLeaveEntitlementCollection($leaveEntitlementList); $employeeLeaveEntitlement = TestDataService::fetchObject('EmployeeLeaveEntitlement', array('LTY001', 1, 1)); //$employeeLeaveEntitlement = $this->leaveEntitlementDao->getEmployeeLeaveEntitlement(1, 'LTY001', 1); $this->assertEquals(50.0, $employeeLeaveEntitlement->getNoOfDaysAllotted()); $employeeLeaveEntitlement = TestDataService::fetchObject('EmployeeLeaveEntitlement', array('LTY002', 2, 1)); //$employeeLeaveEntitlement = $this->leaveEntitlementDao->getEmployeeLeaveEntitlement(2, 'LTY002', 1); $this->assertEquals(40.0, $employeeLeaveEntitlement->getNoOfDaysAllotted()); }
public function testGenerateWhereClauseConditionArrayForPredefinedFilterFields() { $selectedFilterFieldList = new Doctrine_Collection("SelectedFilterField"); $values = null; $selectedFilterFieldList->add(TestDataService::fetchObject('SelectedFilterField', array(3, 4))); $selectedFilterFieldList->add(TestDataService::fetchObject('SelectedFilterField', array(3, 5))); $selectedFilterFieldList->add(TestDataService::fetchObject('SelectedFilterField', array(3, 6))); $selectedFilterFieldList->add(TestDataService::fetchObject('SelectedFilterField', array(3, 7))); $conditionArray = $this->reportGeneratorService->generateWhereClauseConditionArray($selectedFilterFieldList, $values); $this->assertEquals(2, count($conditionArray)); $this->assertEquals("ohrm_project.project_id = 'nus' AND hs_hr_employee.city_code = 'C123'", $conditionArray[2]); }
/** * Testing saveTimesheetActionLog mthod */ public function testSaveTimesheetActionLog() { $timesheetActionLog = TestDataService::fetchObject("TimesheetActionLog", 2); $this->assertEquals("REJECTED", $timesheetActionLog->getComment()); $timesheetActionLog->setComment("ACCEPTED"); $timesheetActionLog->setAction("REJECTED"); $this->timesheetDao->saveTimesheetActionLog($timesheetActionLog); $savedTimesheetActionLog = TestDataService::fetchObject("TimesheetActionLog", $timesheetActionLog->getTimesheetActionLogId()); $this->assertEquals($timesheetActionLog->getAction(), $savedTimesheetActionLog->getAction()); $this->assertEquals($timesheetActionLog->getComment(), $savedTimesheetActionLog->getComment()); $this->assertEquals($timesheetActionLog->getDateTime(), $savedTimesheetActionLog->getDateTime()); $this->assertEquals($timesheetActionLog->getPerformedBy(), $savedTimesheetActionLog->getPerformedBy()); }
/** * @group ReportingChain */ public function testGetSubordinatePropertyListBySupervisorId() { $properties = array(); $subordinatePropertyList = $this->employeeDao->getSubordinatePropertyListBySupervisorId(3, $properties, true, 'empNumber', 'ASC'); $this->assertEquals(2, count($subordinatePropertyList)); $properties = array('empNumber', 'firstName', 'lastName', 'middleName', 'employeeId'); $subordinatePropertyList = $this->employeeDao->getSubordinatePropertyListBySupervisorId(3, $properties, true, 'empNumber', 'ASC'); $this->assertEquals(2, count($subordinatePropertyList)); $properties = array('empNumber', 'firstName', 'lastName', 'middleName', 'employeeId'); $subordinatePropertyList = $this->employeeDao->getSubordinatePropertyListBySupervisorId(10, $properties, true, 'empNumber', 'ASC'); $this->assertEquals(0, count($subordinatePropertyList)); $properties = array('empNumber', 'firstName', 'lastName', 'middleName', 'employeeId'); $subordinatePropertyList = $this->employeeDao->getSubordinatePropertyListBySupervisorId(3, $properties, true, 'empNumber', 'ASC'); foreach ($subordinatePropertyList as $subbordinateProperties) { $this->assertEquals(6, count($subbordinateProperties)); } $properties = array('empNumber', 'firstName', 'lastName', 'middleName', 'employeeId'); $subordinatePropertyList = $this->employeeDao->getSubordinatePropertyListBySupervisorId(3, $properties, true, 'empNumber', 'ASC'); $employee = TestDataService::fetchObject('Employee', 1); $this->assertEquals($employee->getFirstName(), $subordinatePropertyList[1]['firstName']); $propertyArray = array(); $propertyArray['empNumber'] = $employee->getEmpNumber(); $propertyArray['firstName'] = $employee->getFirstName(); $propertyArray['lastName'] = $employee->getLastName(); $propertyArray['middleName'] = $employee->getMiddleName(); $propertyArray['employeeId'] = $employee->getEmployeeId(); $propertyArray['ReportTo'] = array(); $this->compareArrays($propertyArray, $subordinatePropertyList[1]); }
public function testDeleteWorkWeek() { $this->assertTrue($this->workWeekDao->deleteWorkWeek(2)); $this->assertFalse(TestDataService::fetchObject('WorkWeek', 2) instanceof WorkWeek); }
/** * */ public function testSaveCandidateVacancy() { TestDataService::truncateSpecificTables(array('JobCandidateVacancy')); $candidateVacancy = new JobCandidateVacancy(); $candidateVacancy->candidateId = 1; $candidateVacancy->vacancyId = 2; $candidateVacancy->status = 0; $candidateVacancy->appliedDate = '2011-07-08'; $this->candidateDao->saveCandidateVacancy($candidateVacancy); $candidateVacancy = TestDataService::fetchObject('JobCandidateVacancy', array(1, 2)); $this->assertEquals($candidateVacancy->getStatus(), 0); $this->assertEquals($candidateVacancy->getAppliedDate(), '2011-07-08'); }
protected function _verifyDeletedFlags($deleted) { $ids = array(1, 2, 3, 4, 5); $nonDeleted = array_diff($ids, $deleted); // verify deleted foreach ($deleted as $id) { echo $i; $entitlement = TestDataService::fetchObject('LeaveEntitlement', $id); $this->assertEquals(1, $entitlement->getDeleted(), 'id=' . $id); } // verify non deleted foreach ($nonDeleted as $id) { $entitlement = TestDataService::fetchObject('LeaveEntitlement', $id); $this->assertEquals(0, $entitlement->getDeleted(), 'id=' . $id); } }