Skip to content

Commit c11c552

Browse files
committed
Test storing a point in column with SRID 4326
1 parent 199f2b1 commit c11c552

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

tests/Objects/PointTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@
2525
expect($testPlace->point->srid)->toBe(4326);
2626
});
2727

28+
it('creates a model record that has a column with SRID defined using point with SRID', function (): void {
29+
$point = new Point(-43.5309, 172.6365, 4326); // Christchurch, New Zealand
30+
31+
/** @var TestPlace $testPlace */
32+
$testPlace = TestPlace::factory()->create(['point_with_srid' => $point]);
33+
34+
expect($testPlace->point_with_srid)->toEqual($point);
35+
});
36+
2837
it('creates point from JSON', function (): void {
2938
$point = new Point(180, 0);
3039

tests/TestModels/TestPlace.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class TestPlace extends Model
5353
'multi_polygon' => MultiPolygon::class,
5454
'geometry_collection' => GeometryCollection::class,
5555
'point_with_line_string_cast' => LineString::class,
56+
'point_with_srid' => Point::class,
5657
];
5758

5859
/**

tests/database/migrations/0000_00_00_000000_create_test_places_table.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public function up(): void
2121
$table->multiPolygon('multi_polygon')->nullable();
2222
$table->geometryCollection('geometry_collection')->nullable();
2323
$table->point('point_with_line_string_cast')->nullable();
24+
$table->point('point_with_srid', 4326)->nullable();
2425
});
2526
}
2627

0 commit comments

Comments
 (0)