4
4
use Grimzy \LaravelMysqlSpatial \MysqlConnection ;
5
5
use Grimzy \LaravelMysqlSpatial \Types \Point ;
6
6
use Illuminate \Database \Eloquent \Model ;
7
+ use Illuminate \Database \Grammar ;
7
8
use Mockery \Adapter \Phpunit \MockeryPHPUnitIntegration ;
8
9
use Mockery as m ;
9
10
@@ -14,17 +15,23 @@ class SpatialTraitTest extends BaseTestCase
14
15
/**
15
16
* @var TestModel
16
17
*/
17
- protected $ model ;
18
+ protected TestModel $ model ;
18
19
19
20
/**
20
21
* @var array
21
22
*/
22
- protected $ queries ;
23
+ protected array $ queries ;
24
+
25
+ /**
26
+ * @var Grammar
27
+ */
28
+ protected Grammar $ grammar ;
23
29
24
30
public function setUp (): void
25
31
{
26
32
$ this ->model = new TestModel ();
27
33
$ this ->queries = &$ this ->model ->getConnection ()->getPdo ()->queries ;
34
+ $ this ->grammar = $ this ->model ->getConnection ()->getQueryGrammar ();
28
35
}
29
36
30
37
public function tearDown (): void
@@ -303,7 +310,7 @@ public function testScopeDistanceValue()
303
310
$ this ->assertNotEmpty ($ bindings );
304
311
$ this ->assertEquals ('* ' , $ q ->columns [0 ]);
305
312
$ this ->assertInstanceOf (\Illuminate \Database \Query \Expression::class, $ q ->columns [1 ]);
306
- $ this ->assertEquals ('st_distance(`point`, ST_GeomFromText(?, ?, \'axis-order=long-lat \')) as distance ' , $ q ->columns [1 ]->getValue ());
313
+ $ this ->assertEquals ('st_distance(`point`, ST_GeomFromText(?, ?, \'axis-order=long-lat \')) as distance ' , $ q ->columns [1 ]->getValue ($ this -> grammar ));
307
314
$ this ->assertEquals ('POINT(2 1) ' , $ bindings [0 ]);
308
315
}
309
316
@@ -319,7 +326,7 @@ public function testScopeDistanceValueWithSelect()
319
326
$ this ->assertNotEmpty ($ bindings );
320
327
$ this ->assertEquals ('some_column ' , $ q ->columns [0 ]);
321
328
$ this ->assertInstanceOf (\Illuminate \Database \Query \Expression::class, $ q ->columns [1 ]);
322
- $ this ->assertEquals ('st_distance(`point`, ST_GeomFromText(?, ?, \'axis-order=long-lat \')) as distance ' , $ q ->columns [1 ]->getValue ());
329
+ $ this ->assertEquals ('st_distance(`point`, ST_GeomFromText(?, ?, \'axis-order=long-lat \')) as distance ' , $ q ->columns [1 ]->getValue ($ this -> grammar ));
323
330
$ this ->assertEquals ('POINT(2 1) ' , $ bindings [0 ]);
324
331
}
325
332
@@ -335,7 +342,7 @@ public function testScopeDistanceSphereValue()
335
342
$ this ->assertNotEmpty ($ bindings );
336
343
$ this ->assertEquals ('* ' , $ q ->columns [0 ]);
337
344
$ this ->assertInstanceOf (\Illuminate \Database \Query \Expression::class, $ q ->columns [1 ]);
338
- $ this ->assertEquals ('st_distance_sphere(`point`, ST_GeomFromText(?, ?, \'axis-order=long-lat \')) as distance ' , $ q ->columns [1 ]->getValue ());
345
+ $ this ->assertEquals ('st_distance_sphere(`point`, ST_GeomFromText(?, ?, \'axis-order=long-lat \')) as distance ' , $ q ->columns [1 ]->getValue ($ this -> grammar ));
339
346
$ this ->assertEquals ('POINT(2 1) ' , $ bindings [0 ]);
340
347
}
341
348
@@ -351,7 +358,7 @@ public function testScopeDistanceSphereValueWithSelect()
351
358
$ this ->assertNotEmpty ($ bindings );
352
359
$ this ->assertEquals ('some_column ' , $ q ->columns [0 ]);
353
360
$ this ->assertInstanceOf (\Illuminate \Database \Query \Expression::class, $ q ->columns [1 ]);
354
- $ this ->assertEquals ('st_distance_sphere(`point`, ST_GeomFromText(?, ?, \'axis-order=long-lat \')) as distance ' , $ q ->columns [1 ]->getValue ());
361
+ $ this ->assertEquals ('st_distance_sphere(`point`, ST_GeomFromText(?, ?, \'axis-order=long-lat \')) as distance ' , $ q ->columns [1 ]->getValue ($ this -> grammar ));
355
362
$ this ->assertEquals ('POINT(2 1) ' , $ bindings [0 ]);
356
363
}
357
364
0 commit comments