@@ -422,6 +422,64 @@ public function testNearWithGeoJsonPoint($point, array $expected): void
422
422
self ::assertEquals (['$near ' => $ expected ], $ expr ->getQuery ());
423
423
}
424
424
425
+ public function testNearWithGeoJsonPointAndMinDistance (): void
426
+ {
427
+ $ expr = $ this ->createExpr ();
428
+
429
+ $ coordinates = [1 , 2 ];
430
+ $ point = new Point ($ coordinates );
431
+
432
+ self ::assertSame ($ expr , $ expr ->near ($ point , null , 5 ));
433
+ self ::assertEquals (
434
+ [
435
+ '$near ' => [
436
+ '$geometry ' => ['type ' => 'Point ' , 'coordinates ' => $ coordinates ],
437
+ '$minDistance ' => 5 ,
438
+ ],
439
+ ],
440
+ $ expr ->getQuery (),
441
+ );
442
+ }
443
+
444
+ public function testNearWithGeoJsonPointAndMaxDistance (): void
445
+ {
446
+ $ expr = $ this ->createExpr ();
447
+
448
+ $ coordinates = [1 , 2 ];
449
+ $ point = new Point ($ coordinates );
450
+
451
+ self ::assertSame ($ expr , $ expr ->near ($ point , null , null , 10 ));
452
+ self ::assertEquals (
453
+ [
454
+ '$near ' => [
455
+ '$geometry ' => ['type ' => 'Point ' , 'coordinates ' => $ coordinates ],
456
+ '$maxDistance ' => 10 ,
457
+ ],
458
+ ],
459
+ $ expr ->getQuery (),
460
+ );
461
+ }
462
+
463
+ public function testNearWithGeoJsonPointAndMinAndMaxDistance (): void
464
+ {
465
+ $ expr = $ this ->createExpr ();
466
+
467
+ $ coordinates = [1 , 2 ];
468
+ $ point = new Point ($ coordinates );
469
+
470
+ self ::assertSame ($ expr , $ expr ->near ($ point , null , 5 , 10 ));
471
+ self ::assertEquals (
472
+ [
473
+ '$near ' => [
474
+ '$geometry ' => ['type ' => 'Point ' , 'coordinates ' => $ coordinates ],
475
+ '$minDistance ' => 5 ,
476
+ '$maxDistance ' => 10 ,
477
+ ],
478
+ ],
479
+ $ expr ->getQuery (),
480
+ );
481
+ }
482
+
425
483
public function testNearWithLegacyCoordinates (): void
426
484
{
427
485
$ expr = $ this ->createExpr ();
@@ -430,6 +488,30 @@ public function testNearWithLegacyCoordinates(): void
430
488
self ::assertEquals (['$near ' => [1 , 2 ]], $ expr ->getQuery ());
431
489
}
432
490
491
+ public function testNearWithLegacyCoordinatesAndMinDistance (): void
492
+ {
493
+ $ expr = $ this ->createExpr ();
494
+
495
+ self ::assertSame ($ expr , $ expr ->near (1 , 2 , 5 ));
496
+ self ::assertEquals (['$near ' => [1 , 2 ], '$minDistance ' => 5 ], $ expr ->getQuery ());
497
+ }
498
+
499
+ public function testNearWithLegacyCoordinatesAndMaxDistance (): void
500
+ {
501
+ $ expr = $ this ->createExpr ();
502
+
503
+ self ::assertSame ($ expr , $ expr ->near (1 , 2 , null , 10 ));
504
+ self ::assertEquals (['$near ' => [1 , 2 ], '$maxDistance ' => 10 ], $ expr ->getQuery ());
505
+ }
506
+
507
+ public function testNearWithLegacyCoordinatesAndMinAndMaxDistance (): void
508
+ {
509
+ $ expr = $ this ->createExpr ();
510
+
511
+ self ::assertSame ($ expr , $ expr ->near (1 , 2 , 5 , 10 ));
512
+ self ::assertEquals (['$near ' => [1 , 2 ], '$minDistance ' => 5 , '$maxDistance ' => 10 ], $ expr ->getQuery ());
513
+ }
514
+
433
515
/**
434
516
* @param Point|array<string, mixed> $point
435
517
* @param array<string, mixed> $expected
@@ -443,6 +525,64 @@ public function testNearSphereWithGeoJsonPoint($point, array $expected): void
443
525
self ::assertEquals (['$nearSphere ' => $ expected ], $ expr ->getQuery ());
444
526
}
445
527
528
+ public function testNearSphereWithGeoJsonPointAndMinDistance (): void
529
+ {
530
+ $ expr = $ this ->createExpr ();
531
+
532
+ $ coordinates = [1 , 2 ];
533
+ $ point = new Point ($ coordinates );
534
+
535
+ self ::assertSame ($ expr , $ expr ->nearSphere ($ point , null , 5 ));
536
+ self ::assertEquals (
537
+ [
538
+ '$nearSphere ' => [
539
+ '$geometry ' => ['type ' => 'Point ' , 'coordinates ' => $ coordinates ],
540
+ '$minDistance ' => 5 ,
541
+ ],
542
+ ],
543
+ $ expr ->getQuery (),
544
+ );
545
+ }
546
+
547
+ public function testNearSphereWithGeoJsonPointAndMaxDistance (): void
548
+ {
549
+ $ expr = $ this ->createExpr ();
550
+
551
+ $ coordinates = [1 , 2 ];
552
+ $ point = new Point ($ coordinates );
553
+
554
+ self ::assertSame ($ expr , $ expr ->nearSphere ($ point , null , null , 10 ));
555
+ self ::assertEquals (
556
+ [
557
+ '$nearSphere ' => [
558
+ '$geometry ' => ['type ' => 'Point ' , 'coordinates ' => $ coordinates ],
559
+ '$maxDistance ' => 10 ,
560
+ ],
561
+ ],
562
+ $ expr ->getQuery (),
563
+ );
564
+ }
565
+
566
+ public function testNearSphereWithGeoJsonPointAndMinAndMaxDistance (): void
567
+ {
568
+ $ expr = $ this ->createExpr ();
569
+
570
+ $ coordinates = [1 , 2 ];
571
+ $ point = new Point ($ coordinates );
572
+
573
+ self ::assertSame ($ expr , $ expr ->nearSphere ($ point , null , 5 , 10 ));
574
+ self ::assertEquals (
575
+ [
576
+ '$nearSphere ' => [
577
+ '$geometry ' => ['type ' => 'Point ' , 'coordinates ' => $ coordinates ],
578
+ '$minDistance ' => 5 ,
579
+ '$maxDistance ' => 10 ,
580
+ ],
581
+ ],
582
+ $ expr ->getQuery (),
583
+ );
584
+ }
585
+
446
586
public function testNearSphereWithLegacyCoordinates (): void
447
587
{
448
588
$ expr = $ this ->createExpr ();
@@ -451,6 +591,30 @@ public function testNearSphereWithLegacyCoordinates(): void
451
591
self ::assertEquals (['$nearSphere ' => [1 , 2 ]], $ expr ->getQuery ());
452
592
}
453
593
594
+ public function testNearSphereWithLegacyCoordinatesAndMinDistance (): void
595
+ {
596
+ $ expr = $ this ->createExpr ();
597
+
598
+ self ::assertSame ($ expr , $ expr ->nearSphere (1 , 2 , 5 ));
599
+ self ::assertEquals (['$nearSphere ' => [1 , 2 ], '$minDistance ' => 5 ], $ expr ->getQuery ());
600
+ }
601
+
602
+ public function testNearSphereWithLegacyCoordinatesAndMaxDistance (): void
603
+ {
604
+ $ expr = $ this ->createExpr ();
605
+
606
+ self ::assertSame ($ expr , $ expr ->nearSphere (1 , 2 , null , 10 ));
607
+ self ::assertEquals (['$nearSphere ' => [1 , 2 ], '$maxDistance ' => 10 ], $ expr ->getQuery ());
608
+ }
609
+
610
+ public function testNearSphereWithLegacyCoordinatesAndMinAndMaxDistance (): void
611
+ {
612
+ $ expr = $ this ->createExpr ();
613
+
614
+ self ::assertSame ($ expr , $ expr ->nearSphere (1 , 2 , 5 , 10 ));
615
+ self ::assertEquals (['$nearSphere ' => [1 , 2 ], '$minDistance ' => 5 , '$maxDistance ' => 10 ], $ expr ->getQuery ());
616
+ }
617
+
454
618
public function testPullWithValue (): void
455
619
{
456
620
$ expr = $ this ->createExpr ();
0 commit comments