/** * @group geometry */ public function testTypeWrappingSelect() { $lineString = new LineString(array(new Point(0, 0), new Point(10, 0), new Point(10, 10), new Point(0, 10), new Point(0, 0))); $entity = new PolygonEntity(); $entity->setPolygon(new Polygon(array($lineString))); $this->getEntityManager()->persist($entity); $this->getEntityManager()->flush(); $this->getEntityManager()->clear(); $dql = 'SELECT p, %s(p.polygon, :geometry) FROM CrEOF\\Spatial\\Tests\\Fixtures\\PolygonEntity p'; switch ($this->getPlatform()->getName()) { case 'postgresql': $function = 'ST_Contains'; break; case 'mysql': $function = 'Contains'; break; default: throw UnsupportedPlatformException::unsupportedPlatform($this->getPlatform()->getName()); } $dql = sprintf($dql, $function); $query = $this->getEntityManager()->createQuery($dql); $query->setParameter('geometry', new Point(2, 2), 'point'); $query->processParameterValue('geometry'); $result = $query->getSQL(); $parameter = '?'; if (Version::compare('2.5') <= 0) { $parameter = Type::getType('point')->convertToDatabaseValueSQL($parameter, $this->getPlatform()); } $regex = preg_quote(sprintf('/.polygon, %s)/', $parameter)); $this->assertRegExp($regex, $result); }
/** * @param AbstractPlatform $platform * * @throws UnsupportedPlatformException */ protected function validatePlatform(AbstractPlatform $platform) { $platformName = $platform->getName(); if (isset($this->platforms) && !in_array($platformName, $this->platforms)) { throw UnsupportedPlatformException::unsupportedPlatform($platformName); } }
/** * @throws UnsupportedPlatformException */ protected function tearDown() { parent::tearDown(); $this->_sqlLoggerStack->enabled = false; $this->tearDownCommonEntities(); switch ($this->platformName) { case 'postgresql': $this->tearDownPostgreSql(); break; case 'mysql': break; default: throw UnsupportedPlatformException::unsupportedPlatform($this->platformName); break; } $this->_em->clear(); }
/** * @param AbstractPlatform $platform * * @return string * @throws UnsupportedPlatformException */ private function getPlatformName(AbstractPlatform $platform) { $name = __CLASS__ . '::PLATFORM_' . strtoupper($platform->getName()); if (!defined($name)) { throw UnsupportedPlatformException::unsupportedPlatform($name); } return constant($name); }
/** * @return Connection * @throws UnsupportedPlatformException * @throws \Doctrine\DBAL\DBALException */ protected static function getConnection() { if (isset(static::$connection)) { return static::$connection; } $connection = DriverManager::getConnection(static::getConnectionParameters()); switch ($connection->getDatabasePlatform()->getName()) { case 'postgresql': $connection->exec('CREATE EXTENSION postgis'); break; case 'mysql': break; default: throw UnsupportedPlatformException::unsupportedPlatform($connection->getDatabasePlatform()->getName()); } return $connection; }