public function testSanitizeNotificationSection()
 {
     $notifications = TestDataService::loadObjectList('BeaconNotification', $this->fixture, 'BeaconNotification');
     $notificationXML = new SimpleXMLElement($notifications[0]->getDefinition());
     $sanitizedBody = $this->beaconNotificationService->sanitizeNotificationSection($notificationXML->content->body . "");
     $this->assertTrue(substr_count($sanitizedBody, '<script>') == 0);
 }
 public function testGetAllCustomers()
 {
     $customerList = TestDataService::loadObjectList('Customer', $this->fixture, 'Customer');
     $customerDao = $this->getMock('CustomerDao');
     $customerDao->expects($this->once())->method('getAllCustomers')->with(false)->will($this->returnValue($customerList));
     $this->customerService->setCustomerDao($customerDao);
     $result = $this->customerService->getAllCustomers(false);
     $this->assertEquals($result, $customerList);
 }
 public function testGtJobCategoryById()
 {
     $jobCatList = TestDataService::loadObjectList('JobCategory', $this->fixture, 'JobCategory');
     $jobCatDao = $this->getMock('JobCategoryDao');
     $jobCatDao->expects($this->once())->method('getJobCategoryById')->with(1)->will($this->returnValue($jobCatList[0]));
     $this->jobCatService->setJobCategoryDao($jobCatDao);
     $result = $this->jobCatService->getJobCategoryById(1);
     $this->assertEquals($result, $jobCatList[0]);
 }
 public function testGetJobTitleById()
 {
     $jobTitleList = TestDataService::loadObjectList('JobTitle', $this->fixture, 'JobTitle');
     $jobTitleDao = $this->getMock('JobTitleDao');
     $jobTitleDao->expects($this->once())->method('getJobTitleById')->with(1)->will($this->returnValue($jobTitleList[0]));
     $this->JobTitleService->setJobTitleDao($jobTitleDao);
     $result = $this->JobTitleService->getJobTitleById(1);
     $this->assertEquals($jobTitleList[0], $result);
 }
 public function testUpdateWorkShift()
 {
     $workShiftList = TestDataService::loadObjectList('WorkShift', $this->fixture, 'WorkShift');
     $workShiftDao = $this->getMock('WorkShiftDao');
     $workShiftDao->expects($this->once())->method('updateWorkShift')->with($workShiftList[0])->will($this->returnValue(true));
     $this->workShiftService->setWorkShiftDao($workShiftDao);
     $result = $this->workShiftService->updateWorkShift($workShiftList[0]);
     $this->assertTrue($result);
 }
