]> git.openstreetmap.org Git - nominatim.git/blob - test/php/Nominatim/SearchContextTest.php
phpcs fixes. Mostly spacing and single quotes
[nominatim.git] / test / php / Nominatim / SearchContextTest.php
1 <?php
2
3 namespace Nominatim;
4
5 @define('CONST_BasePath', '../../');
6
7 require_once '../../lib/SearchContext.php';
8
9 class SearchContextTest extends \PHPUnit_Framework_TestCase
10 {
11     private $oCtx;
12
13
14     protected function setUp()
15     {
16         $this->oCtx = new SearchContext();
17     }
18
19     public function testHasNearPoint()
20     {
21         $this->assertFalse($this->oCtx->hasNearPoint());
22         $this->oCtx->setNearPoint(0, 0);
23         $this->assertTrue($this->oCtx->hasNearPoint());
24     }
25
26     public function testNearRadius()
27     {
28         $this->oCtx->setNearPoint(1, 1);
29         $this->assertEquals(0.1, $this->oCtx->nearRadius());
30         $this->oCtx->setNearPoint(1, 1, 0.338);
31         $this->assertEquals(0.338, $this->oCtx->nearRadius());
32     }
33
34     public function testWithinSQL()
35     {
36         $this->oCtx->setNearPoint(0.1, 23, 1);
37
38         $this->assertEquals(
39             'ST_DWithin(foo, ST_SetSRID(ST_Point(23,0.1),4326), 1.000000)',
40             $this->oCtx->withinSQL('foo')
41         );
42     }
43
44     public function testDistanceSQL()
45     {
46         $this->oCtx->setNearPoint(0.1, 23, 1);
47
48         $this->assertEquals(
49             'ST_Distance(ST_SetSRID(ST_Point(23,0.1),4326), foo)',
50             $this->oCtx->distanceSQL('foo')
51         );
52     }
53 }