]> git.openstreetmap.org Git - nominatim.git/blob - test/php/Nominatim/ClassTypesTest.php
adapt php tests
[nominatim.git] / test / php / Nominatim / ClassTypesTest.php
1 <?php
2
3 namespace Nominatim;
4
5 require_once(CONST_BasePath.'/lib/ClassTypes.php');
6
7 class ClassTypesTest extends \PHPUnit\Framework\TestCase
8 {
9     public function testGetLabelTag()
10     {
11         $aPlace = array('class' => 'boundary', 'type' => 'administrative',
12                         'rank_address' => '4', 'place_type' => 'city');
13         $this->assertEquals('city', ClassTypes\getLabelTag($aPlace));
14
15         $aPlace = array('class' => 'boundary', 'type' => 'administrative',
16                         'rank_address' => '10');
17         $this->assertEquals('state_district', ClassTypes\getLabelTag($aPlace));
18
19         $aPlace = array('class' => 'boundary', 'type' => 'administrative');
20         $this->assertEquals('administrative', ClassTypes\getLabelTag($aPlace));
21
22         $aPlace = array('class' => 'place', 'type' => 'hamlet',
23                         'rank_address' => '20');
24         $this->assertEquals('hamlet', ClassTypes\getLabelTag($aPlace));
25
26         $aPlace = array('class' => 'highway', 'type' => 'residential',
27                         'rank_address' => '26');
28         $this->assertEquals('road', ClassTypes\getLabelTag($aPlace));
29
30         $aPlace = array('class' => 'place', 'type' => 'house_number',
31                         'rank_address' => '30');
32         $this->assertEquals('house_number', ClassTypes\getLabelTag($aPlace));
33
34         $aPlace = array('class' => 'amenity', 'type' => 'prison',
35                         'rank_address' => '30');
36         $this->assertEquals('amenity', ClassTypes\getLabelTag($aPlace));
37     }
38
39     public function testGetLabel()
40     {
41         $aPlace = array('class' => 'boundary', 'type' => 'administrative',
42                         'rank_address' => '4', 'place_type' => 'city');
43         $this->assertEquals('City', ClassTypes\getLabel($aPlace));
44
45         $aPlace = array('class' => 'boundary', 'type' => 'administrative',
46                         'rank_address' => '10');
47         $this->assertEquals('State District', ClassTypes\getLabel($aPlace));
48
49         $aPlace = array('class' => 'boundary', 'type' => 'administrative');
50         $this->assertEquals('Administrative', ClassTypes\getLabel($aPlace));
51
52         $aPlace = array('class' => 'amenity', 'type' => 'prison');
53         $this->assertEquals('Prison', ClassTypes\getLabel($aPlace));
54
55         $aPlace = array('class' => 'amenity', 'type' => 'foobar');
56         $this->assertNull(ClassTypes\getLabel($aPlace));
57     }
58
59     public function testGetBoundaryLabel()
60     {
61         $this->assertEquals('City', ClassTypes\getBoundaryLabel(8, null));
62         $this->assertEquals('Administrative', ClassTypes\getBoundaryLabel(18, null));
63         $this->assertEquals('None', ClassTypes\getBoundaryLabel(18, null, 'None'));
64         $this->assertEquals('State', ClassTypes\getBoundaryLabel(4, 'de', 'None'));
65     }
66
67     public function testGetDefRadius()
68     {
69         $aResult = array('class' => '', 'type' => '');
70         $this->assertEquals(0.00005, ClassTypes\getDefRadius($aResult));
71
72         $aResult = array('class' => 'place', 'type' => 'country');
73         $this->assertEquals(7, ClassTypes\getDefRadius($aResult));
74     }
75
76     public function testGetIcon()
77     {
78         $aResult = array('class' => '', 'type' => '');
79         $this->assertNull(ClassTypes\getIcon($aResult));
80
81         $aResult = array('class' => 'place', 'type' => 'airport');
82         $this->assertEquals('transport_airport2', ClassTypes\getIcon($aResult));
83     }
84
85     public function testGetImportance()
86     {
87         $aResult = array('class' => '', 'type' => '');
88         $this->assertNull(ClassTypes\getImportance($aResult));
89
90         $aResult = array('class' => 'place', 'type' => 'airport');
91         $this->assertGreaterThan(0, ClassTypes\getImportance($aResult));
92     }
93 }