/** * {@inheritdoc} */ function load(ObjectManager $manager) { $point1 = new PointEntity(); $point1->setPoint(Point::xy(0, 0)); $manager->persist($point1); $manager->flush(); }
/** * @dataProvider providerEarthDistanceFunction * * @param string $pointA The WKT of the first point, with Lon/Lat coordinates. * @param string $pointB The WKT of the second point, with Lon/Lat coordinates. * @param float $expectedDistance The expected distance in meters. */ public function testEarthDistanceFunction($pointA, $pointB, $expectedDistance) { $pointA = Point::fromText($pointA, 4326); $pointB = Point::fromText($pointB, 4326); $em = $this->getEntityManager(); $em->beginTransaction(); $em->createQueryBuilder()->delete()->from(PointEntity::class, 'p')->getQuery()->execute(); $pointEntity = new PointEntity(); $pointEntity->setPoint($pointA); $em->persist($pointEntity); $em->flush($pointEntity); $actualDistance = $em->createQueryBuilder()->select('EarthDistance(p.point, :point)')->from(PointEntity::class, 'p')->setParameter('point', $pointB, 'point')->getQuery()->getSingleScalarResult(); $em->rollback(); $this->assertEquals($expectedDistance, $actualDistance, '', 100.0); }