예제 #1
0
 public function testSearchDistance()
 {
     $country = CM_Model_Location::createCountry('Country', 'CR');
     $source = CM_Model_Location::createCity($country, 'Source', 0, 0);
     $locationMiddle = CM_Model_Location::createCity($country, 'City', 0, 10);
     $locationFar = CM_Model_Location::createCity($country, 'City', 0, 100);
     $locationClose = CM_Model_Location::createCity($country, 'City', 0, 0);
     $this->_recreateLocationIndex();
     $paging = new CM_Paging_Location_SearchText('City', CM_Model_Location::LEVEL_CITY, CM_Model_Location::LEVEL_CITY, $source);
     $expected = array($locationClose, $locationMiddle, $locationFar);
     $this->assertEquals($expected, $paging->getItems());
 }
예제 #2
0
 public function testCountryOnly()
 {
     $country = CM_Model_Location::createCountry('My country', 'MC');
     $partLabeler = function (CM_Model_Location $locationPart, CM_Model_Location $location) {
         return $locationPart->getName();
     };
     $flagLabeler = function (CM_Model_Location $locationPart, CM_Model_Location $location) {
         return null;
     };
     $expected = '<span class="function-location contains-flag">My country</span>';
     $this->_assertSame($expected, array('location' => $country, 'partLabeler' => $partLabeler, 'flagLabeler' => $flagLabeler));
 }
예제 #3
0
 public function testGetters()
 {
     $site = CM_Site_Abstract::factory();
     $user = CM_Model_User::createStatic();
     $language = CM_Model_Language::create('English', 'en', true);
     $timezone = new DateTimeZone('Europe/London');
     $debug = true;
     $location = CM_Model_Location::createCountry('United Kingdom', 'UK');
     $environment = new CM_Frontend_Environment($site, $user, $language, $timezone, $debug, $location);
     $this->assertSame($site, $environment->getSite());
     $this->assertSame($user, $environment->getViewer(true));
     $this->assertSame($language, $environment->getLanguage());
     $this->assertSame($language->getAbbreviation(), $environment->getLocale());
     $this->assertSame($timezone, $environment->getTimeZone());
     $this->assertSame($debug, $environment->isDebug());
     $this->assertSame($location, $environment->getLocation());
 }
예제 #4
0
파일: MaxMind.php 프로젝트: cargomedia/cm
 protected function _upgradeCountryList()
 {
     $this->_streamOutput->writeln('Updating countries database…');
     $count = $this->_count(array($this->_countryListRenamed, $this->_countryListAdded), 2);
     $item = 0;
     foreach ($this->_countryListRenamed as $countryCode => $countryNames) {
         $countryName = $countryNames['name'];
         CM_Db_Db::update('cm_model_location_country', array('name' => $countryName), array('abbreviation' => $countryCode));
         $this->_printProgressCounter(++$item, $count);
     }
     unset($this->_countryListRenamed);
     foreach ($this->_countryListAdded as $countryCode => $countryName) {
         $country = CM_Model_Location::createCountry($countryName, $countryCode);
         $countryId = $country->getId();
         $this->_countryIdList[$countryCode] = $countryId;
         $this->_printProgressCounter(++$item, $count);
     }
     unset($this->_countryListAdded);
 }
예제 #5
0
 public function testCreateZip()
 {
     $country = CM_Model_Location::createCountry('Example Country', 'EC');
     $state = CM_Model_Location::createState($country, 'Example State', 'ES');
     $city = CM_Model_Location::createCity($state, 'Example City', 50, 100);
     $zip = CM_Model_Location::createZip($city, '12333', 50, 100);
     $this->assertSame($country->getId(), $zip->getId(CM_Model_Location::LEVEL_COUNTRY));
     $this->assertSame($state->getId(), $zip->getId(CM_Model_Location::LEVEL_STATE));
     $this->assertSame($city->getId(), $zip->getId(CM_Model_Location::LEVEL_CITY));
     $this->assertSame('12333', $zip->getName());
     $this->assertSame(array('lat' => (double) 50, 'lon' => (double) 100), $zip->getCoordinates());
 }