Пример #1
0
 public function testSetGetName()
 {
     $this->object->setName('city');
     $this->assertEquals('city', $this->object->getName());
     $this->object->setName('City');
     $this->assertEquals('City', $this->object->getName());
 }
Пример #2
0
 public function testShouldUpdateCurrentLocation()
 {
     $currentLocation = null;
     $latitude = -23.48033;
     $longitude = -46.63459;
     $city = new City();
     $city->setName("São Paulo");
     $city->setState("SP");
     $address = new Address();
     $address->setCity($city);
     $address->setStreet("Rua Funchal");
     $address->setDistrict("Vila Olímpia");
     $api = $this->getMock("ApontadorApi", array("revgeocode"));
     $api->expects($this->once())->method("revgeocode")->with($latitude, $longitude)->will($this->returnValue($address));
     $locationController = new LocationController();
     $locationController->setApi($api);
     $locationController->disableSession();
     $locationController->update($latitude, $longitude);
     $current = $locationController->current();
     $currentLocation = new Location($current['location']);
     $this->assertNotNull($currentLocation);
     $this->assertSame("SP", $currentLocation->getAddress()->getCity()->getState());
     $this->assertSame("São Paulo", $currentLocation->getAddress()->getCity()->getName());
     $this->assertSame("Vila Olímpia", $currentLocation->getAddress()->getDistrict());
     $this->assertSame("Rua Funchal", $currentLocation->getAddress()->getStreet());
     $this->assertSame($latitude, $currentLocation->getPoint()->getLat());
     $this->assertSame($longitude, $currentLocation->getPoint()->getLng());
 }
Пример #3
0
 public function load()
 {
     $this->populate(unserialize(Session::read('location')));
     $lat = $this->point->getLat();
     $lng = $this->point->getLng();
     if (empty($lat) || empty($lng)) {
         $city = new City();
         $city->setName("São Paulo");
         $city->setState("SP");
         $this->point->setLat(-23.48033);
         $this->point->setLng(-46.63459);
         $this->address->setCity($city);
     }
 }