]> git.openstreetmap.org Git - nominatim.git/commitdiff
return place_id link to details when not an OSM object
authorSarah Hoffmann <lonvia@denofr.de>
Sun, 9 Feb 2020 14:45:38 +0000 (15:45 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Sun, 9 Feb 2020 14:45:38 +0000 (15:45 +0100)
Stop-gap solution to find the right object for Tiger and
interpolation objects.

lib/output.php
test/php/Nominatim/OutputTest.php [new file with mode: 0644]

index 9d4b7502c855044c6859bae36f1d291897ab20c7..8715efbc49b61d5fa83aa7d37c9f4d27955634dc 100644 (file)
@@ -48,5 +48,5 @@ function detailsPermaLink($aFeature, $sRefText = false)
         $sLabel = $sRefText ? $sRefText : $sOSMType.' '.$aFeature['osm_id'];
         return '<a href="details.php?osmtype='.$aFeature['osm_type'].'&osmid='.$aFeature['osm_id'].'&class='.$aFeature['class'].'">'.$sLabel.'</a>';
     }
-    return '';
+    return detailsLink($aFeature, $sRefText);
 }
diff --git a/test/php/Nominatim/OutputTest.php b/test/php/Nominatim/OutputTest.php
new file mode 100644 (file)
index 0000000..ce9bfa3
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+
+namespace Nominatim;
+
+require_once(CONST_BasePath.'/lib/output.php');
+
+class OutputTest extends \PHPUnit\Framework\TestCase
+{
+    public function testDetailsPermaLinkNode()
+    {
+        $aFeature = array('osm_type' => 'N', 'osm_id'=> 38274, 'class' => 'place');
+        $this->assertSame(
+                detailsPermaLink($aFeature),
+                '<a href="details.php?osmtype=N&osmid=38274&class=place">node 38274</a>'
+                );
+    }
+
+    public function testDetailsPermaLinkWay()
+    {
+        $aFeature = array('osm_type' => 'W', 'osm_id'=> 65, 'class' => 'highway');
+        $this->assertSame(
+                detailsPermaLink($aFeature),
+                '<a href="details.php?osmtype=W&osmid=65&class=highway">way 65</a>'
+                );
+    }
+
+    public function testDetailsPermaLinkRelation()
+    {
+        $aFeature = array('osm_type' => 'R', 'osm_id'=> 9908, 'class' => 'waterway');
+        $this->assertSame(
+                detailsPermaLink($aFeature),
+                '<a href="details.php?osmtype=R&osmid=9908&class=waterway">relation 9908</a>'
+                );
+    }
+
+    public function testDetailsPermaLinkTiger()
+    {
+        $aFeature = array('osm_type' => 'T', 'osm_id'=> 2, 'place_id' => 334);
+        $this->assertSame(
+                detailsPermaLink($aFeature, 'foo'),
+                '<a href="details.php?place_id=334">foo</a>'
+                );
+    }
+
+    public function testDetailsPermaLinkInterpolation()
+    {
+        $aFeature = array('osm_type' => 'I', 'osm_id'=> 400, 'place_id' => 3);
+        $this->assertSame(
+                detailsPermaLink($aFeature, 'foo'),
+                '<a href="details.php?place_id=3">foo</a>'
+                );
+    }
+
+
+
+
+}