Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/5.1.x-dev' into 6.x…
Browse files Browse the repository at this point in the history
…-dev
  • Loading branch information
Alexandre-T committed Jun 13, 2024
2 parents 959c338 + b51b656 commit 18331ad
Show file tree
Hide file tree
Showing 8 changed files with 178 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@

namespace LongitudeOne\Spatial\Tests\DBAL\Types\Geography;

use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Types\Exception\TypeNotRegistered;
use Doctrine\DBAL\Types\Type;
use LongitudeOne\Spatial\DBAL\Types\Geography\PointType;
use LongitudeOne\Spatial\Exception\InvalidValueException;
use LongitudeOne\Spatial\PHP\Types\Geography\Point;
use LongitudeOne\Spatial\Tests\Fixtures\GeoPointSridEntity;
Expand Down Expand Up @@ -67,6 +71,25 @@ public function testFindGeographyBy(): void
static::assertEquals(4326, $queryEntities[0]->getPoint()->getSrid());
}

/**
* Unit test the getName, getSQLType and getBindingType methods.
*
* @throws TypeNotRegistered It shall not happen
*/
public function testName(): void
{
if (!Type::hasType('geopoint')) {
Type::addType('geopoint', PointType::class);
}

static::assertTrue(Type::hasType('geopoint'));
$spatialInstance = new PointType();
static::assertNotFalse($spatialInstance->getName());
static::assertSame('geopoint', $spatialInstance->getName());
static::assertSame(ParameterType::STRING, $spatialInstance->getBindingType());
static::assertSame('Point', $spatialInstance->getSQLType());
}

/**
* Test a null geography.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@

namespace LongitudeOne\Spatial\Tests\DBAL\Types\Geography;

use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Types\Exception\TypeNotRegistered;
use Doctrine\DBAL\Types\Type;
use LongitudeOne\Spatial\DBAL\Types\Geography\PolygonType;
use LongitudeOne\Spatial\Exception\InvalidValueException;
use LongitudeOne\Spatial\PHP\Types\Geography\LineString;
use LongitudeOne\Spatial\PHP\Types\Geography\Point;
Expand Down Expand Up @@ -81,6 +85,25 @@ public function testFindByPolygon(): void
static::assertEquals($entity, $result[0]);
}

/**
* Unit test the getName, getSQLType and getBindingType methods.
*
* @throws TypeNotRegistered It shall not happen
*/
public function testName(): void
{
if (!Type::hasType('geopolygon')) {
Type::addType('geopolygon', PolygonType::class);
}

static::assertTrue(Type::hasType('geopolygon'));
$spatialInstance = new PolygonType();
static::assertNotFalse($spatialInstance->getName());
static::assertSame('geopolygon', $spatialInstance->getName());
static::assertSame(ParameterType::STRING, $spatialInstance->getBindingType());
static::assertSame('Polygon', $spatialInstance->getSQLType());
}

/**
* Test to store an empty polygon.
*/
Expand Down
22 changes: 22 additions & 0 deletions tests/LongitudeOne/Spatial/Tests/DBAL/Types/GeographyTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@

namespace LongitudeOne\Spatial\Tests\DBAL\Types;

use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Types\Exception\TypeNotRegistered;
use Doctrine\DBAL\Types\Type;
use LongitudeOne\Spatial\DBAL\Types\GeographyType;
use LongitudeOne\Spatial\Exception\InvalidValueException;
use LongitudeOne\Spatial\PHP\Types\Geography\LineString;
use LongitudeOne\Spatial\PHP\Types\Geography\Point;
Expand Down Expand Up @@ -64,6 +68,24 @@ public function testLineStringGeography(): void
$this->assertIsRetrievableById($this->getEntityManager(), $entity);
}

/**
* Unit test the getName, getSQLType and getBindingType methods.
*
* @throws TypeNotRegistered It shall not happen
*/
public function testName(): void
{
if (!Type::hasType('geography')) {
Type::addType('geography', GeographyType::class);
}

$spatialInstance = new GeographyType();
static::assertNotFalse($spatialInstance->getName());
static::assertSame('geography', $spatialInstance->getName());
static::assertSame(ParameterType::STRING, $spatialInstance->getBindingType());
static::assertSame('Geography', $spatialInstance->getSQLType());
}

/**
* Test to store and retrieve a null geography.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@

namespace LongitudeOne\Spatial\Tests\DBAL\Types\Geometry;

use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Types\Exception\TypeNotRegistered;
use Doctrine\DBAL\Types\Type;
use LongitudeOne\Spatial\DBAL\Types\Geometry\LineStringType;
use LongitudeOne\Spatial\Exception\InvalidValueException;
use LongitudeOne\Spatial\PHP\Types\Geometry\LineString;
use LongitudeOne\Spatial\PHP\Types\Geometry\Point;
Expand Down Expand Up @@ -91,6 +95,24 @@ public function testLineString(): void
static::assertIsRetrievableById($this->getEntityManager(), $entity);
}

/**
* Unit test the getName, getSQLType and getBindingType methods.
*
* @throws TypeNotRegistered It shall not happen
*/
public function testName(): void
{
if (!Type::hasType('linestring')) {
Type::addType('linestring', LineStringType::class);
}

$spatialInstance = new LineStringType();
static::assertNotFalse($spatialInstance->getName());
static::assertSame('linestring', $spatialInstance->getName());
static::assertSame(ParameterType::STRING, $spatialInstance->getBindingType());
static::assertSame('LineString', $spatialInstance->getSQLType());
}

