/** * * @param OperationalCountry $country * @return Doctrine_Collection */ public function getLocationsMappedToOperationalCountry(OperationalCountry $country) { try { return $this->getOperationalCountryDao()->getLocationsMappedToOperationalCountry($country->getCountryCode()); } catch (Exception $e) { throw new ServiceException($e->getMessage()); } }
public function testGetAccessibleOperationalCountryIds() { $mockService = $this->getMock('OperationalCountryService'); $opCountryList = new Doctrine_Collection('OperationalCountry'); for ($i = 0; $i < 3; $i++) { $operationalCountry = new OperationalCountry(); $operationalCountry->setId($i + 1); $opCountryList->add($operationalCountry); } $mockService->expects($this->once())->method('getOperationalCountryList')->will($this->returnValue($opCountryList)); $this->adminUserRole->setOperationalCountryService($mockService); $opCountryIds = $this->adminUserRole->getAccessibleOperationalCountryIds(null, null); $this->assertEquals($opCountryIds, array(1, 2, 3)); }
public function testReadHolidayByDate() { $matchedHoliday = $this->holidayDao->readHolidayByDate('2010-05-27'); $this->assertTrue($matchedHoliday instanceof Holiday); $this->assertEquals(1, $matchedHoliday->getId()); $sriLanka = new OperationalCountry(); $sriLanka->setId(1); $sriLanka->setCountryCode('LK'); $matchedHoliday = $this->holidayDao->readHolidayByDate('2010-05-28', $sriLanka); $this->assertTrue($matchedHoliday instanceof Holiday); $this->assertEquals(2, $matchedHoliday->getId()); }
/** * @covers OperationalCountryService::getLocationsMappedToOperationalCountry */ public function testGetLocationsMappedToOperationalCountry_Success() { $locationList = array(); $locationList[] = new Location(); $locationList[] = new Location(); $locationList[] = new Location(); $sriLanka = new Country(); $sriLanka->setName('Sri Lanka'); $operationalCountry = new OperationalCountry(); $operationalCountry->setId(1); $operationalCountry->setCountry($sriLanka); $operationalCountry->setCountryCode('LK'); $operationalCountryDaoMock = $this->getMock('OperationalCountryDao', array('getLocationsMappedToOperationalCountry')); $operationalCountryDaoMock->expects($this->once())->method('getLocationsMappedToOperationalCountry')->will($this->returnValue($locationList)); $result = $this->service->setOperationalCountryDao($operationalCountryDaoMock); $result = $this->service->getLocationsMappedToOperationalCountry($operationalCountry); $this->assertEquals($locationList, $result); }