Skip to content

Commit ddedd29

Browse files
committed
Add test case to illustrate problems with regex to convert WKT to geometry
1 parent a6bae05 commit ddedd29

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/GeometryCastTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,3 +189,19 @@
189189

190190
expect($testPlace->isDirty())->toBeFalse();
191191
});
192+
193+
it('handles ST_GeomFromText optional values on a raw expression', function (string $expression): void {
194+
// Arrange
195+
$testPlace = TestPlace::factory()->create(['point' => DB::raw($expression)]);
196+
197+
// Act
198+
$testPlace->point = null;
199+
200+
// Assert
201+
// Will trigger 'point' attribute to cast raw expression to a Point object
202+
expect($testPlace->isDirty())->toBeTrue();
203+
})->with([
204+
'without SRID' => "ST_GeomFromText('POINT(12.38057 55.73406)')",
205+
'with SRID' => "ST_GeomFromText('POINT(12.38057 55.73406)', 4326)",
206+
'with options' => "ST_GeomFromText('POINT(12.38057 55.73406)', 4326, 'axis-order=long-lat')",
207+
]);

0 commit comments

Comments
 (0)