/**
* Test to store a null line string, then to find it with its id.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@

namespace LongitudeOne\Spatial\Tests\DBAL\Types\Geometry;

use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Types\Exception\TypeNotRegistered;
use Doctrine\DBAL\Types\Type;
use LongitudeOne\Spatial\DBAL\Types\Geometry\MultiPolygonType;
use LongitudeOne\Spatial\Exception\InvalidValueException;
use LongitudeOne\Spatial\PHP\Types\Geometry\LineString;
use LongitudeOne\Spatial\PHP\Types\Geometry\MultiPolygon;
Expand Down Expand Up @@ -101,6 +105,24 @@ public function testMultiPolygon(): void
static::assertEquals($entity, $result[0]);
}

/**
* Unit test the getName, getSQLType and getBindingType methods.
*
* @throws TypeNotRegistered It shall not happen
*/
public function testName(): void
{
if (!Type::hasType('multipolygon')) {
Type::addType('multipolygon', MultiPolygonType::class);
}

$spatialInstance = new MultiPolygonType();
static::assertNotFalse($spatialInstance->getName());
static::assertSame('multipolygon', $spatialInstance->getName());
static::assertSame(ParameterType::STRING, $spatialInstance->getBindingType());
static::assertSame('MultiPolygon', $spatialInstance->getSQLType());
}

/**
* Test to store a null multipolygon and find it by id.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@

namespace LongitudeOne\Spatial\Tests\DBAL\Types\Geometry;

use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Types\Exception\TypeNotRegistered;
use Doctrine\DBAL\Types\Type;
use LongitudeOne\Spatial\DBAL\Types\Geometry\PointType;
use LongitudeOne\Spatial\Tests\Fixtures\PointEntity;
use LongitudeOne\Spatial\Tests\Helper\PersistantPointHelperTrait;
use LongitudeOne\Spatial\Tests\PersistOrmTestCase;
Expand Down Expand Up @@ -94,6 +98,24 @@ public function testFindByPoint(): void
static::assertEquals($entity, $result[0]);
}

/**
* Unit test the getName, getSQLType and getBindingType methods.
*
* @throws TypeNotRegistered It shall not happen
*/
public function testName(): void
{
if (!Type::hasType('point')) {
Type::addType('point', PointType::class);
}

$spatialInstance = new PointType();
static::assertNotFalse($spatialInstance->getName());
static::assertSame('point', $spatialInstance->getName());
static::assertSame(ParameterType::STRING, $spatialInstance->getBindingType());
static::assertSame('Point', $spatialInstance->getSQLType());
}

/**
* Test to store a null point and find it by its id.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@

namespace LongitudeOne\Spatial\Tests\DBAL\Types\Geometry;

use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Types\Exception\TypeNotRegistered;
use Doctrine\DBAL\Types\Type;
use LongitudeOne\Spatial\DBAL\Types\Geometry\PolygonType;
use LongitudeOne\Spatial\Tests\Fixtures\PolygonEntity;
use LongitudeOne\Spatial\Tests\Helper\LineStringHelperTrait;
use LongitudeOne\Spatial\Tests\Helper\PersistantPolygonHelperTrait;
Expand Down Expand Up @@ -66,6 +70,24 @@ public function testFindByPolygon(): void
static::assertEquals($entity, $result[0]);
}

/**
* Unit test the getName, getSQLType and getBindingType methods.
*
* @throws TypeNotRegistered It shall not happen
*/
public function testName(): void
{
if (!Type::hasType('polygon')) {
Type::addType('polygon', PolygonType::class);
}

$spatialInstance = new PolygonType();
static::assertNotFalse($spatialInstance->getName());
static::assertSame('polygon', $spatialInstance->getName());
static::assertSame(ParameterType::STRING, $spatialInstance->getBindingType());
static::assertSame('Polygon', $spatialInstance->getSQLType());
}

/**
* Test to store a null polygon and find it by its id.
*/
Expand Down
22 changes: 22 additions & 0 deletions tests/LongitudeOne/Spatial/Tests/DBAL/Types/GeometryTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@

namespace LongitudeOne\Spatial\Tests\DBAL\Types;

use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Types\Exception\TypeNotRegistered;
use Doctrine\DBAL\Types\Type;
use LongitudeOne\Spatial\DBAL\Types\GeometryType;
use LongitudeOne\Spatial\Exception\InvalidValueException;
use LongitudeOne\Spatial\PHP\Types\Geometry\GeometryInterface;
use LongitudeOne\Spatial\PHP\Types\Geometry\LineString;
Expand Down Expand Up @@ -84,6 +88,24 @@ public function testLineStringGeometry(): void
static::assertInstanceOf(GeometryInterface::class, $entity->getGeometry());
}

/**
* Unit test the getName, getSQLType and getBindingType methods.
*
* @throws TypeNotRegistered It shall not happen
*/
public function testName(): void
{
if (!Type::hasType('geometry')) {
Type::addType('geometry', GeometryType::class);
}

$spatialInstance = new GeometryType();
static::assertNotFalse($spatialInstance->getName());
static::assertSame('geometry', $spatialInstance->getName());
static::assertSame(ParameterType::STRING, $spatialInstance->getBindingType());
static::assertSame('Geometry', $spatialInstance->getSQLType());
}

/**
* Test to store a null geometry and retrieve it by its identifier.
*/
Expand Down

0 comments on commit 18331ad

Please sign in to comment.