@@ -215,7 +215,10 @@ public function testScopeDistance()
215215 $ this ->assertInstanceOf (\Grimzy \LaravelMysqlSpatial \Eloquent \Builder::class, $ query );
216216 $ q = $ query ->getQuery ();
217217 $ this ->assertNotEmpty ($ q ->wheres );
218- $ this ->assertContains ("st_distance(`point`, ST_GeomFromText('POINT(2 1)')) <= 10 " , $ q ->wheres [0 ]['sql ' ]);
218+ $ this ->assertNotEmpty ($ q ->bindings ['where ' ]);
219+ $ this ->assertEquals ('st_distance(`point`, ST_GeomFromText(?)) <= ? ' , $ q ->wheres [0 ]['sql ' ]);
220+ $ this ->assertEquals ('POINT(2 1) ' , $ q ->bindings ['where ' ][0 ]);
221+ $ this ->assertEquals (10 , $ q ->bindings ['where ' ][1 ]);
219222 }
220223
221224 public function testScopeDistanceExcludingSelf ()
@@ -226,8 +229,12 @@ public function testScopeDistanceExcludingSelf()
226229 $ this ->assertInstanceOf (\Grimzy \LaravelMysqlSpatial \Eloquent \Builder::class, $ query );
227230 $ q = $ query ->getQuery ();
228231 $ this ->assertNotEmpty ($ q ->wheres );
229- $ this ->assertContains ("st_distance(`point`, ST_GeomFromText('POINT(2 1)')) <= 10 " , $ q ->wheres [0 ]['sql ' ]);
230- $ this ->assertContains ("st_distance(`point`, ST_GeomFromText('POINT(2 1)')) != 0 " , $ q ->wheres [1 ]['sql ' ]);
232+ $ this ->assertNotEmpty ($ q ->bindings ['where ' ]);
233+ $ this ->assertEquals ('st_distance(`point`, ST_GeomFromText(?)) <= ? ' , $ q ->wheres [0 ]['sql ' ]);
234+ $ this ->assertEquals ('st_distance(`point`, ST_GeomFromText(?)) != 0 ' , $ q ->wheres [1 ]['sql ' ]);
235+ $ this ->assertEquals ('POINT(2 1) ' , $ q ->bindings ['where ' ][0 ]);
236+ $ this ->assertEquals (10 , $ q ->bindings ['where ' ][1 ]);
237+ $ this ->assertEquals ('POINT(2 1) ' , $ q ->bindings ['where ' ][2 ]);
231238 }
232239
233240 public function testScopeDistanceSphere ()
@@ -238,7 +245,10 @@ public function testScopeDistanceSphere()
238245 $ this ->assertInstanceOf (\Grimzy \LaravelMysqlSpatial \Eloquent \Builder::class, $ query );
239246 $ q = $ query ->getQuery ();
240247 $ this ->assertNotEmpty ($ q ->wheres );
241- $ this ->assertContains ("st_distance_sphere(`point`, ST_GeomFromText('POINT(2 1)')) <= 10 " , $ q ->wheres [0 ]['sql ' ]);
248+ $ this ->assertNotEmpty ($ q ->bindings ['where ' ]);
249+ $ this ->assertEquals ('st_distance_sphere(`point`, ST_GeomFromText(?)) <= ? ' , $ q ->wheres [0 ]['sql ' ]);
250+ $ this ->assertEquals ('POINT(2 1) ' , $ q ->bindings ['where ' ][0 ]);
251+ $ this ->assertEquals (10 , $ q ->bindings ['where ' ][1 ]);
242252 }
243253
244254 public function testScopeDistanceSphereExcludingSelf ()
@@ -249,8 +259,12 @@ public function testScopeDistanceSphereExcludingSelf()
249259 $ this ->assertInstanceOf (\Grimzy \LaravelMysqlSpatial \Eloquent \Builder::class, $ query );
250260 $ q = $ query ->getQuery ();
251261 $ this ->assertNotEmpty ($ q ->wheres );
252- $ this ->assertContains ("st_distance_sphere(`point`, ST_GeomFromText('POINT(2 1)')) <= 10 " , $ q ->wheres [0 ]['sql ' ]);
253- $ this ->assertContains ("st_distance_sphere(`point`, ST_GeomFromText('POINT(2 1)')) != 0 " , $ q ->wheres [1 ]['sql ' ]);
262+ $ this ->assertNotEmpty ($ q ->bindings ['where ' ]);
263+ $ this ->assertEquals ('st_distance_sphere(`point`, ST_GeomFromText(?)) <= ? ' , $ q ->wheres [0 ]['sql ' ]);
264+ $ this ->assertEquals ('st_distance_sphere(point, ST_GeomFromText(?)) != 0 ' , $ q ->wheres [1 ]['sql ' ]);
265+ $ this ->assertEquals ('POINT(2 1) ' , $ q ->bindings ['where ' ][0 ]);
266+ $ this ->assertEquals (10 , $ q ->bindings ['where ' ][1 ]);
267+ $ this ->assertEquals ('POINT(2 1) ' , $ q ->bindings ['where ' ][2 ]);
254268 }
255269
256270 public function testScopeDistanceValue ()
@@ -261,9 +275,11 @@ public function testScopeDistanceValue()
261275 $ this ->assertInstanceOf (\Grimzy \LaravelMysqlSpatial \Eloquent \Builder::class, $ query );
262276 $ q = $ query ->getQuery ();
263277 $ this ->assertNotEmpty ($ q ->columns );
264- $ this ->assertContains ('* ' , $ q ->columns [0 ]);
278+ $ this ->assertNotEmpty ($ q ->bindings ['select ' ]);
279+ $ this ->assertEquals ('* ' , $ q ->columns [0 ]);
265280 $ this ->assertInstanceOf (\Illuminate \Database \Query \Expression::class, $ q ->columns [1 ]);
266- $ this ->assertContains ("st_distance(`point`, ST_GeomFromText('POINT(2 1)')) as distance " , $ q ->columns [1 ]->getValue ());
281+ $ this ->assertEquals ('st_distance(`point`, ST_GeomFromText(?)) as distance ' , $ q ->columns [1 ]->getValue ());
282+ $ this ->assertEquals ('POINT(2 1) ' , $ q ->bindings ['select ' ][0 ]);
267283 }
268284
269285 public function testScopeDistanceValueWithSelect ()
@@ -274,9 +290,11 @@ public function testScopeDistanceValueWithSelect()
274290 $ this ->assertInstanceOf (\Grimzy \LaravelMysqlSpatial \Eloquent \Builder::class, $ query );
275291 $ q = $ query ->getQuery ();
276292 $ this ->assertNotEmpty ($ q ->columns );
277- $ this ->assertContains ('some_column ' , $ q ->columns [0 ]);
293+ $ this ->assertNotEmpty ($ q ->bindings ['select ' ]);
294+ $ this ->assertEquals ('some_column ' , $ q ->columns [0 ]);
278295 $ this ->assertInstanceOf (\Illuminate \Database \Query \Expression::class, $ q ->columns [1 ]);
279- $ this ->assertContains ("st_distance(`point`, ST_GeomFromText('POINT(2 1)')) as distance " , $ q ->columns [1 ]->getValue ());
296+ $ this ->assertEquals ('st_distance(`point`, ST_GeomFromText(?)) as distance ' , $ q ->columns [1 ]->getValue ());
297+ $ this ->assertEquals ('POINT(2 1) ' , $ q ->bindings ['select ' ][0 ]);
280298 }
281299
282300 public function testScopeDistanceSphereValue ()
@@ -287,9 +305,11 @@ public function testScopeDistanceSphereValue()
287305 $ this ->assertInstanceOf (\Grimzy \LaravelMysqlSpatial \Eloquent \Builder::class, $ query );
288306 $ q = $ query ->getQuery ();
289307 $ this ->assertNotEmpty ($ q ->columns );
290- $ this ->assertContains ('* ' , $ q ->columns [0 ]);
308+ $ this ->assertNotEmpty ($ q ->bindings ['select ' ]);
309+ $ this ->assertEquals ('* ' , $ q ->columns [0 ]);
291310 $ this ->assertInstanceOf (\Illuminate \Database \Query \Expression::class, $ q ->columns [1 ]);
292- $ this ->assertContains ("st_distance_sphere(`point`, ST_GeomFromText('POINT(2 1)')) as distance " , $ q ->columns [1 ]->getValue ());
311+ $ this ->assertEquals ('st_distance_sphere(`point`, ST_GeomFromText(?)) as distance ' , $ q ->columns [1 ]->getValue ());
312+ $ this ->assertEquals ('POINT(2 1) ' , $ q ->bindings ['select ' ][0 ]);
293313 }
294314
295315 public function testScopeDistanceSphereValueWithSelect ()
@@ -300,9 +320,11 @@ public function testScopeDistanceSphereValueWithSelect()
300320 $ this ->assertInstanceOf (\Grimzy \LaravelMysqlSpatial \Eloquent \Builder::class, $ query );
301321 $ q = $ query ->getQuery ();
302322 $ this ->assertNotEmpty ($ q ->columns );
303- $ this ->assertContains ('some_column ' , $ q ->columns [0 ]);
323+ $ this ->assertNotEmpty ($ q ->bindings ['select ' ]);
324+ $ this ->assertEquals ('some_column ' , $ q ->columns [0 ]);
304325 $ this ->assertInstanceOf (\Illuminate \Database \Query \Expression::class, $ q ->columns [1 ]);
305- $ this ->assertContains ("st_distance_sphere(`point`, ST_GeomFromText('POINT(2 1)')) as distance " , $ q ->columns [1 ]->getValue ());
326+ $ this ->assertEquals ('st_distance_sphere(`point`, ST_GeomFromText(?)) as distance ' , $ q ->columns [1 ]->getValue ());
327+ $ this ->assertEquals ('POINT(2 1) ' , $ q ->bindings ['select ' ][0 ]);
306328 }
307329
308330 private function buildTestPolygon ()
@@ -327,7 +349,9 @@ public function testScopeComparison()
327349 $ this ->assertInstanceOf (\Grimzy \LaravelMysqlSpatial \Eloquent \Builder::class, $ query );
328350 $ q = $ query ->getQuery ();
329351 $ this ->assertNotEmpty ($ q ->wheres );
330- $ this ->assertContains ("st_within(`point`, ST_GeomFromText('POLYGON((1 1,2 1),(2 1,2 2),(2 2,1 1))')) " , $ q ->wheres [0 ]['sql ' ]);
352+ $ this ->assertNotEmpty ($ q ->bindings ['where ' ]);
353+ $ this ->assertContains ('st_within(`point`, ST_GeomFromText(?)) ' , $ q ->wheres [0 ]['sql ' ]);
354+ $ this ->assertEquals ('POLYGON((1 1,2 1),(2 1,2 2),(2 2,1 1)) ' , $ q ->bindings ['where ' ][0 ]);
331355 }
332356
333357 public function testScopeWithin ()
@@ -337,7 +361,9 @@ public function testScopeWithin()
337361 $ this ->assertInstanceOf (\Grimzy \LaravelMysqlSpatial \Eloquent \Builder::class, $ query );
338362 $ q = $ query ->getQuery ();
339363 $ this ->assertNotEmpty ($ q ->wheres );
340- $ this ->assertContains ("st_within(`point`, ST_GeomFromText('POLYGON((1 1,2 1),(2 1,2 2),(2 2,1 1))')) " , $ q ->wheres [0 ]['sql ' ]);
364+ $ this ->assertNotEmpty ($ q ->bindings ['where ' ]);
365+ $ this ->assertContains ('st_within(`point`, ST_GeomFromText(?)) ' , $ q ->wheres [0 ]['sql ' ]);
366+ $ this ->assertEquals ('POLYGON((1 1,2 1),(2 1,2 2),(2 2,1 1)) ' , $ q ->bindings ['where ' ][0 ]);
341367 }
342368
343369 public function testScopeCrosses ()
@@ -347,7 +373,9 @@ public function testScopeCrosses()
347373 $ this ->assertInstanceOf (\Grimzy \LaravelMysqlSpatial \Eloquent \Builder::class, $ query );
348374 $ q = $ query ->getQuery ();
349375 $ this ->assertNotEmpty ($ q ->wheres );
350- $ this ->assertContains ("st_crosses(`point`, ST_GeomFromText('POLYGON((1 1,2 1),(2 1,2 2),(2 2,1 1))')) " , $ q ->wheres [0 ]['sql ' ]);
376+ $ this ->assertNotEmpty ($ q ->bindings ['where ' ]);
377+ $ this ->assertContains ('st_crosses(`point`, ST_GeomFromText(?)) ' , $ q ->wheres [0 ]['sql ' ]);
378+ $ this ->assertEquals ('POLYGON((1 1,2 1),(2 1,2 2),(2 2,1 1)) ' , $ q ->bindings ['where ' ][0 ]);
351379 }
352380
353381 public function testScopeContains ()
@@ -357,7 +385,9 @@ public function testScopeContains()
357385 $ this ->assertInstanceOf (\Grimzy \LaravelMysqlSpatial \Eloquent \Builder::class, $ query );
358386 $ q = $ query ->getQuery ();
359387 $ this ->assertNotEmpty ($ q ->wheres );
360- $ this ->assertContains ("st_contains(`point`, ST_GeomFromText('POLYGON((1 1,2 1),(2 1,2 2),(2 2,1 1))')) " , $ q ->wheres [0 ]['sql ' ]);
388+ $ this ->assertNotEmpty ($ q ->bindings ['where ' ]);
389+ $ this ->assertContains ('st_contains(`point`, ST_GeomFromText(?)) ' , $ q ->wheres [0 ]['sql ' ]);
390+ $ this ->assertEquals ('POLYGON((1 1,2 1),(2 1,2 2),(2 2,1 1)) ' , $ q ->bindings ['where ' ][0 ]);
361391 }
362392
363393 public function testScopeDisjoint ()
@@ -367,7 +397,9 @@ public function testScopeDisjoint()
367397 $ this ->assertInstanceOf (\Grimzy \LaravelMysqlSpatial \Eloquent \Builder::class, $ query );
368398 $ q = $ query ->getQuery ();
369399 $ this ->assertNotEmpty ($ q ->wheres );
370- $ this ->assertContains ("st_disjoint(`point`, ST_GeomFromText('POLYGON((1 1,2 1),(2 1,2 2),(2 2,1 1))')) " , $ q ->wheres [0 ]['sql ' ]);
400+ $ this ->assertNotEmpty ($ q ->bindings ['where ' ]);
401+ $ this ->assertContains ('st_disjoint(`point`, ST_GeomFromText(?)) ' , $ q ->wheres [0 ]['sql ' ]);
402+ $ this ->assertEquals ('POLYGON((1 1,2 1),(2 1,2 2),(2 2,1 1)) ' , $ q ->bindings ['where ' ][0 ]);
371403 }
372404
373405 public function testScopeEquals ()
@@ -377,7 +409,9 @@ public function testScopeEquals()
377409 $ this ->assertInstanceOf (\Grimzy \LaravelMysqlSpatial \Eloquent \Builder::class, $ query );
378410 $ q = $ query ->getQuery ();
379411 $ this ->assertNotEmpty ($ q ->wheres );
380- $ this ->assertContains ("st_equals(`point`, ST_GeomFromText('POLYGON((1 1,2 1),(2 1,2 2),(2 2,1 1))')) " , $ q ->wheres [0 ]['sql ' ]);
412+ $ this ->assertNotEmpty ($ q ->bindings ['where ' ]);
413+ $ this ->assertContains ('st_equals(`point`, ST_GeomFromText(?)) ' , $ q ->wheres [0 ]['sql ' ]);
414+ $ this ->assertEquals ('POLYGON((1 1,2 1),(2 1,2 2),(2 2,1 1)) ' , $ q ->bindings ['where ' ][0 ]);
381415 }
382416
383417 public function testScopeIntersects ()
@@ -387,7 +421,9 @@ public function testScopeIntersects()
387421 $ this ->assertInstanceOf (\Grimzy \LaravelMysqlSpatial \Eloquent \Builder::class, $ query );
388422 $ q = $ query ->getQuery ();
389423 $ this ->assertNotEmpty ($ q ->wheres );
390- $ this ->assertContains ("st_intersects(`point`, ST_GeomFromText('POLYGON((1 1,2 1),(2 1,2 2),(2 2,1 1))')) " , $ q ->wheres [0 ]['sql ' ]);
424+ $ this ->assertNotEmpty ($ q ->bindings ['where ' ]);
425+ $ this ->assertContains ('st_intersects(`point`, ST_GeomFromText(?)) ' , $ q ->wheres [0 ]['sql ' ]);
426+ $ this ->assertEquals ('POLYGON((1 1,2 1),(2 1,2 2),(2 2,1 1)) ' , $ q ->bindings ['where ' ][0 ]);
391427 }
392428
393429 public function testScopeOverlaps ()
@@ -397,7 +433,9 @@ public function testScopeOverlaps()
397433 $ this ->assertInstanceOf (\Grimzy \LaravelMysqlSpatial \Eloquent \Builder::class, $ query );
398434 $ q = $ query ->getQuery ();
399435 $ this ->assertNotEmpty ($ q ->wheres );
400- $ this ->assertContains ("st_overlaps(`point`, ST_GeomFromText('POLYGON((1 1,2 1),(2 1,2 2),(2 2,1 1))')) " , $ q ->wheres [0 ]['sql ' ]);
436+ $ this ->assertNotEmpty ($ q ->bindings ['where ' ]);
437+ $ this ->assertContains ('st_overlaps(`point`, ST_GeomFromText(?)) ' , $ q ->wheres [0 ]['sql ' ]);
438+ $ this ->assertEquals ('POLYGON((1 1,2 1),(2 1,2 2),(2 2,1 1)) ' , $ q ->bindings ['where ' ][0 ]);
401439 }
402440
403441 public function testScopeDoesTouch ()
@@ -407,7 +445,9 @@ public function testScopeDoesTouch()
407445 $ this ->assertInstanceOf (\Grimzy \LaravelMysqlSpatial \Eloquent \Builder::class, $ query );
408446 $ q = $ query ->getQuery ();
409447 $ this ->assertNotEmpty ($ q ->wheres );
410- $ this ->assertContains ("st_touches(`point`, ST_GeomFromText('POLYGON((1 1,2 1),(2 1,2 2),(2 2,1 1))')) " , $ q ->wheres [0 ]['sql ' ]);
448+ $ this ->assertNotEmpty ($ q ->bindings ['where ' ]);
449+ $ this ->assertContains ('st_touches(`point`, ST_GeomFromText(?)) ' , $ q ->wheres [0 ]['sql ' ]);
450+ $ this ->assertEquals ('POLYGON((1 1,2 1),(2 1,2 2),(2 2,1 1)) ' , $ q ->bindings ['where ' ][0 ]);
411451 }
412452}
413453
0 commit comments