Beispiel #6
0
 /**
  * Testing getValue()
  */
 public function testGetValue()
 {
     // Test values in fixtures.yml
     $fixtureObjects = TestDataService::loadObjectList('Config', $this->fixture, 'Config');
     foreach ($fixtureObjects as $config) {
         $value = $this->configDao->getValue($config->key);
         $this->assertEquals($config->value, $value);
     }
 }
 public function testGetMembershipById()
 {
     $membershipList = TestDataService::loadObjectList('Membership', $this->fixture, 'Membership');
     $membershipDao = $this->getMock('MembershipDao');
     $membershipDao->expects($this->once())->method('getMembershipById')->with(1)->will($this->returnValue($membershipList[0]));
     $this->membershipService->setMembershipDao($membershipDao);
     $result = $this->membershipService->getMembershipById(1);
     $this->assertEquals($result, $membershipList[0]);
 }
 public function testGetNationalityById()
 {
     $nationalityList = TestDataService::loadObjectList('Nationality', $this->fixture, 'Nationality');
     $nationalityDao = $this->getMock('NationalityDao');
     $nationalityDao->expects($this->once())->method('getNationalityById')->with(1)->will($this->returnValue($nationalityList[0]));
     $this->nationalityService->setNationalityDao($nationalityDao);
     $result = $this->nationalityService->getNationalityById(1);
     $this->assertEquals($result, $nationalityList[0]);
 }
 public function testGetEmploymentStatusById()
 {
     $empStatusList = TestDataService::loadObjectList('EmploymentStatus', $this->fixture, 'EmploymentStatus');
     $empStatusDao = $this->getMock('EmploymentStatusDao');
     $empStatusDao->expects($this->once())->method('getEmploymentStatusById')->with(1)->will($this->returnValue($empStatusList[0]));
     $this->empStatService->setEmploymentStatusDao($empStatusDao);
     $result = $this->empStatService->getEmploymentStatusById(1);
     $this->assertEquals($result, $empStatusList[0]);
 }
 public function testAddSubunit()
 {
     $subunitList = TestDataService::loadObjectList('Subunit', $this->fixture, 'Subunit');
     $subunit = $subunitList[2];
     $parentSubunit = new Subunit();
     $parentSubunit->setName("New Department");
     $this->assertTrue($this->companyStructureDao->addSubunit($parentSubunit, $subunit));
     $this->assertNotNull($parentSubunit->getId());
 }
 public function testGetLocationList()
 {
     $locationList = TestDataService::loadObjectList('Location', $this->fixture, 'Location');
     $locationDao = $this->getMock('LocationDao');
     $locationDao->expects($this->once())->method('getLocationList')->will($this->returnValue($locationList));
     $this->locationService->setLocationDao($locationDao);
     $result = $this->locationService->getLocationList();
     $this->assertEquals($result, $locationList);
 }
 /**
  * @group orangehrmAttendancePlugin
  */
 public function testSavePunchAction()
 {
     $attendanceRecords = TestDataService::loadObjectList('AttendanceRecord', $this->fixture, 'AttendanceRecord');
     $attendanceRecord = $attendanceRecords[0];
     $attendanceDaoMock = $this->getMock('AttendanceDao', array('savePunchRecord'));
     $attendanceDaoMock->expects($this->once())->method('savePunchRecord')->with($attendanceRecord)->will($this->returnValue($attendanceRecord));
     $this->attendanceService->setAttendanceDao($attendanceDaoMock);
     $this->assertTrue($this->attendanceService->savePunchRecord($attendanceRecord) instanceof AttendanceRecord);
 }
 public function testReadWorkWeek()
 {
     $workWeekList = TestDataService::loadObjectList('WorkWeek', $this->fixture, 'WorkWeek');
     $workWeekDao = $this->getMock('WorkWeekDao', array('readWorkWeek'));
     $workWeekDao->expects($this->once())->method('readWorkWeek')->with(1)->will($this->returnValue($workWeekList[0]));
     $this->workWeekService->setWorkWeekDao($workWeekDao);
     $readWorkWeek = $this->workWeekService->readWorkWeek(1);
     $this->assertTrue($readWorkWeek instanceof WorkWeek);
     $this->assertEquals($workWeekList[0], $readWorkWeek);
 }
 public function testReadLeaveType()
 {
     $leaveTypeList = TestDataService::loadObjectList('LeaveType', $this->fixture, 'set1');
     $leaveType = $leaveTypeList[0];
     $leaveTypeDao = $this->getMock('LeaveTypeDao', array('readLeaveType'));
     $leaveTypeDao->expects($this->once())->method('readLeaveType')->with('LTY001')->will($this->returnValue($leaveType));
     $this->leaveTypeService->setLeaveTypeDao($leaveTypeDao);
     $leaveType = $this->leaveTypeService->readLeaveType('LTY001');
     $this->assertTrue($leaveType instanceof LeaveType);
 }
Beispiel #15
0
 public function testGetAllValues()
 {
     $result = $this->configDao->getAllValues();
     // Test values in fixtures.yml
     $fixtureObjects = TestDataService::loadObjectList('Config', $this->fixture, 'Config');
     foreach ($fixtureObjects as $config) {
         $this->assertTrue(isset($result[$config->key]));
         $this->assertEquals($config->value, $result[$config->key]);
     }
     $this->assertEquals(count($fixtureObjects), count($result));
 }
 public function testResolveAllDatapoints()
 {
     $datapointList = TestDataService::loadObjectList('DataPoint', $this->fixture, 'set1');
     $beaconDatapointDao = $this->getMock('BeaconDatapointDao', array('getAllDatapoints'));
     $beaconDatapointDao->expects($this->once())->method('getAllDatapoints')->will($this->returnValue($datapointList));
     $this->beaconDatapointService->setBeaconDatapointDao($beaconDatapointDao);
     $results = $this->beaconDatapointService->resolveAllDatapoints();
     $this->assertEquals(count($datapointList), count($results));
     foreach ($datapointList as $datapoint) {
         $this->assertArrayHasKey($datapoint->getName(), $results);
     }
 }
 public function testGetLeaveTypeListByCountryId()
 {
     $entitlementList = TestDataService::loadObjectList('LeaveType', $this->fixture, 'LeaveType');
     $expected = array($entitlementList[3], $entitlementList[1]);
     $results = $this->dao->getLeaveTypeList(1);
     $this->_compareLeaveTypes($expected, $results);
     // country id without leave types
     $results = $this->dao->getLeaveTypeList(2);
     $this->assertEquals(0, count($results));
     // non-existing country id
     $results = $this->dao->getLeaveTypeList(12);
     $this->assertEquals(0, count($results));
 }
