public function testGetAccessibleEmployees()
 {
     $mockService = $this->getMock('EmployeeService');
     $employeeList = new Doctrine_Collection('Employee');
     for ($i = 0; $i < 2; $i++) {
         $employee = new Employee();
         $employee->setEmployeeId($i + 1);
         $employee->setEmpNumber($i + 1);
         $employee->setFirstName("test name" . $i + 1);
         $employeeList->add($employee);
     }
     $mockService->expects($this->once())->method('getSubordinateList')->with(1, true)->will($this->returnValue($employeeList));
     $this->supervisorUserRole->setEmployeeNumber(1);
     $this->supervisorUserRole->setEmployeeService($mockService);
     $employees = $this->supervisorUserRole->getAccessibleEmployees();
     $this->assertEquals(2, count($employees));
     for ($i = 0; $i < 2; $i++) {
         $this->assertEquals($employees[$i + 1], $employeeList[$i]);
     }
 }
 /**
  * @covers CorporateDirectoryWebServiceHelper::getCorporateDirectoryEmployeeDetailsAsArray
  */
 public function testGetCorporateDirectoryEmployeeDetailsAsArrayWithLoationsAndSubunits()
 {
     $location = new Location();
     $location->setId(1);
     $locationCollection = new Doctrine_Collection('Location');
     $locationCollection->add($location);
     $employee = new Employee();
     $employee->setEmpNumber(1);
     $employee->setFirstName('testEmpFirstName');
     $employee->setLastName('testEmpLastName');
     $employee->setLocations($locationCollection);
     $count = 1;
     $employees = array($employee);
     $employeeDirectoryServiceMock = $this->getMock('EmployeeDirectoryService');
     $employeeDirectoryServiceMock->expects($this->once())->method('searchEmployees')->will($this->returnValue($employees));
     $employeeDirectoryServiceMock->expects($this->once())->method('getSearchEmployeeCount')->will($this->returnValue($count));
     $this->corporateDirectoryWebServiceHelper->setEmployeeDirectoryService($employeeDirectoryServiceMock);
     $employeeDetails = $this->corporateDirectoryWebServiceHelper->getCorporateDirectoryEmployeeDetailsAsArray();
     $this->assertEquals(1, count($employeeDetails));
     $this->assertNotNull($employeeDetails[0]['location_id']);
     $this->assertEquals(1, $employeeDetails[0]['location_id']);
 }
 public function getEmployeeListForAttendanceTotalSummaryReport()
 {
     $employeeList = $this->getEmployeeService()->getEmployeeList('empNumber', 'ASC', true);
     $employee = new Employee();
     $employee->setEmpNumber('-1');
     $employee->setFirstName("All");
     if ($employeeList[0]->getEmpNumber() == null) {
         $employeeList->add($employee);
         return $employeeList;
     } else {
         $employeeList->add($employee);
         return $employeeList;
     }
 }
示例#4
0
 /**
  * Get employee list after sorting and filtering using given parameters.
  *
  * @param EmployeeSearchParameterHolder $parameterHolder
  */
 public function searchEmployees(EmployeeSearchParameterHolder $parameterHolder)
 {
     $sortField = $parameterHolder->getOrderField();
     $sortOrder = $parameterHolder->getOrderBy();
     $offset = $parameterHolder->getOffset();
     $limit = $parameterHolder->getLimit();
     $filters = $parameterHolder->getFilters();
     $returnType = $parameterHolder->getReturnType();
     $select = '';
     $query = '';
     $bindParams = array();
     $orderBy = '';
     $this->_getEmployeeListQuery($select, $query, $bindParams, $orderBy, $sortField, $sortOrder, $filters);
     $completeQuery = $select . ' ' . $query . ' ' . $orderBy;
     if (!is_null($offset) && !is_null($limit)) {
         $completeQuery .= ' LIMIT ' . $offset . ', ' . $limit;
     }
     if (sfConfig::get('sf_logging_enabled')) {
         $msg = $completeQuery;
         if (count($bindParams) > 0) {
             $msg .= ' (' . implode(',', $bindParams) . ')';
         }
         sfContext::getInstance()->getLogger()->info($msg);
     }
     $conn = Doctrine_Manager::connection();
     $statement = $conn->prepare($completeQuery);
     $result = $statement->execute($bindParams);
     if ($returnType == EmployeeSearchParameterHolder::RETURN_TYPE_OBJECT) {
         $employees = new Doctrine_Collection(Doctrine::getTable('Employee'));
         if ($result) {
             while ($row = $statement->fetch()) {
                 $employee = new Employee();
                 $employee->setEmpNumber($row['empNumber']);
                 $employee->setEmployeeId($row['employeeId']);
                 $employee->setFirstName($row['firstName']);
                 $employee->setMiddleName($row['middleName']);
                 $employee->setLastName($row['lastName']);
                 $employee->setTerminationId($row['terminationId']);
                 $jobTitle = new JobTitle();
                 $jobTitle->setId($row['jobTitleId']);
                 $jobTitle->setJobTitleName($row['jobTitle']);
                 $jobTitle->setIsDeleted($row['isDeleted']);
                 $employee->setJobTitle($jobTitle);
                 $employeeStatus = new EmploymentStatus();
                 $employeeStatus->setId($row['employeeStatusId']);
                 $employeeStatus->setName($row['employeeStatus']);
                 $employee->setEmployeeStatus($employeeStatus);
                 $workStation = new SubUnit();
                 $workStation->setName($row['subDivision']);
                 $workStation->setId($row['subDivisionId']);
                 $employee->setSubDivision($workStation);
                 $supervisorList = isset($row['supervisors']) ? $row['supervisors'] : '';
                 if (!empty($supervisorList)) {
                     $supervisors = new Doctrine_Collection(Doctrine::getTable('Employee'));
                     $supervisorArray = explode(',', $supervisorList);
                     foreach ($supervisorArray as $supervisor) {
                         list($first, $middle, $last) = explode('##', $supervisor);
                         $supervisor = new Employee();
                         $supervisor->setFirstName($first);
                         $supervisor->setMiddleName($middle);
                         $supervisor->setLastName($last);
                         $employee->supervisors[] = $supervisor;
                     }
                 }
                 $locationList = $row['locationIds'];
                 if (!empty($locationList)) {
                     //                    $locations = new Doctrine_Collection(Doctrine::getTable('EmpLocations'));
                     $locationArray = explode(',', $locationList);
                     foreach ($locationArray as $location) {
                         list($id, $name) = explode('##', $location);
                         $empLocation = new Location();
                         $empLocation->setId($id);
                         $empLocation->setName($name);
                         $employee->locations[] = $empLocation;
                     }
                 }
                 $employees[] = $employee;
             }
         }
     } else {
         return $statement->fetchAll();
     }
     return $employees;
 }
