|
1 | 1 | <?php |
2 | 2 |
|
| 3 | +use Doctrine\DBAL\Types\Type; |
3 | 4 | use Illuminate\Support\Facades\DB; |
4 | 5 | use MatanYadaev\EloquentSpatial\Doctrine\GeometryCollectionType; |
5 | 6 | use MatanYadaev\EloquentSpatial\Doctrine\LineStringType; |
|
9 | 10 | use MatanYadaev\EloquentSpatial\Doctrine\PointType; |
10 | 11 | use MatanYadaev\EloquentSpatial\Doctrine\PolygonType; |
11 | 12 |
|
12 | | -it('uses custom Doctrine types for spatial columns', function (): void { |
| 13 | +it('uses custom Doctrine types for spatial columns', function (string $column, string $typeClass, string $typeName): void { |
| 14 | + /** @var class-string<Type> $typeClass */ |
13 | 15 | $doctrineSchemaManager = DB::connection()->getDoctrineSchemaManager(); |
14 | 16 |
|
15 | 17 | $columns = $doctrineSchemaManager->listTableColumns('test_places'); |
16 | 18 |
|
17 | | - expect($columns['point']->getType()) |
18 | | - ->toBeInstanceOf(PointType::class) |
19 | | - ->getName()->toBe('point'); |
20 | | - |
21 | | - expect($columns['line_string']->getType()) |
22 | | - ->toBeInstanceOf(LineStringType::class) |
23 | | - ->getName()->toBe('linestring'); |
24 | | - |
25 | | - expect($columns['multi_point']->getType()) |
26 | | - ->toBeInstanceOf(MultiPointType::class) |
27 | | - ->getName()->toBe('multipoint'); |
28 | | - |
29 | | - expect($columns['polygon']->getType()) |
30 | | - ->toBeInstanceOf(PolygonType::class) |
31 | | - ->getName()->toBe('polygon'); |
32 | | - |
33 | | - expect($columns['multi_line_string']->getType()) |
34 | | - ->toBeInstanceOf(MultiLineStringType::class) |
35 | | - ->getName()->toBe('multilinestring'); |
36 | | - |
37 | | - expect($columns['multi_polygon']->getType()) |
38 | | - ->toBeInstanceOf(MultiPolygonType::class) |
39 | | - ->getName()->toBe('multipolygon'); |
40 | | - |
41 | | - expect($columns['geometry_collection']->getType()) |
42 | | - ->toBeInstanceOf(GeometryCollectionType::class) |
43 | | - ->getName()->toBe('geometrycollection'); |
44 | | -}); |
| 19 | + expect($columns[$column]->getType())->toBeInstanceOf($typeClass) |
| 20 | + ->and($columns[$column]->getType()->getName())->toBe($typeName); |
| 21 | +})->with([ |
| 22 | + 'point' => ['point', PointType::class, 'point'], |
| 23 | + 'line_string' => ['line_string', LineStringType::class, 'linestring'], |
| 24 | + 'multi_point' => ['multi_point', MultiPointType::class, 'multipoint'], |
| 25 | + 'polygon' => ['polygon', PolygonType::class, 'polygon'], |
| 26 | + 'multi_line_string' => ['multi_line_string', MultiLineStringType::class, 'multilinestring'], |
| 27 | + 'multi_polygon' => ['multi_polygon', MultiPolygonType::class, 'multipolygon'], |
| 28 | + 'geometry_collection' => ['geometry_collection', GeometryCollectionType::class, 'geometrycollection'], |
| 29 | +]); |
0 commit comments