Beispiel #18
0
 public function testUpdateCandidateHistory()
 {
     $candidateVacancyList = TestDataService::loadObjectList('CandidateHistory', $this->fixture, 'CandidateHistory');
     $candidateVacancyList[1]->interviewers = '1_2_';
     $result = $this->candidateDao->updateCandidateHistory($candidateVacancyList[1]);
     $this->assertEquals($result, 1);
 }
 public function testReadEmployeeLeaveEntitlement()
 {
     $leaveEntitlements = TestDataService::loadObjectList('EmployeeLeaveEntitlement', $this->fixture, 'EmployeeLeaveEntitlement');
     $leaveEntitlementDao = $this->getMock('LeaveEntitlementDao', array('readEmployeeLeaveEntitlement'));
     $leaveEntitlementDao->expects($this->once())->method('readEmployeeLeaveEntitlement')->will($this->returnValue($leaveEntitlements[0]));
     $this->leaveEntitlementService->setLeaveEntitlementDao($leaveEntitlementDao);
     $readLeaveEntitlement = $this->leaveEntitlementService->readEmployeeLeaveEntitlement('0001', 1, 2);
     $this->assertTrue($readLeaveEntitlement instanceof EmployeeLeaveEntitlement);
     $this->assertEquals($leaveEntitlements[0]->getNoOfDaysAllotted(), $readLeaveEntitlement->getNoOfDaysAllotted());
     $this->assertEquals($leaveEntitlements[0]->getLeaveTaken(), $readLeaveEntitlement->getLeaveTaken());
     $this->assertEquals($leaveEntitlements[0], $readLeaveEntitlement);
 }
 public function testIsWithinNextLeavePeriod()
 {
     $leavePeriods = TestDataService::loadObjectList('LeavePeriod', $this->fixture, 'LeavePeriod');
     $leavePeriodDao = $this->getMock('LeavePeriodDao', array('filterByTimestamp'));
     $leavePeriodDao->expects($this->any())->method('filterByTimestamp')->will($this->returnValue($leavePeriods[1]));
     $timestamp = strtotime(date("Y") . "-05-11");
     $results = array(true, false);
     $this->leavePeriodService->setLeavePeriodDao($leavePeriodDao);
     $result = $this->leavePeriodService->isWithinNextLeavePeriod($timestamp);
     $this->assertTrue(in_array($result, $results));
 }
Beispiel #21
0
 public function testSearchHolidays()
 {
     $holidays = TestDataService::loadObjectList('Holiday', $this->fixture, 'Holiday');
     $holidayDao = $this->getMock('HolidayDao', array('searchHolidays'));
     $holidayDao->expects($this->once())->method('searchHolidays')->will($this->returnValue($holidays));
     $this->holidayService->setHolidayDao($holidayDao);
     $list = $this->holidayService->searchHolidays("2010-01-01", "2010-12-31");
     foreach ($list as $holiday) {
         $this->assertTrue($holiday instanceof Holiday);
     }
 }
 public function testGetEmployeesBySubUnit()
 {
     $employees = TestDataService::loadObjectList('Employee', $this->fixture, 'Employee');
     $subUnit = 2;
     $includeTerminatedEmployees = true;
     $mockDao = $this->getMock('EmployeeDao');
     $mockDao->expects($this->once())->method('getEmployeesBySubUnit')->with($subUnit, $includeTerminatedEmployees)->will($this->returnValue($employees));
     $this->employeeService->setEmployeeDao($mockDao);
     $result = $this->employeeService->getEmployeesBySubUnit($subUnit, $includeTerminatedEmployees);
     $this->assertEquals($employees, $result);
 }
 public function testIsHalfdayHolidayReturnsFalse()
 {
     $holidays = TestDataService::loadObjectList('Holiday', $this->fixture, 'Holiday');
     $holidayDao = $this->getMock('HolidayDao', array('readHolidayByDate'));
     $holidayDao->expects($this->once())->method('readHolidayByDate')->with("2010-05-28")->will($this->returnValue($holidays[1]));
     $this->holidayService->setHolidayDao($holidayDao);
     $this->assertFalse($this->holidayService->isHalfdayHoliday("2010-05-28"));
 }
 public function testGetMatchingEntitlements()
 {
     $leaveEntitlements = TestDataService::loadObjectList('LeaveEntitlement', $this->fixture, 'LeaveEntitlement');
     $leaveEntitlement = $leaveEntitlements[0];
     $empNumber = $leaveEntitlement->getEmpNumber();
     $leaveTypeId = $leaveEntitlement->getLeaveTypeId();
     $fromDate = $leaveEntitlement->getFromDate();
     $toDate = $leaveEntitlement->getToDate();
     $mockDao = $this->getMock('LeaveEntitlementDao', array('getMatchingEntitlements'));
     $mockDao->expects($this->once())->method('getMatchingEntitlements')->with($empNumber, $leaveTypeId, $fromDate, $toDate)->will($this->returnValue($leaveEntitlement));
     $this->service->setLeaveEntitlementDao($mockDao);
     $result = $this->service->getMatchingEntitlements($empNumber, $leaveTypeId, $fromDate, $toDate);
     $this->assertEquals($leaveEntitlement, $result);
 }
