]> git.openstreetmap.org Git - nominatim.git/blob - test/php/Nominatim/OutputTest.php
Merge branch 'separate-compilation' of https://github.com/eyusupov/Nominatim into...
[nominatim.git] / test / php / Nominatim / OutputTest.php
1 <?php
2
3 namespace Nominatim;
4
5 require_once(CONST_BasePath.'/lib/output.php');
6
7 class OutputTest extends \PHPUnit\Framework\TestCase
8 {
9     public function testDetailsPermaLinkNode()
10     {
11         $aFeature = array('osm_type' => 'N', 'osm_id'=> 38274, 'class' => 'place');
12         $this->assertSame(
13             detailsPermaLink($aFeature),
14             '<a href="details.php?osmtype=N&osmid=38274&class=place">node 38274</a>'
15         );
16     }
17
18     public function testDetailsPermaLinkWay()
19     {
20         $aFeature = array('osm_type' => 'W', 'osm_id'=> 65, 'class' => 'highway');
21         $this->assertSame(
22             detailsPermaLink($aFeature),
23             '<a href="details.php?osmtype=W&osmid=65&class=highway">way 65</a>'
24         );
25     }
26
27     public function testDetailsPermaLinkRelation()
28     {
29         $aFeature = array('osm_type' => 'R', 'osm_id'=> 9908, 'class' => 'waterway');
30         $this->assertSame(
31             detailsPermaLink($aFeature),
32             '<a href="details.php?osmtype=R&osmid=9908&class=waterway">relation 9908</a>'
33         );
34     }
35
36     public function testDetailsPermaLinkTiger()
37     {
38         $aFeature = array('osm_type' => 'T', 'osm_id'=> 2, 'place_id' => 334);
39         $this->assertSame(
40             detailsPermaLink($aFeature, 'foo'),
41             '<a href="details.php?place_id=334">foo</a>'
42         );
43     }
44
45     public function testDetailsPermaLinkInterpolation()
46     {
47         $aFeature = array('osm_type' => 'I', 'osm_id'=> 400, 'place_id' => 3);
48         $this->assertSame(
49             detailsPermaLink($aFeature, 'foo'),
50             '<a href="details.php?place_id=3">foo</a>'
51         );
52     }
53
54     public function testDetailsPermaLinkWithExtraPropertiesNode()
55     {
56         $aFeature = array('osm_type' => 'N', 'osm_id'=> 2, 'class' => 'amenity');
57         $this->assertSame(
58             detailsPermaLink($aFeature, 'something', 'class="xtype"'),
59             '<a class="xtype" href="details.php?osmtype=N&osmid=2&class=amenity">something</a>'
60         );
61     }
62
63     public function testDetailsPermaLinkWithExtraPropertiesTiger()
64     {
65         $aFeature = array('osm_type' => 'T', 'osm_id'=> 5, 'place_id' => 46);
66         $this->assertSame(
67             detailsPermaLink($aFeature, 'something', 'class="xtype"'),
68             '<a class="xtype" href="details.php?place_id=46">something</a>'
69         );
70     }
71 }