/** * Test the prePersist method of the GeographicalListener. */ public function testPrePersist() { $this->lifecycleArgs->expects($this->once())->method('getEntity')->will($this->returnValue($this->geographicalEntity)); $this->geographicalAnnotation->expects($this->once())->method('getLat')->will($this->returnValue('latitude')); $this->geographicalAnnotation->expects($this->once())->method('getLng')->will($this->returnValue('longitude')); $this->geographicalQueryAnnotation->expects($this->once())->method('getMethod')->will($this->returnValue('getAddress')); $this->queryService->expects($this->once())->method('queryForCoordinates')->with($this->anything())->will($this->returnValue($this->queryResult)); $this->queryResult->expects($this->once())->method('getLatitude')->will($this->returnValue(50)); $this->queryResult->expects($this->once())->method('getLongitude')->will($this->returnValue(-50)); $this->driver->expects($this->once())->method('getGeographicalAnnotation')->will($this->returnValue($this->geographicalAnnotation)); $this->driver->expects($this->once())->method('getGeographicalQueryAnnotation')->will($this->returnValue($this->geographicalQueryAnnotation)); $this->listener->prePersist($this->lifecycleArgs); $this->assertEquals(50, $this->geographicalEntity->getLatitude()); $this->assertEquals(-50, $this->geographicalEntity->getLongitude()); }
/** * Gets the mock listener. * * @param Vich\GeographicalBundle\Driver\AnnotationDriver $driver The driver * @param Vich\GeographicalBundle\QueryService\QueryServiceInterface $queryService The query service * @return Vich\GeographicalBundle\Listener\GeographicalListener The listener */ private function getListener(AnnotationDriver $driver, QueryServiceInterface $queryService) { $listener = new GeographicalListener($driver); $listener->setQueryService($queryService); return $listener; }