|
191 | 191 | expect($testPlace->isDirty())->toBeFalse();
|
192 | 192 | });
|
193 | 193 |
|
194 |
| -it('handles ST_GeomFromText optional values on a raw expression', function (string $expression): void { |
| 194 | +it('handles casting geometry columns with raw expressions', function (string $expression): void { |
195 | 195 | // Arrange
|
| 196 | + /** @var TestPlace $testPlace */ |
196 | 197 | $testPlace = TestPlace::factory()->create(['point' => DB::raw($expression)]);
|
197 | 198 |
|
198 |
| - // Act |
199 |
| - $testPlace->point = null; |
200 |
| - |
201 |
| - // Assert |
202 |
| - // Will trigger 'point' attribute to cast raw expression to a Point object |
203 |
| - expect($testPlace->isDirty())->toBeTrue(); |
| 199 | + // Act & Assert |
| 200 | + expect(function () use ($testPlace): void { |
| 201 | + // Trigger 'point' attribute to cast raw expression to a `Point` object |
| 202 | + $testPlace->originalIsEquivalent('point'); |
| 203 | + })->not->toThrow(Exception::class); |
204 | 204 | })->with([
|
205 |
| - 'without SRID' => "ST_GeomFromText('POINT(12.38057 55.73406)')", |
206 |
| - 'with SRID' => "ST_GeomFromText('POINT(12.38057 55.73406)', 4326)", |
| 205 | + 'without SRID' => "ST_GeomFromText('POINT(0 0)')", |
| 206 | + 'with SRID' => "ST_GeomFromText('POINT(0 0)', 4326)", |
207 | 207 | ]);
|
208 | 208 |
|
209 |
| -it('handles ST_GeomFromText option for mysql on a raw expression', function (): void { |
| 209 | +it('handles casting geometry columns with raw expressions with axis order', function (): void { |
210 | 210 | // Arrange
|
211 |
| - $testPlace = TestPlace::factory()->create(['point' => DB::raw("ST_GeomFromText('POINT(12.38057 55.73406)', 4326, 'axis-order=long-lat')")]); |
212 |
| - |
213 |
| - // Act |
214 |
| - $testPlace->point = null; |
| 211 | + /** @var TestPlace $testPlace */ |
| 212 | + $testPlace = TestPlace::factory()->create(['point' => DB::raw("ST_GeomFromText('POINT(0 0)', 4326, 'axis-order=long-lat')")]); |
215 | 213 |
|
216 |
| - // Assert |
217 |
| - // Will trigger 'point' attribute to cast raw expression to a Point object |
218 |
| - expect($testPlace->isDirty())->toBeTrue(); |
| 214 | + // Act & Assert |
| 215 | + expect(function () use ($testPlace): void { |
| 216 | + // Trigger 'point' attribute to cast raw expression to a `Point` object |
| 217 | + $testPlace->originalIsEquivalent('point'); |
| 218 | + })->not->toThrow(Exception::class); |
219 | 219 | })->skip(fn () => ! AxisOrder::supported(DB::connection()));
|
0 commit comments