From 744bf7b4c8876cc0ac69b7b4fe0bd8a24a29b67b Mon Sep 17 00:00:00 2001 From: Benjamin Morel Date: Tue, 17 Aug 2021 23:12:21 +0200 Subject: [PATCH] Remove Doctrine This will be moved to a separate package. --- composer.json | 3 - phpunit-bootstrap.php | 69 +-------- src/Doctrine/Functions/AbstractFunction.php | 63 -------- src/Doctrine/Functions/AreaFunction.php | 21 --- src/Doctrine/Functions/AzimuthFunction.php | 21 --- src/Doctrine/Functions/BoundaryFunction.php | 21 --- src/Doctrine/Functions/BufferFunction.php | 21 --- src/Doctrine/Functions/CentroidFunction.php | 21 --- src/Doctrine/Functions/ContainsFunction.php | 21 --- src/Doctrine/Functions/ConvexHullFunction.php | 21 --- src/Doctrine/Functions/CrossesFunction.php | 21 --- src/Doctrine/Functions/DifferenceFunction.php | 21 --- src/Doctrine/Functions/DisjointFunction.php | 21 --- src/Doctrine/Functions/DistanceFunction.php | 21 --- src/Doctrine/Functions/EnvelopeFunction.php | 21 --- src/Doctrine/Functions/EqualsFunction.php | 21 --- src/Doctrine/Functions/IntersectsFunction.php | 21 --- src/Doctrine/Functions/IsClosedFunction.php | 21 --- src/Doctrine/Functions/IsSimpleFunction.php | 21 --- src/Doctrine/Functions/IsValidFunction.php | 21 --- src/Doctrine/Functions/LengthFunction.php | 21 --- .../Functions/LocateAlongFunction.php | 21 --- .../Functions/LocateBetweenFunction.php | 21 --- .../Functions/MaxDistanceFunction.php | 21 --- src/Doctrine/Functions/OverlapsFunction.php | 21 --- .../Functions/PointOnSurfaceFunction.php | 21 --- src/Doctrine/Functions/RelateFunction.php | 21 --- src/Doctrine/Functions/SimplifyFunction.php | 21 --- src/Doctrine/Functions/SnapToGridFunction.php | 21 --- .../Functions/SymDifferenceFunction.php | 21 --- src/Doctrine/Functions/TouchesFunction.php | 21 --- src/Doctrine/Functions/UnionFunction.php | 21 --- src/Doctrine/Functions/WithinFunction.php | 21 --- src/Doctrine/Types/GeometryCollectionType.php | 23 --- src/Doctrine/Types/GeometryType.php | 135 ------------------ src/Doctrine/Types/LineStringType.php | 28 ---- src/Doctrine/Types/MultiLineStringType.php | 28 ---- src/Doctrine/Types/MultiPointType.php | 28 ---- src/Doctrine/Types/MultiPolygonType.php | 28 ---- src/Doctrine/Types/PointType.php | 28 ---- src/Doctrine/Types/PolygonType.php | 23 --- .../DataFixtures/LoadGeometryData.php | 23 --- .../DataFixtures/LoadLineStringData.php | 28 ---- .../DataFixtures/LoadMultiLineStringData.php | 35 ----- .../DataFixtures/LoadMultiPointData.php | 28 ---- .../DataFixtures/LoadMultiPolygonData.php | 44 ------ tests/Doctrine/DataFixtures/LoadPointData.php | 23 --- .../Doctrine/DataFixtures/LoadPolygonData.php | 33 ----- tests/Doctrine/Fixtures/GeometryEntity.php | 36 ----- tests/Doctrine/Fixtures/LineStringEntity.php | 36 ----- .../Fixtures/MultiLineStringEntity.php | 36 ----- tests/Doctrine/Fixtures/MultiPointEntity.php | 36 ----- .../Doctrine/Fixtures/MultiPolygonEntity.php | 36 ----- tests/Doctrine/Fixtures/PointEntity.php | 36 ----- tests/Doctrine/Fixtures/PolygonEntity.php | 36 ----- tests/Doctrine/FunctionalTestCase.php | 108 -------------- tests/Doctrine/Types/GeometryTypeTest.php | 41 ------ tests/Doctrine/Types/LineStringTypeTest.php | 40 ------ .../Types/MultiLineStringTypeTest.php | 55 ------- tests/Doctrine/Types/MultiPointTypeTest.php | 49 ------- tests/Doctrine/Types/MultiPolygonTypeTest.php | 68 --------- tests/Doctrine/Types/PointTypeTest.php | 34 ----- tests/Doctrine/Types/PolygonTypeTest.php | 47 ------ 63 files changed, 1 insertion(+), 1993 deletions(-) delete mode 100644 src/Doctrine/Functions/AbstractFunction.php delete mode 100644 src/Doctrine/Functions/AreaFunction.php delete mode 100644 src/Doctrine/Functions/AzimuthFunction.php delete mode 100644 src/Doctrine/Functions/BoundaryFunction.php delete mode 100644 src/Doctrine/Functions/BufferFunction.php delete mode 100644 src/Doctrine/Functions/CentroidFunction.php delete mode 100644 src/Doctrine/Functions/ContainsFunction.php delete mode 100644 src/Doctrine/Functions/ConvexHullFunction.php delete mode 100644 src/Doctrine/Functions/CrossesFunction.php delete mode 100644 src/Doctrine/Functions/DifferenceFunction.php delete mode 100644 src/Doctrine/Functions/DisjointFunction.php delete mode 100644 src/Doctrine/Functions/DistanceFunction.php delete mode 100644 src/Doctrine/Functions/EnvelopeFunction.php delete mode 100644 src/Doctrine/Functions/EqualsFunction.php delete mode 100644 src/Doctrine/Functions/IntersectsFunction.php delete mode 100644 src/Doctrine/Functions/IsClosedFunction.php delete mode 100644 src/Doctrine/Functions/IsSimpleFunction.php delete mode 100644 src/Doctrine/Functions/IsValidFunction.php delete mode 100644 src/Doctrine/Functions/LengthFunction.php delete mode 100644 src/Doctrine/Functions/LocateAlongFunction.php delete mode 100644 src/Doctrine/Functions/LocateBetweenFunction.php delete mode 100644 src/Doctrine/Functions/MaxDistanceFunction.php delete mode 100644 src/Doctrine/Functions/OverlapsFunction.php delete mode 100644 src/Doctrine/Functions/PointOnSurfaceFunction.php delete mode 100644 src/Doctrine/Functions/RelateFunction.php delete mode 100644 src/Doctrine/Functions/SimplifyFunction.php delete mode 100644 src/Doctrine/Functions/SnapToGridFunction.php delete mode 100644 src/Doctrine/Functions/SymDifferenceFunction.php delete mode 100644 src/Doctrine/Functions/TouchesFunction.php delete mode 100644 src/Doctrine/Functions/UnionFunction.php delete mode 100644 src/Doctrine/Functions/WithinFunction.php delete mode 100644 src/Doctrine/Types/GeometryCollectionType.php delete mode 100644 src/Doctrine/Types/GeometryType.php delete mode 100644 src/Doctrine/Types/LineStringType.php delete mode 100644 src/Doctrine/Types/MultiLineStringType.php delete mode 100644 src/Doctrine/Types/MultiPointType.php delete mode 100644 src/Doctrine/Types/MultiPolygonType.php delete mode 100644 src/Doctrine/Types/PointType.php delete mode 100644 src/Doctrine/Types/PolygonType.php delete mode 100644 tests/Doctrine/DataFixtures/LoadGeometryData.php delete mode 100644 tests/Doctrine/DataFixtures/LoadLineStringData.php delete mode 100644 tests/Doctrine/DataFixtures/LoadMultiLineStringData.php delete mode 100644 tests/Doctrine/DataFixtures/LoadMultiPointData.php delete mode 100644 tests/Doctrine/DataFixtures/LoadMultiPolygonData.php delete mode 100644 tests/Doctrine/DataFixtures/LoadPointData.php delete mode 100644 tests/Doctrine/DataFixtures/LoadPolygonData.php delete mode 100644 tests/Doctrine/Fixtures/GeometryEntity.php delete mode 100644 tests/Doctrine/Fixtures/LineStringEntity.php delete mode 100644 tests/Doctrine/Fixtures/MultiLineStringEntity.php delete mode 100644 tests/Doctrine/Fixtures/MultiPointEntity.php delete mode 100644 tests/Doctrine/Fixtures/MultiPolygonEntity.php delete mode 100644 tests/Doctrine/Fixtures/PointEntity.php delete mode 100644 tests/Doctrine/Fixtures/PolygonEntity.php delete mode 100644 tests/Doctrine/FunctionalTestCase.php delete mode 100644 tests/Doctrine/Types/GeometryTypeTest.php delete mode 100644 tests/Doctrine/Types/LineStringTypeTest.php delete mode 100644 tests/Doctrine/Types/MultiLineStringTypeTest.php delete mode 100644 tests/Doctrine/Types/MultiPointTypeTest.php delete mode 100644 tests/Doctrine/Types/MultiPolygonTypeTest.php delete mode 100644 tests/Doctrine/Types/PointTypeTest.php delete mode 100644 tests/Doctrine/Types/PolygonTypeTest.php diff --git a/composer.json b/composer.json index 39879c0..9a5a9b7 100644 --- a/composer.json +++ b/composer.json @@ -18,9 +18,6 @@ "ext-json": "*", "ext-sqlite3": "*", "brick/reflection": "~0.2.0 || ~0.3.0 || ~0.4.0", - "doctrine/orm": "^2.0", - "doctrine/data-fixtures": "^1.0", - "doctrine/cache": "^1.11", "phpunit/phpunit": "^8.0 || ^9.0", "php-coveralls/php-coveralls": "^2.0", "vimeo/psalm": "4.3.1" diff --git a/phpunit-bootstrap.php b/phpunit-bootstrap.php index 53bc15d..7c233f0 100644 --- a/phpunit-bootstrap.php +++ b/phpunit-bootstrap.php @@ -1,31 +1,12 @@ addPsr4('Doctrine\\Tests\\', [ - __DIR__ . '/vendor/doctrine/orm/tests/Doctrine/Tests', - __DIR__ . '/vendor/doctrine/dbal/tests/Doctrine/Tests' - ]); - $classLoader->loadClass('Doctrine\Tests\DbalFunctionalTestCase'); - $classLoader->loadClass('Doctrine\Tests\DBAL\Mocks\MockPlatform'); - - Type::addType('geometry', Types\GeometryType::class); - Type::addType('linestring', Types\LineStringType::class); - Type::addType('multilinestring', Types\MultiLineStringType::class); - Type::addType('multipoint', Types\MultiPointType::class); - Type::addType('multipolygon', Types\MultiPolygonType::class); - Type::addType('point', Types\PointType::class); - Type::addType('polygon', Types\PolygonType::class); + require 'vendor/autoload.php'; $engine = getenv('ENGINE'); @@ -57,30 +38,6 @@ echo 'MySQL version: ' . $version . PHP_EOL; - // Connect data for doctrine integration tests - $GLOBALS['db_type'] = 'pdo_mysql'; - $GLOBALS['db_host'] = '127.0.0.1'; - $GLOBALS['db_port'] = 3306; - $GLOBALS['db_username'] = 'root'; - $GLOBALS['db_password'] = ''; - $GLOBALS['db_name'] = 'geo_tests'; - - $GLOBALS['tmpdb_type'] = 'pdo_mysql'; - $GLOBALS['tmpdb_host'] = '127.0.0.1'; - $GLOBALS['tmpdb_port'] = 3306; - $GLOBALS['tmpdb_username'] = 'root'; - $GLOBALS['tmpdb_password'] = ''; - $GLOBALS['tmpdb_name'] = 'geo_tests_tmp'; - - // doctrine/dbal >= 2.13.0 - $GLOBALS['db_driver'] = 'pdo_mysql'; - $GLOBALS['db_user'] = 'root'; - $GLOBALS['db_dbname'] = 'geo_tests'; - - $GLOBALS['tmpdb_driver'] = 'pdo_mysql'; - $GLOBALS['tmpdb_user'] = 'root'; - $GLOBALS['tmpdb_dbname'] = 'geo_tests_tmp'; - $engine = new PDOEngine($pdo); break; @@ -106,30 +63,6 @@ echo 'PostGIS version: ' . $version . PHP_EOL; - // Connect data for doctrine integration tests - $GLOBALS['db_type'] = 'pdo_pgsql'; - $GLOBALS['db_host'] = 'localhost'; - $GLOBALS['db_port'] = 5432; - $GLOBALS['db_username'] = 'postgres'; - $GLOBALS['db_password'] = 'postgres'; - $GLOBALS['db_name'] = 'geo_tests'; - - $GLOBALS['tmpdb_type'] = 'pdo_pgsql'; - $GLOBALS['tmpdb_host'] = 'localhost'; - $GLOBALS['tmpdb_port'] = 5432; - $GLOBALS['tmpdb_username'] = 'postgres'; - $GLOBALS['tmpdb_password'] = 'postgres'; - $GLOBALS['tmpdb_name'] = 'geo_tests_tmp'; - - // doctrine/dbal >= 2.13.0 - $GLOBALS['db_driver'] = 'pdo_pgsql'; - $GLOBALS['db_user'] = 'postgres'; - $GLOBALS['db_dbname'] = 'geo_tests'; - - $GLOBALS['tmpdb_driver'] = 'pdo_pgsql'; - $GLOBALS['tmpdb_user'] = 'postgres'; - $GLOBALS['tmpdb_dbname'] = 'geo_tests_tmp'; - $engine = new PDOEngine($pdo); break; diff --git a/src/Doctrine/Functions/AbstractFunction.php b/src/Doctrine/Functions/AbstractFunction.php deleted file mode 100644 index 1fee6e1..0000000 --- a/src/Doctrine/Functions/AbstractFunction.php +++ /dev/null @@ -1,63 +0,0 @@ -getSqlFunctionName() . '('; - - foreach ($this->args as $key => $arg) { - if ($key !== 0) { - $sql .= ', '; - } - - $sql .= $arg->dispatch($sqlWalker); - } - - $sql .= ')'; - - return $sql; - } - - public function parse(Parser $parser) : void - { - $this->args = []; - - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); - - $parameterCount = $this->getParameterCount(); - - for ($i = 0; $i < $parameterCount; $i++) { - if ($i !== 0) { - $parser->match(Lexer::T_COMMA); - } - - /** @psalm-suppress InvalidPropertyAssignmentValue */ - $this->args[] = $parser->ArithmeticPrimary(); - } - - $parser->match(Lexer::T_CLOSE_PARENTHESIS); - } -} diff --git a/src/Doctrine/Functions/AreaFunction.php b/src/Doctrine/Functions/AreaFunction.php deleted file mode 100644 index 1778981..0000000 --- a/src/Doctrine/Functions/AreaFunction.php +++ /dev/null @@ -1,21 +0,0 @@ - - */ - protected function getProxyClassName() : string - { - return GeometryProxy::class; - } - - /** - * Returns whether the associated geometry class has known (non-proxy) subclasses. - * If true, the WKB has to be introspected before the correct proxy class can be instantiated. - */ - protected function hasKnownSubclasses() : bool - { - return true; - } - - public function getName() - { - return 'Geometry'; - } - - public function getSQLDeclaration(array $column, AbstractPlatform $platform) - { - if ($platform instanceof PostgreSqlPlatform) { - return 'GEOMETRY'; - } - - return strtoupper($this->getName()); - } - - public function convertToPHPValue($value, AbstractPlatform $platform) - { - /** @var string|resource|null $value */ - if ($value === null) { - return null; - } - - if (is_resource($value)) { - $value = stream_get_contents($value); - } - - if ($this->hasKnownSubclasses()) { - // Introspect the WKB to get the correct proxy class - if ($this->wkbReader === null) { - $this->wkbReader = new WKBReader(); - } - - return $this->wkbReader->readAsProxy($value, self::$srid); - } - - $proxyClassName = $this->getProxyClassName(); - - return new $proxyClassName($value, true, self::$srid); - } - - public function convertToDatabaseValue($value, AbstractPlatform $platform) - { - if ($value === null) { - return null; - } - - if ($value instanceof Geometry) { - return $value->asBinary(); - } - - $type = is_object($value) ? get_class($value) : gettype($value); - - throw new \UnexpectedValueException(sprintf('Expected %s, got %s.', Geometry::class, $type)); - } - - public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform) - { - if ($platform instanceof MySqlPlatform) { - $sqlExpr = sprintf('BINARY %s', $sqlExpr); - } - - return sprintf('ST_GeomFromWKB(%s, %d)', $sqlExpr, self::$srid); - } - - public function convertToPHPValueSQL($sqlExpr, $platform) - { - return sprintf('ST_AsBinary(%s)', $sqlExpr); - } - - public function canRequireSQLConversion() - { - return true; - } - - public function requiresSQLCommentHint(AbstractPlatform $platform) - { - return true; - } - - public function getBindingType() - { - return \PDO::PARAM_LOB; - } -} diff --git a/src/Doctrine/Types/LineStringType.php b/src/Doctrine/Types/LineStringType.php deleted file mode 100644 index 483769e..0000000 --- a/src/Doctrine/Types/LineStringType.php +++ /dev/null @@ -1,28 +0,0 @@ -setGeometry(Point::xy(1, 2)); - - $manager->persist($point1); - $manager->flush(); - } -} diff --git a/tests/Doctrine/DataFixtures/LoadLineStringData.php b/tests/Doctrine/DataFixtures/LoadLineStringData.php deleted file mode 100644 index 772b0a4..0000000 --- a/tests/Doctrine/DataFixtures/LoadLineStringData.php +++ /dev/null @@ -1,28 +0,0 @@ -setLineString(LineString::of($point1, $point2, $point3)); - - $manager->persist($lineString1); - $manager->flush(); - } -} diff --git a/tests/Doctrine/DataFixtures/LoadMultiLineStringData.php b/tests/Doctrine/DataFixtures/LoadMultiLineStringData.php deleted file mode 100644 index 7a2e341..0000000 --- a/tests/Doctrine/DataFixtures/LoadMultiLineStringData.php +++ /dev/null @@ -1,35 +0,0 @@ -setMultiLineString(MultiLineString::of($lineString1, $lineString2)); - - $manager->persist($multilineString1); - $manager->flush(); - } -} diff --git a/tests/Doctrine/DataFixtures/LoadMultiPointData.php b/tests/Doctrine/DataFixtures/LoadMultiPointData.php deleted file mode 100644 index f24092f..0000000 --- a/tests/Doctrine/DataFixtures/LoadMultiPointData.php +++ /dev/null @@ -1,28 +0,0 @@ -setMultiPoint(MultiPoint::of($point1, $point2, $point3)); - - $manager->persist($multiPoint1); - $manager->flush(); - } -} diff --git a/tests/Doctrine/DataFixtures/LoadMultiPolygonData.php b/tests/Doctrine/DataFixtures/LoadMultiPolygonData.php deleted file mode 100644 index 69b4e76..0000000 --- a/tests/Doctrine/DataFixtures/LoadMultiPolygonData.php +++ /dev/null @@ -1,44 +0,0 @@ -setMultiPolygon(MultiPolygon::of($poly1, $poly2)); - - $manager->persist($multiPoly1); - $manager->flush(); - } -} diff --git a/tests/Doctrine/DataFixtures/LoadPointData.php b/tests/Doctrine/DataFixtures/LoadPointData.php deleted file mode 100644 index 69cf8ad..0000000 --- a/tests/Doctrine/DataFixtures/LoadPointData.php +++ /dev/null @@ -1,23 +0,0 @@ -setPoint(Point::xy(0, 0)); - - $manager->persist($point1); - $manager->flush(); - } -} diff --git a/tests/Doctrine/DataFixtures/LoadPolygonData.php b/tests/Doctrine/DataFixtures/LoadPolygonData.php deleted file mode 100644 index 48e6211..0000000 --- a/tests/Doctrine/DataFixtures/LoadPolygonData.php +++ /dev/null @@ -1,33 +0,0 @@ -setPolygon(Polygon::of($ring)); - - $manager->persist($poly1); - $manager->flush(); - } -} diff --git a/tests/Doctrine/Fixtures/GeometryEntity.php b/tests/Doctrine/Fixtures/GeometryEntity.php deleted file mode 100644 index 4807c6e..0000000 --- a/tests/Doctrine/Fixtures/GeometryEntity.php +++ /dev/null @@ -1,36 +0,0 @@ -geometry; - } - - public function setGeometry(Geometry $geometry) : void - { - $this->geometry = $geometry; - } -} diff --git a/tests/Doctrine/Fixtures/LineStringEntity.php b/tests/Doctrine/Fixtures/LineStringEntity.php deleted file mode 100644 index df5870d..0000000 --- a/tests/Doctrine/Fixtures/LineStringEntity.php +++ /dev/null @@ -1,36 +0,0 @@ -lineString; - } - - public function setLineString(LineString $lineString) : void - { - $this->lineString = $lineString; - } -} diff --git a/tests/Doctrine/Fixtures/MultiLineStringEntity.php b/tests/Doctrine/Fixtures/MultiLineStringEntity.php deleted file mode 100644 index 8322f0f..0000000 --- a/tests/Doctrine/Fixtures/MultiLineStringEntity.php +++ /dev/null @@ -1,36 +0,0 @@ -multiLineString; - } - - public function setMultiLineString(MultiLineString $multiLineString) : void - { - $this->multiLineString = $multiLineString; - } -} diff --git a/tests/Doctrine/Fixtures/MultiPointEntity.php b/tests/Doctrine/Fixtures/MultiPointEntity.php deleted file mode 100644 index 6ba9496..0000000 --- a/tests/Doctrine/Fixtures/MultiPointEntity.php +++ /dev/null @@ -1,36 +0,0 @@ -multiPoint; - } - - public function setMultiPoint(MultiPoint $multiPoint) : void - { - $this->multiPoint = $multiPoint; - } -} diff --git a/tests/Doctrine/Fixtures/MultiPolygonEntity.php b/tests/Doctrine/Fixtures/MultiPolygonEntity.php deleted file mode 100644 index b11f9db..0000000 --- a/tests/Doctrine/Fixtures/MultiPolygonEntity.php +++ /dev/null @@ -1,36 +0,0 @@ -multiPolygon; - } - - public function setMultiPolygon(MultiPolygon $multiPolygon) : void - { - $this->multiPolygon = $multiPolygon; - } -} diff --git a/tests/Doctrine/Fixtures/PointEntity.php b/tests/Doctrine/Fixtures/PointEntity.php deleted file mode 100644 index 59cbe06..0000000 --- a/tests/Doctrine/Fixtures/PointEntity.php +++ /dev/null @@ -1,36 +0,0 @@ -point; - } - - public function setPoint(Point $point) : void - { - $this->point = $point; - } -} diff --git a/tests/Doctrine/Fixtures/PolygonEntity.php b/tests/Doctrine/Fixtures/PolygonEntity.php deleted file mode 100644 index 07ca525..0000000 --- a/tests/Doctrine/Fixtures/PolygonEntity.php +++ /dev/null @@ -1,36 +0,0 @@ -polygon; - } - - public function setPolygon(Polygon $polygon) : void - { - $this->polygon = $polygon; - } -} diff --git a/tests/Doctrine/FunctionalTestCase.php b/tests/Doctrine/FunctionalTestCase.php deleted file mode 100644 index 2c3cb51..0000000 --- a/tests/Doctrine/FunctionalTestCase.php +++ /dev/null @@ -1,108 +0,0 @@ -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); - - $this->em = EntityManager::create($this->_conn, $config, $this->platform->getEventManager()); - $schemaTool = new SchemaTool($this->em); - - $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); - } - - protected function getEntityManager() : EntityManager - { - return $this->em; - } - - protected function addFixture(FixtureInterface $fixture) : void - { - $this->fixtureLoader->addFixture($fixture); - } - - protected function loadFixtures() : void - { - $this->ormExecutor->execute($this->fixtureLoader->getFixtures()); - } - - protected function assertPointEquals(Point $point, float $x, float $y, ?float $z = null) : void - { - self::assertInstanceOf(Point::class, $point); - - self::assertSame($x, $point->x()); - self::assertSame($y, $point->y()); - self::assertSame($z, $point->z()); - } -} diff --git a/tests/Doctrine/Types/GeometryTypeTest.php b/tests/Doctrine/Types/GeometryTypeTest.php deleted file mode 100644 index 6afc8c5..0000000 --- a/tests/Doctrine/Types/GeometryTypeTest.php +++ /dev/null @@ -1,41 +0,0 @@ -addFixture(new LoadGeometryData()); - $this->loadFixtures(); - } - - public function testReadFromDbAndConvertToPHPValue() : void - { - $repository = $this->getEntityManager()->getRepository(GeometryEntity::class); - - /** @var GeometryEntity $geometryEntity */ - $geometryEntity = $repository->findOneBy(['id' => 1]); - self::assertNotNull($geometryEntity); - - $geometry = $geometryEntity->getGeometry(); - - self::assertInstanceOf(Point::class, $geometry); - self::assertInstanceOf(ProxyInterface::class, $geometry); - - /** @var Point $geometry */ - $this->assertPointEquals($geometry, 1.0, 2.0); - } -} diff --git a/tests/Doctrine/Types/LineStringTypeTest.php b/tests/Doctrine/Types/LineStringTypeTest.php deleted file mode 100644 index bc55b02..0000000 --- a/tests/Doctrine/Types/LineStringTypeTest.php +++ /dev/null @@ -1,40 +0,0 @@ -addFixture(new LoadLineStringData()); - $this->loadFixtures(); - } - - public function testReadFromDbAndConvertToPHPValue() : void - { - $repository = $this->getEntityManager()->getRepository(LineStringEntity::class); - - /** @var LineStringEntity $lineStringEntity */ - $lineStringEntity = $repository->findOneBy(['id' => 1]); - self::assertNotNull($lineStringEntity); - - $lineString = $lineStringEntity->getLineString(); - self::assertInstanceOf(LineString::class, $lineString); - self::assertSame(3, $lineString->numPoints()); - - $this->assertPointEquals($lineString->pointN(1), 0.0, 0.0); - $this->assertPointEquals($lineString->pointN(2), 1.0, 0.0); - $this->assertPointEquals($lineString->pointN(3), 1.0, 1.0); - } -} diff --git a/tests/Doctrine/Types/MultiLineStringTypeTest.php b/tests/Doctrine/Types/MultiLineStringTypeTest.php deleted file mode 100644 index 0a462be..0000000 --- a/tests/Doctrine/Types/MultiLineStringTypeTest.php +++ /dev/null @@ -1,55 +0,0 @@ -addFixture(new LoadMultiLineStringData()); - $this->loadFixtures(); - } - - public function testReadFromDbAndConvertToPHPValue() : void - { - $repository = $this->getEntityManager()->getRepository(MultiLineStringEntity::class); - - /** @var MultiLineStringEntity $multiLineStringEntity */ - $multiLineStringEntity = $repository->findOneBy(['id' => 1]); - self::assertNotNull($multiLineStringEntity); - - $multiLineString = $multiLineStringEntity->getMultiLineString(); - self::assertInstanceOf(MultiLineString::class, $multiLineString); - self::assertSame(2, $multiLineString->numGeometries()); - - /** @var LineString $lineString1 */ - $lineString1 = $multiLineString->geometryN(1); - self::assertInstanceOf(LineString::class, $lineString1); - self::assertSame(3, $lineString1->numPoints()); - - $this->assertPointEquals($lineString1->pointN(1), 0.0, 0.0); - $this->assertPointEquals($lineString1->pointN(2), 1.0, 0.0); - $this->assertPointEquals($lineString1->pointN(3), 1.0, 1.0); - - /** @var LineString $lineString2 */ - $lineString2 = $multiLineString->geometryN(2); - self::assertInstanceOf(LineString::class, $lineString2); - self::assertSame(3, $lineString2->numPoints()); - - $this->assertPointEquals($lineString2->pointN(1), 2.0, 2.0); - $this->assertPointEquals($lineString2->pointN(2), 3.0, 2.0); - $this->assertPointEquals($lineString2->pointN(3), 3.0, 3.0); - } -} diff --git a/tests/Doctrine/Types/MultiPointTypeTest.php b/tests/Doctrine/Types/MultiPointTypeTest.php deleted file mode 100644 index b09363c..0000000 --- a/tests/Doctrine/Types/MultiPointTypeTest.php +++ /dev/null @@ -1,49 +0,0 @@ -addFixture(new LoadMultiPointData()); - $this->loadFixtures(); - } - - public function testReadFromDbAndConvertToPHPValue() : void - { - $repository = $this->getEntityManager()->getRepository(MultiPointEntity::class); - - /** @var MultiPointEntity $multiPointEntity */ - $multiPointEntity = $repository->findOneBy(['id' => 1]); - self::assertNotNull($multiPointEntity); - - $multiPoint = $multiPointEntity->getMultiPoint(); - self::assertInstanceOf(MultiPoint::class, $multiPoint); - self::assertSame(3, $multiPoint->numGeometries()); - - /** @var Point $point */ - $point = $multiPoint->geometryN(1); - $this->assertPointEquals($point, 0.0, 0.0); - - /** @var Point $point */ - $point = $multiPoint->geometryN(2); - $this->assertPointEquals($point, 1.0, 0.0); - - /** @var Point $point */ - $point = $multiPoint->geometryN(3); - $this->assertPointEquals($point, 1.0, 1.0); - } -} diff --git a/tests/Doctrine/Types/MultiPolygonTypeTest.php b/tests/Doctrine/Types/MultiPolygonTypeTest.php deleted file mode 100644 index fbd060c..0000000 --- a/tests/Doctrine/Types/MultiPolygonTypeTest.php +++ /dev/null @@ -1,68 +0,0 @@ -addFixture(new LoadMultiPolygonData()); - $this->loadFixtures(); - } - - public function testReadFromDbAndConvertToPHPValue() : void - { - $repository = $this->getEntityManager()->getRepository(MultiPolygonEntity::class); - - /** @var MultiPolygonEntity $multiPolygonEntity */ - $multiPolygonEntity = $repository->findOneBy(['id' => 1]); - self::assertNotNull($multiPolygonEntity); - - $multiPolygon = $multiPolygonEntity->getMultiPolygon(); - self::assertInstanceOf(MultiPolygon::class, $multiPolygon); - self::assertSame(2, $multiPolygon->numGeometries()); - - /** @var Polygon $polygon1 */ - $polygon1 = $multiPolygon->geometryN(1); - self::assertInstanceOf(Polygon::class, $polygon1); - self::assertSame(1, $polygon1->count()); - self::assertInstanceOf(LineString::class, $polygon1->exteriorRing()); - - $ring = $polygon1->exteriorRing(); - self::assertSame(5, $ring->numPoints()); - - $this->assertPointEquals($ring->pointN(1), 0.0, 0.0); - $this->assertPointEquals($ring->pointN(2), 1.0, 0.0); - $this->assertPointEquals($ring->pointN(3), 1.0, 1.0); - $this->assertPointEquals($ring->pointN(4), 0.0, 1.0); - $this->assertPointEquals($ring->pointN(5), 0.0, 0.0); - - /** @var Polygon $polygon2 */ - $polygon2 = $multiPolygon->geometryN(2); - self::assertInstanceOf(Polygon::class, $polygon2); - self::assertSame(1, $polygon2->count()); - self::assertInstanceOf(LineString::class, $polygon2->exteriorRing()); - - $ring = $polygon2->exteriorRing(); - self::assertSame(5, $ring->numPoints()); - - $this->assertPointEquals($ring->pointN(1), 2.0, 2.0); - $this->assertPointEquals($ring->pointN(2), 3.0, 2.0); - $this->assertPointEquals($ring->pointN(3), 3.0, 3.0); - $this->assertPointEquals($ring->pointN(4), 2.0, 3.0); - $this->assertPointEquals($ring->pointN(5), 2.0, 2.0); - } -} diff --git a/tests/Doctrine/Types/PointTypeTest.php b/tests/Doctrine/Types/PointTypeTest.php deleted file mode 100644 index 6c8e55d..0000000 --- a/tests/Doctrine/Types/PointTypeTest.php +++ /dev/null @@ -1,34 +0,0 @@ -addFixture(new LoadPointData()); - $this->loadFixtures(); - } - - public function testReadFromDbAndConvertToPHPValue() : void - { - $repository = $this->getEntityManager()->getRepository(PointEntity::class); - - /** @var PointEntity $pointEntity */ - $pointEntity = $repository->findOneBy([]); - self::assertNotNull($pointEntity); - - $point = $pointEntity->getPoint(); - $this->assertPointEquals($point, 0.0, 0.0); - } -} diff --git a/tests/Doctrine/Types/PolygonTypeTest.php b/tests/Doctrine/Types/PolygonTypeTest.php deleted file mode 100644 index 607ff5b..0000000 --- a/tests/Doctrine/Types/PolygonTypeTest.php +++ /dev/null @@ -1,47 +0,0 @@ -addFixture(new LoadPolygonData()); - $this->loadFixtures(); - } - - public function testReadFromDbAndConvertToPHPValue() : void - { - $repository = $this->getEntityManager()->getRepository(PolygonEntity::class); - - /** @var PolygonEntity $polygonEntity */ - $polygonEntity = $repository->findOneBy(['id' => 1]); - self::assertNotNull($polygonEntity); - - $polygon = $polygonEntity->getPolygon(); - self::assertInstanceOf(Polygon::class, $polygon); - self::assertSame(1, $polygon->count()); - self::assertInstanceOf(LineString::class, $polygon->exteriorRing()); - - $ring = $polygon->exteriorRing(); - self::assertSame(5, $ring->numPoints()); - - $this->assertPointEquals($ring->pointN(1), 0.0, 0.0); - $this->assertPointEquals($ring->pointN(2), 1.0, 0.0); - $this->assertPointEquals($ring->pointN(3), 1.0, 1.0); - $this->assertPointEquals($ring->pointN(4), 0.0, 1.0); - $this->assertPointEquals($ring->pointN(5), 0.0, 0.0); - } -}