/**
  * Test the getGeographicalAnnotation method of the AnnotationDriver.
  */
 public function testGetGeographicalAnnotation()
 {
     $this->geographicalAnnotation->expects($this->once())->method('getLat')->will($this->returnValue('latitude'));
     $this->geographicalAnnotation->expects($this->once())->method('getLng')->will($this->returnValue('longitude'));
     $this->reader->expects($this->once())->method('getClassAnnotation')->with($this->isInstanceOf('\\ReflectionClass'), $this->equalTo('Vich\\GeographicalBundle\\Annotation\\Geographical'))->will($this->returnValue($this->geographicalAnnotation));
     $annot = $this->driver->getGeographicalAnnotation($this->geographicalEntity);
     $this->assertNotNull($annot);
     $this->assertEquals('latitude', $annot->getLat());
     $this->assertEquals('longitude', $annot->getLng());
 }
 /**
  * Update coordinates on objects being updated before update
  * if they require changing
  *
  * @param PreUpdateEventArgs $args The event arguments
  */
 public function preUpdate(PreUpdateEventArgs $args)
 {
     $obj = $args->getEntity();
     $geographical = $this->driver->getGeographicalAnnotation($obj);
     if ($geographical && $geographical->getOn() === Geographical::ON_UPDATE) {
         $geographicalQuery = $this->driver->getGeographicalQueryAnnotation($obj);
         if ($geographicalQuery) {
             $this->queryCoordinates($obj, $geographical, $geographicalQuery);
         }
     }
 }
 /**
  * Gets the latitude and longitude values of the object based on annotations.
  * 
  * @param type $obj The object
  * @return array An array
  */
 private function getLatLng($obj)
 {
     $annot = $this->driver->getGeographicalAnnotation($obj);
     if (!$annot) {
         throw new \InvalidArgumentException('Unable to find Geographical annotaion');
     }
     $latMethod = sprintf('get%s', $annot->getLat());
     $lngMethod = sprintf('get%s', $annot->getLng());
     $lat = $obj->{$latMethod}();
     $lng = $obj->{$lngMethod}();
     return array($lat, $lng);
 }