44use Grimzy \LaravelMysqlSpatial \MysqlConnection ;
55use Grimzy \LaravelMysqlSpatial \Types \Point ;
66use Illuminate \Database \Eloquent \Model ;
7+ use Illuminate \Database \Grammar ;
78use Mockery \Adapter \Phpunit \MockeryPHPUnitIntegration ;
89use Mockery as m ;
910
@@ -14,17 +15,23 @@ class SpatialTraitTest extends BaseTestCase
1415 /**
1516 * @var TestModel
1617 */
17- protected $ model ;
18+ protected TestModel $ model ;
1819
1920 /**
2021 * @var array
2122 */
22- protected $ queries ;
23+ protected array $ queries ;
24+
25+ /**
26+ * @var Grammar
27+ */
28+ protected Grammar $ grammar ;
2329
2430 public function setUp (): void
2531 {
2632 $ this ->model = new TestModel ();
2733 $ this ->queries = &$ this ->model ->getConnection ()->getPdo ()->queries ;
34+ $ this ->grammar = $ this ->model ->getConnection ()->getQueryGrammar ();
2835 }
2936
3037 public function tearDown (): void
@@ -303,7 +310,7 @@ public function testScopeDistanceValue()
303310 $ this ->assertNotEmpty ($ bindings );
304311 $ this ->assertEquals ('* ' , $ q ->columns [0 ]);
305312 $ 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 ));
307314 $ this ->assertEquals ('POINT(2 1) ' , $ bindings [0 ]);
308315 }
309316
@@ -319,7 +326,7 @@ public function testScopeDistanceValueWithSelect()
319326 $ this ->assertNotEmpty ($ bindings );
320327 $ this ->assertEquals ('some_column ' , $ q ->columns [0 ]);
321328 $ 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 ));
323330 $ this ->assertEquals ('POINT(2 1) ' , $ bindings [0 ]);
324331 }
325332
@@ -335,7 +342,7 @@ public function testScopeDistanceSphereValue()
335342 $ this ->assertNotEmpty ($ bindings );
336343 $ this ->assertEquals ('* ' , $ q ->columns [0 ]);
337344 $ 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 ));
339346 $ this ->assertEquals ('POINT(2 1) ' , $ bindings [0 ]);
340347 }
341348
@@ -351,7 +358,7 @@ public function testScopeDistanceSphereValueWithSelect()
351358 $ this ->assertNotEmpty ($ bindings );
352359 $ this ->assertEquals ('some_column ' , $ q ->columns [0 ]);
353360 $ 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 ));
355362 $ this ->assertEquals ('POINT(2 1) ' , $ bindings [0 ]);
356363 }
357364
0 commit comments