-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathDoctrineTypesTest.php
66 lines (61 loc) · 2.3 KB
/
DoctrineTypesTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
use Doctrine\DBAL\Types\Type;
use Illuminate\Foundation\Application;
use Illuminate\Support\Facades\DB;
use MatanYadaev\EloquentSpatial\Doctrine\GeographyType;
use MatanYadaev\EloquentSpatial\Doctrine\GeometryCollectionType;
use MatanYadaev\EloquentSpatial\Doctrine\GeometryType;
use MatanYadaev\EloquentSpatial\Doctrine\LineStringType;
use MatanYadaev\EloquentSpatial\Doctrine\MultiLineStringType;
use MatanYadaev\EloquentSpatial\Doctrine\MultiPointType;
use MatanYadaev\EloquentSpatial\Doctrine\MultiPolygonType;
use MatanYadaev\EloquentSpatial\Doctrine\PointType;
use MatanYadaev\EloquentSpatial\Doctrine\PolygonType;
/** @var array{column: string, postgresType: class-string<Type>, mySqlType: class-string<Type>} $typeClass */
$dataset = [
[
'column' => 'point',
'postgresType' => GeometryType::class,
'mySqlType' => PointType::class,
],
[
'column' => 'point_geography',
'postgresType' => GeographyType::class,
'mySqlType' => PointType::class,
],
[
'column' => 'line_string',
'postgresType' => GeometryType::class,
'mySqlType' => LineStringType::class,
],
[
'column' => 'multi_point',
'postgresType' => GeometryType::class,
'mySqlType' => MultiPointType::class,
],
[
'column' => 'polygon',
'postgresType' => GeometryType::class,
'mySqlType' => PolygonType::class,
],
[
'column' => 'multi_line_string',
'postgresType' => GeometryType::class,
'mySqlType' => MultiLineStringType::class,
],
[
'column' => 'multi_polygon',
'postgresType' => GeometryType::class,
'mySqlType' => MultiPolygonType::class,
],
[
'column' => 'geometry_collection',
'postgresType' => GeometryType::class,
'mySqlType' => GeometryCollectionType::class,
],
];
it('uses custom Doctrine types for spatial columns', function ($column, $postgresType, $mySqlType): void {
$doctrineSchemaManager = DB::connection()->getDoctrineSchemaManager();
$columns = $doctrineSchemaManager->listTableColumns('test_places');
expect($columns[$column]->getType())->toBeInstanceOfOnPostgres($postgresType)->toBeInstanceOfOnMysql($mySqlType);
})->with($dataset)->skip(version_compare(Application::VERSION, '11.0.0', '>='));