5 @define('CONST_BasePath', '../../');
7 require_once '../../lib/SearchContext.php';
9 class SearchContextTest extends \PHPUnit_Framework_TestCase
13 protected function setUp()
15 $this->oCtx = new SearchContext();
18 public function testHasNearPoint()
20 $this->assertFalse($this->oCtx->hasNearPoint());
21 $this->oCtx->setNearPoint(0, 0);
22 $this->assertTrue($this->oCtx->hasNearPoint());
25 public function testNearRadius()
27 $this->oCtx->setNearPoint(1, 1);
28 $this->assertEquals(0.1, $this->oCtx->nearRadius());
29 $this->oCtx->setNearPoint(1, 1, 0.338);
30 $this->assertEquals(0.338, $this->oCtx->nearRadius());
33 public function testWithinSQL()
35 $this->oCtx->setNearPoint(0.1, 23, 1);
38 'ST_DWithin(foo, ST_SetSRID(ST_Point(23,0.1),4326), 1.000000)',
39 $this->oCtx->withinSQL('foo')
43 public function testDistanceSQL()
45 $this->oCtx->setNearPoint(0.1, 23, 1);
48 'ST_Distance(ST_SetSRID(ST_Point(23,0.1),4326), foo)',
49 $this->oCtx->distanceSQL('foo')