5 require_once(CONST_LibDir.'/SearchContext.php');
 
   7 class SearchContextTest extends \PHPUnit\Framework\TestCase
 
  12     protected function setUp(): void
 
  14         $this->oCtx = new SearchContext();
 
  17     public function testHasNearPoint()
 
  19         $this->assertFalse($this->oCtx->hasNearPoint());
 
  20         $this->oCtx->setNearPoint(0, 0);
 
  21         $this->assertTrue($this->oCtx->hasNearPoint());
 
  24     public function testNearRadius()
 
  26         $this->oCtx->setNearPoint(1, 1);
 
  27         $this->assertEquals(0.1, $this->oCtx->nearRadius());
 
  28         $this->oCtx->setNearPoint(1, 1, 0.338);
 
  29         $this->assertEquals(0.338, $this->oCtx->nearRadius());
 
  32     public function testWithinSQL()
 
  34         $this->oCtx->setNearPoint(0.1, 23, 1);
 
  37             'ST_DWithin(foo, ST_SetSRID(ST_Point(23,0.1),4326), 1.000000)',
 
  38             $this->oCtx->withinSQL('foo')
 
  42     public function testDistanceSQL()
 
  44         $this->oCtx->setNearPoint(0.1, 23, 1);
 
  47             'ST_Distance(ST_SetSRID(ST_Point(23,0.1),4326), foo)',
 
  48             $this->oCtx->distanceSQL('foo')
 
  52     public function testSetViewboxFromBox()
 
  54         $viewbox = array(30, 20, 40, 50);
 
  55         $this->oCtx->setViewboxFromBox($viewbox, true);
 
  57             'ST_SetSRID(ST_MakeBox2D(ST_Point(30.000000,20.000000),ST_Point(40.000000,50.000000)),4326)',
 
  58             $this->oCtx->sqlViewboxSmall
 
  63             'ST_SetSRID(ST_MakeBox2D(ST_Point(50.000000,80.000000),ST_Point(20.000000,-10.000000)),4326)',
 
  64             $this->oCtx->sqlViewboxLarge
 
  68         $viewbox = array(-1.5, -2, 1.5, 2);
 
  69         $this->oCtx->setViewboxFromBox($viewbox, true);
 
  71             'ST_SetSRID(ST_MakeBox2D(ST_Point(-1.500000,-2.000000),ST_Point(1.500000,2.000000)),4326)',
 
  72             $this->oCtx->sqlViewboxSmall
 
  77             'ST_SetSRID(ST_MakeBox2D(ST_Point(4.500000,6.000000),ST_Point(-4.500000,-6.000000)),4326)',
 
  78             $this->oCtx->sqlViewboxLarge