5 require_once(CONST_BasePath.'/lib/ClassTypes.php');
7 class ClassTypesTest extends \PHPUnit\Framework\TestCase
9 public function testGetLabelTag()
11 $aPlace = array('class' => 'boundary', 'type' => 'administrative',
12 'rank_address' => '4', 'place_type' => 'city');
13 $this->assertEquals('city', ClassTypes\getLabelTag($aPlace));
15 $aPlace = array('class' => 'boundary', 'type' => 'administrative',
16 'rank_address' => '10');
17 $this->assertEquals('state_district', ClassTypes\getLabelTag($aPlace));
19 $aPlace = array('class' => 'boundary', 'type' => 'administrative');
20 $this->assertEquals('administrative', ClassTypes\getLabelTag($aPlace));
22 $aPlace = array('class' => 'place', 'type' => 'hamlet', 'rank_address' => '20');
23 $this->assertEquals('hamlet', ClassTypes\getLabelTag($aPlace));
25 $aPlace = array('class' => 'highway', 'type' => 'residential',
26 'rank_address' => '26');
27 $this->assertEquals('road', ClassTypes\getLabelTag($aPlace));
29 $aPlace = array('class' => 'place', 'type' => 'house_number',
30 'rank_address' => '30');
31 $this->assertEquals('house_number', ClassTypes\getLabelTag($aPlace));
33 $aPlace = array('class' => 'amenity', 'type' => 'prison',
34 'rank_address' => '30');
35 $this->assertEquals('amenity', ClassTypes\getLabelTag($aPlace));
38 public function testGetLabel()
40 $aPlace = array('class' => 'boundary', 'type' => 'administrative',
41 'rank_address' => '4', 'place_type' => 'city');
42 $this->assertEquals('City', ClassTypes\getLabel($aPlace));
44 $aPlace = array('class' => 'boundary', 'type' => 'administrative',
45 'rank_address' => '10');
46 $this->assertEquals('State District', ClassTypes\getLabel($aPlace));
48 $aPlace = array('class' => 'boundary', 'type' => 'administrative');
49 $this->assertEquals('Administrative', ClassTypes\getLabel($aPlace));
51 $aPlace = array('class' => 'amenity', 'type' => 'prison');
52 $this->assertEquals('Prison', ClassTypes\getLabel($aPlace));
54 $aPlace = array('class' => 'amenity', 'type' => 'foobar');
55 $this->assertNull(ClassTypes\getLabel($aPlace));
58 public function testGetBoundaryLabel()
60 $this->assertEquals('City', ClassTypes\getBoundaryLabel(8, null));
61 $this->assertEquals('Administrative', ClassTypes\getBoundaryLabel(18, null));
62 $this->assertEquals('None', ClassTypes\getBoundaryLabel(18, null, 'None'));
63 $this->assertEquals('State', ClassTypes\getBoundaryLabel(4, 'de', 'None'));
64 $this->assertEquals('County', ClassTypes\getBoundaryLabel(4, 'se', 'None'));
65 $this->assertEquals('Municipality', ClassTypes\getBoundaryLabel(7, 'se', 'None'));
68 public function testGetDefRadius()
70 $aResult = array('class' => '', 'type' => '');
71 $this->assertEquals(0.00005, ClassTypes\getDefRadius($aResult));
73 $aResult = array('class' => 'place', 'type' => 'country');
74 $this->assertEquals(7, ClassTypes\getDefRadius($aResult));
77 public function testGetIcon()
79 $aResult = array('class' => '', 'type' => '');
80 $this->assertNull(ClassTypes\getIcon($aResult));
82 $aResult = array('class' => 'place', 'type' => 'airport');
83 $this->assertEquals('transport_airport2', ClassTypes\getIcon($aResult));
86 public function testGetImportance()
88 $aResult = array('class' => '', 'type' => '');
89 $this->assertNull(ClassTypes\getImportance($aResult));
91 $aResult = array('class' => 'place', 'type' => 'airport');
92 $this->assertGreaterThan(0, ClassTypes\getImportance($aResult));