/** * {@inheritdoc} */ protected function setUp() { parent::setUp(); if (!GeometryEngineRegistry::has()) { $this->markTestSkipped('This test requires a connection to a database.'); } $engine = GeometryEngineRegistry::get(); if (!$engine instanceof PDOEngine) { $this->markTestSkipped('This test currently only works with a PDO connection.'); } $this->platform = $this->_conn->getDatabasePlatform(); $this->platform->registerDoctrineTypeMapping('geometry', 'binary'); $this->platform->registerDoctrineTypeMapping('linestring', 'binary'); $this->platform->registerDoctrineTypeMapping('multilinestring', 'binary'); $this->platform->registerDoctrineTypeMapping('multipoint', 'binary'); $this->platform->registerDoctrineTypeMapping('multipolygon', 'binary'); $this->platform->registerDoctrineTypeMapping('point', 'binary'); $this->platform->registerDoctrineTypeMapping('polygon', 'binary'); switch ($this->platform->getName()) { case 'postgresql': $this->_conn->executeQuery('CREATE EXTENSION IF NOT EXISTS postgis;'); break; } $this->fixtureLoader = new Loader(); $config = Setup::createAnnotationMetadataConfiguration([__DIR__ . '/Fixtures'], false); $config->addCustomNumericFunction('EarthDistance', EarthDistanceFunction::class); $this->em = EntityManager::create($this->_conn, $config, $this->platform->getEventManager()); $this->schemaTool = new SchemaTool($this->em); $this->schemaTool->updateSchema([$this->em->getClassMetadata(Fixtures\GeometryEntity::class), $this->em->getClassMetadata(Fixtures\LineStringEntity::class), $this->em->getClassMetadata(Fixtures\MultiLineStringEntity::class), $this->em->getClassMetadata(Fixtures\MultiPointEntity::class), $this->em->getClassMetadata(Fixtures\MultiPolygonEntity::class), $this->em->getClassMetadata(Fixtures\PointEntity::class), $this->em->getClassMetadata(Fixtures\PolygonEntity::class)]); $purger = new ORMPurger(); $this->ormExecutor = new ORMExecutor($this->em, $purger); }
/** * Marks the current test as requiring a geometry engine to be set. * * If no engine is set, the test will be skipped. * * @return void */ protected final function requiresGeometryEngine() { if (!GeometryEngineRegistry::has()) { $this->markTestSkipped('This test requires a geometry engine to be set.'); } }