示例#5
0
 /**
  * Test getEmployeeYearsOfService 
  */
 public function testGetEmployeeYearsOfService()
 {
     $empNumber = 12;
     $joinedDate = '2001-02-01';
     $currentDate = '2010-03-04';
     $employee = new Employee();
     $employee->setLastName('Last Name');
     $employee->setFirstName('First Name');
     $employee->setEmpNumber($empNumber);
     $employee->setJoinedDate($joinedDate);
     $mockDao = $this->getMock('EmployeeDao');
     $mockDao->expects($this->once())->method('getEmployee')->with($empNumber)->will($this->returnValue($employee));
     $this->employeeService->setEmployeeDao($mockDao);
     $yearsOfService = $this->employeeService->getEmployeeYearsOfService($empNumber, $currentDate);
     //$this->assertEquals(9, $yearsOfService);
     // Test with non-existant employee
     $mockDao = $this->getMock('EmployeeDao');
     $mockDao->expects($this->once())->method('getEmployee')->with($empNumber)->will($this->returnValue(null));
     $this->employeeService->setEmployeeDao($mockDao);
     try {
         $yearsOfService = $this->employeeService->getEmployeeYearsOfService($empNumber, $currentDate);
         $this->fail("PIMServiceException expected");
     } catch (PIMServiceException $e) {
         // Expected
     }
 }
 public function testSearchLeaveRequestsEmployeeFilterMultipleEmployees()
 {
     $searchParameters = new ParameterStub();
     $dateRange = new DateRangeStub();
     $searchParameters->setParameter('dateRange', $dateRange);
     $searchParameters->setParameter('noOfRecordsPerPage', 50);
     $searchParameters->setParameter('cmbWithTerminated', 'on');
     $employee1 = new Employee();
     $employee1->setEmpNumber(1);
     $employee2 = new Employee();
     $employee2->setEmpNumber(2);
     $searchParameters->setParameter('employeeFilter', array($employee1, $employee2));
     $searchResult = $this->leaveRequestDao->searchLeaveRequests($searchParameters, 1);
     $requestList = $searchResult['list'];
     $requestCount = $searchResult['meta']['record_count'];
     /* Checking type */
     foreach ($requestList as $request) {
         $this->assertTrue($request instanceof LeaveRequest);
     }
     /* Checking count */
     $this->assertEquals(14, count($requestList));
     $this->assertEquals(14, $requestCount);
     /* Checking values and order */
     $this->assertEquals(14, $requestList[0]->getId());
     $this->assertEquals(1, $requestList[0]->getLeaveTypeId());
     $this->assertEquals('2010-08-12', $requestList[0]->getDateApplied());
     $this->assertEquals(2, $requestList[0]->getEmpNumber());
     $this->assertEquals(9, $requestList[13]->getId());
     $this->assertEquals(3, $requestList[13]->getLeaveTypeId());
     $this->assertEquals('2010-06-08', $requestList[13]->getDateApplied());
     $this->assertEquals(1, $requestList[13]->getEmpNumber());
 }
 public function testGetCorporateDirectoryEmployeeDetailsAsArrayWithNullProfilePicture()
 {
     $employee = new Employee();
     $employee->setEmpNumber(1);
     $employee->setFirstName('testEmpFirstName');
     $employee->setLastName('testEmpLastName');
     $count = 1;
     $employees = array($employee);
     $employeeDirectoryServiceMock = $this->getMock('EmployeeDirectoryService');
     $employeeDirectoryServiceMock->expects($this->once())->method('searchEmployees')->will($this->returnValue($employees));
     $employeeDirectoryServiceMock->expects($this->once())->method('getSearchEmployeeCount')->will($this->returnValue($count));
     $employeeServiceMock = $this->getMock('EmployeeService');
     $employeeServiceMock->expects($this->once())->method('getEmployeePicture')->will($this->returnValue(null));
     $this->corporateDirectoryWebServiceHelper->setEmployeeDirectoryService($employeeDirectoryServiceMock);
     $this->corporateDirectoryWebServiceHelper->setEmployeeService($employeeServiceMock);
     $employeeDetails = $this->corporateDirectoryWebServiceHelper->getCorporateDirectoryEmployeeDetailsAsArray();
     $this->assertNull($employeeDetails[0]['profile_picture']);
 }