Beispiel #25
0
 /**
  * Testing getPublishedVacancies()
  */
 public function testGetPublishedVacancies()
 {
     // Get Published, active objects from fixture
     $allVacancyList = TestDataService::loadObjectList('JobVacancy', $this->fixture, 'JobVacancy');
     $publishedActiveList = array();
     foreach ($allVacancyList as $vacancy) {
         if ($vacancy->getStatus() == JobVacancy::ACTIVE && $vacancy->getPublishedInFeed() == JobVacancy::PUBLISHED) {
             $publishedActiveList[] = $vacancy;
         }
     }
     // Get Vacancy list and compare with fixture
     $vacancyList = $this->vacancyDao->getPublishedVacancies();
     $this->assertEquals(count($vacancyList), count($publishedActiveList));
     foreach ($vacancyList as $vacancy) {
         $this->assertEquals(JobVacancy::ACTIVE, $vacancy->getStatus());
         $this->assertTrue($vacancy->getPublishedInFeed());
     }
 }
 public function testGetEmployeeIdList()
 {
     $employeeIdList = $this->employeeDao->getEmployeeIdList();
     $this->assertEquals(5, count($employeeIdList));
     $employeeIdList = $this->employeeDao->getEmployeeIdList();
     $employees = TestDataService::loadObjectList('Employee', $this->fixture, 'Employee');
     $employeeIdArray = $this->getEmployeeIds($employees);
     $this->compareArrays($employeeIdArray, $employeeIdList);
 }
 public function testGetActionableStatesUserRoleWithNoWorkflowAccess()
 {
     $users = TestDataService::loadObjectList('SystemUser', $this->fixture, 'SystemUser');
     $ess = $users[1];
     $this->manager->setUser($ess);
     $workflow = 3;
     $actions = array('1', '2', '3');
     $expected = array('ACTIVE', 'NOT EXIST');
     $states = $this->manager->getActionableStates($workflow, $actions);
     $this->assertTrue(is_array($states));
     $this->assertEquals(0, count($states));
 }
 public function testGetWorkFlowStateMachineRecordsService()
 {
     $workflowStateMachineRecords = TestDataService::loadObjectList('WorkflowStateMachine', $this->fixture, 'WorkflowStateMachine');
     $workflowStateMachineRecord = $workflowStateMachineRecords[12];
     $accessFlowStateMachineDaoMock = $this->getMock('AccessFlowStateMachineDao');
     $accessFlowStateMachineDaoMock->expects($this->once())->method('getWorkFlowStateMachineRecords')->with(PluginWorkflowStateMachine::FLOW_EMPLOYEE)->will($this->returnValue($workflowStateMachineRecord));
     $this->accessFlowStateMachineService->setAccessFlowStateMachineDao($accessFlowStateMachineDaoMock);
     $this->assertTrue($this->accessFlowStateMachineService->getWorkFlowStateMachineRecords(PluginWorkflowStateMachine::FLOW_EMPLOYEE, null) instanceof WorkflowStateMachine);
 }
 public function testGetTimesheetByStartDate()
 {
     $startDate = "2011-04-18";
     $timesheets = TestDataService::loadObjectList('Timesheet', $this->fixture, 'Timesheet');
     $temp = $timesheets[0];
     $timesheetDaoMock = $this->getMock('TimesheetDao', array('getTimesheetByStartDate'));
     $timesheetDaoMock->expects($this->once())->method('getTimesheetByStartDate')->with($startDate)->will($this->returnValue($temp));
     $this->timesheetService->setTimesheetDao($timesheetDaoMock);
     $gotTimesheet = $this->timesheetService->getTimesheetByStartDate($startDate);
     $this->assertTrue($gotTimesheet instanceof Timesheet);
     //$this->assertEquals( 1 , count($gotTimesheet));
     $this->assertEquals("2011-04-18", $gotTimesheet->getStartDate());
 }
 public function testUpdateCandidateVacancy()
 {
     $candidatesVacancy = TestDataService::loadObjectList('JobCandidateVacancy', $this->fixture, 'JobCandidateVacancy');
     $candidateVacancy = $candidatesVacancy[0];
     $userObj = new User();
     $candidateService = $this->getMock('CandidateService', array('getNextStateForCandidateVacancy'));
     $candidateService->expects($this->any())->method('getNextStateForCandidateVacancy')->with('SHORTLISTED', 3, $userObj)->will($this->returnValue('REJECTED'));
     $candidateDao = $this->getMock('CandidateDao');
     $candidateDao->expects($this->once())->method('updateCandidateVacancy')->with($candidateVacancy)->will($this->returnValue(1));
     $candidateService->setCandidateDao($candidateDao);
     $return = $candidateService->updateCandidateVacancy($candidateVacancy, 3, $userObj);
     $this->assertEquals(1, $return);
 }