示例#1
0
 /**
  * Testing getDependents
  */
 public function testGetDependents()
 {
     $empNumber = 111;
     $dependents = array();
     $dependent = new EmpDependent();
     $dependent->setEmpNumber(111);
     $dependent->setSeqno(1);
     $dependent->setName('Anthony Perera');
     $dependent->setRelationshipType('child');
     $dependents[0] = $dependent;
     $dependent = new EmpDependent();
     $dependent->setEmpNumber(111);
     $dependent->setSeqno(2);
     $dependent->setName('Anton Perera');
     $dependent->setRelationshipType('child');
     $dependents[1] = $dependent;
     $mockDao = $this->getMock('EmployeeDao');
     $mockDao->expects($this->once())->method('getDependents')->with($empNumber)->will($this->returnValue($dependents));
     $this->employeeService->setEmployeeDao($mockDao);
     $result = $this->employeeService->getDependents($empNumber);
     $this->assertEquals($dependents, $result);
     $mockDao = $this->getMock('EmployeeDao');
     $mockDao->expects($this->once())->method('getDependents')->with($empNumber)->will($this->throwException(new DaoException()));
     $this->employeeService->setEmployeeDao($mockDao);
     try {
         $result = $this->employeeService->getDependents($empNumber);
         $this->fail("Exception expected");
     } catch (Exception $e) {
         $this->assertTrue($e instanceof PIMServiceException);
     }
 }
 /**
  * Testing getDependents
  */
 public function testGetDependents()
 {
     $empNumber = 111;
     $dependents = array();
     $dependent = new EmpDependent();
     $dependent->setEmpNumber(111);
     $dependent->setSeqno(1);
     $dependent->setName('Anthony Perera');
     $dependent->setRelationshipType('child');
     $dependents[0] = $dependent;
     $dependent = new EmpDependent();
     $dependent->setEmpNumber(111);
     $dependent->setSeqno(2);
     $dependent->setName('Anton Perera');
     $dependent->setRelationshipType('child');
     $dependents[1] = $dependent;
     $mockDao = $this->getMock('EmployeeDao');
     $mockDao->expects($this->once())->method('getEmployeeDependents')->with($empNumber)->will($this->returnValue($dependents));
     $this->employeeService->setEmployeeDao($mockDao);
     $result = $this->employeeService->getEmployeeDependents($empNumber);
     $this->assertEquals($dependents, $result);
 }