/** * @covers CountryService::searchCountries * @expectedException ServiceException */ public function testSearchCountries_WithException() { $searchParams = array('sampleParam1' => 'sampleValue1', 'sampleParam2' => 'sampleValue2'); $countryDaoMock = $this->getMock('CountryDao', array('searchCountries')); $countryDaoMock->expects($this->once())->method('searchCountries')->will($this->throwException(new DaoException())); $this->service->setCountryDao($countryDaoMock); $this->service->searchCountries($searchParams); }
/** * @param $request * @return SS_HTTPRequest|SS_HTTPResponse */ public function countries($request) { $response = Controller::curr()->getResponse(); $service = new CountryService($request); $objects = $service->processRequest(); $responseData = array('objects' => $service->formatObjects($objects), 'count' => $objects->count()); $response = $response->setBody(json_encode($responseData)); return $response; }
/** * Update CompanyLocation * @return unknown_type */ public function executeUpdateCompanyLocation(sfWebRequest $request) { $companyService = new CompanyService(); $companyLocation = $companyService->readLocation($request->getParameter('id')); $this->companyLocation = $companyLocation; if ($request->isMethod('post')) { $companyLocation->setLocName($request->getParameter('txtName')); $companyLocation->setLocCountry($request->getParameter('cmbCountry')); $companyLocation->setLocState($request->getParameter('txtState')); $companyLocation->setLocCity($request->getParameter('txtCity')); $companyLocation->setLocAdd($request->getParameter('txtAddress')); $companyLocation->setLocZip($request->getParameter('txtZipCode')); $companyLocation->setLocPhone($request->getParameter('txtPhone')); $companyLocation->setLocFax($request->getParameter('txtFax')); $companyLocation->setLocComments($request->getParameter('txtComments')); $companyService = new CompanyService(); $companyService->saveCompanyLocation($companyLocation); $this->setMessage('SUCCESS', array(TopLevelMessages::UPDATE_SUCCESS)); $this->redirect('admin/listCompanylocation'); } $countryService = new CountryService(); $this->countryList = $countryService->getCountryList(); $this->provinceList = $countryService->getProvinceList(); }