public function testFindByLocationUseCityWithCountry() { $countryId = CM_Db_Db::insert('cm_model_location_country', array('abbreviation' => 'DE', 'name' => 'Germany')); $country = new CM_Model_Location(CM_Model_Location::LEVEL_COUNTRY, $countryId); $cityId = CM_Db_Db::insert('cm_model_location_city', array('stateId' => null, 'countryId' => $countryId, 'name' => 'Berlin', 'lat' => 12.345678, 'lon' => 12.345678)); $city = new CM_Model_Location(CM_Model_Location::LEVEL_CITY, $cityId); $this->assertNull(CM_Model_Currency::findByLocation($city)); $currency = CM_Model_Currency::create('978', 'EUR'); $cache = CM_Cache_Local::getInstance(); $cacheKey = CM_CacheConst::Currency_CountryId . '_countryId:' . $country->getId(); $currency->setCountryMapping($country); $cache->delete($cacheKey); $this->assertEquals($currency, CM_Model_Currency::findByLocation($city)); }
/** * @return CM_Frontend_Environment * @throws CM_Exception_AuthRequired */ public function getEnvironment() { $request = $this->getRequest(); $location = $request->getLocation(); $viewer = $request->getViewer(); $currency = null; if (null === $currency && null !== $viewer) { $currency = $viewer->getCurrency(); } if (null === $currency && null !== $location) { $currency = CM_Model_Currency::findByLocation($location); } $clientDevice = new CM_Http_ClientDevice($request); return new CM_Frontend_Environment($this->getSite(), $viewer, $request->getLanguage(), $request->getTimeZone(), null, $location, $currency, $clientDevice); }
/** * @return CM_Frontend_Environment * @throws CM_Exception_AuthRequired */ public function getEnvironment() { $location = $this->getRequest()->getLocation(); $currency = null !== $location ? CM_Model_Currency::findByLocation($location) : null; return new CM_Frontend_Environment($this->getSite(), $this->getRequest()->getViewer(), $this->getRequest()->getLanguage(), null, null, $location, $currency); }