|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
class PointOfInterestTest extends SapphireTest |
|
4
|
|
|
{ |
|
5
|
|
|
protected static $fixture_file = 'mappable-poi/tests/pointsofinterest.yml'; |
|
6
|
|
|
|
|
7
|
1 |
|
public function testUpdateCMSFields() |
|
8
|
|
|
{ |
|
9
|
1 |
|
$poi = new PointOfInterest(); |
|
10
|
1 |
|
$fields = $poi->getCMSFields(); |
|
11
|
1 |
|
$tab = $fields->findOrMakeTab('Root.Main'); |
|
12
|
1 |
|
$fields = $tab->FieldList(); |
|
13
|
1 |
|
$names = array(); |
|
14
|
1 |
|
foreach ($fields as $field) { |
|
15
|
1 |
|
$names[] = $field->getName(); |
|
16
|
1 |
|
} |
|
17
|
|
|
|
|
18
|
1 |
|
$this->assertEquals(array('Name'), $names); |
|
19
|
1 |
|
} |
|
20
|
|
|
|
|
21
|
2 |
|
public function testShowGuideMarkers() |
|
22
|
|
|
{ |
|
23
|
1 |
|
$layer = $this->objFromFixture('PointsOfInterestLayer', 'BTS'); |
|
24
|
1 |
|
error_log('LAYER: '.$layer->Name); |
|
25
|
1 |
|
$pois = $layer->PointsOfInterest(); |
|
26
|
1 |
|
$poi = $pois->first(); |
|
27
|
|
|
|
|
28
|
|
|
// guidemarkers off, expect null returned |
|
29
|
1 |
|
$layer->ShowGuideMarkers = 0; |
|
30
|
1 |
|
$layer->write(); |
|
31
|
1 |
|
$poi->getCMSFields(); |
|
32
|
2 |
|
$guidepoints = $poi->getMapField()->getGuidePoints(); |
|
33
|
1 |
|
$this->assertNull($guidepoints); |
|
34
|
|
|
|
|
35
|
|
|
// guidemarkers on, convert datalist to an array of coordinates |
|
36
|
1 |
|
$layer->ShowGuideMarkers = 1; |
|
37
|
1 |
|
$layer->write(); |
|
38
|
1 |
|
$poi->getCMSFields(); |
|
39
|
1 |
|
$guidepoints = $poi->getMapField()->getGuidePoints(); |
|
40
|
1 |
|
$expected = array(); |
|
41
|
1 |
|
$coors = array(); |
|
42
|
1 |
|
foreach ($guidepoints as $gp) { |
|
43
|
1 |
|
$coors[] = array($gp->Lat, $gp->Lon); |
|
44
|
1 |
|
} |
|
45
|
|
|
|
|
46
|
|
|
$expected = array( |
|
47
|
1 |
|
array(13.77965803301, 100.54461523531), |
|
48
|
1 |
|
array(13.744081610619, 100.54311513861), |
|
49
|
1 |
|
array(13.802594511242, 100.55379467004), |
|
50
|
1 |
|
array(13.74054138487, 100.55545772112), |
|
51
|
1 |
|
array(13.756924089277, 100.53381164654), |
|
52
|
1 |
|
array(13.751846080459, 100.53157277536), |
|
53
|
1 |
|
array(13.772614550915, 100.54209276599), |
|
54
|
1 |
|
array(13.793846082833, 100.54974883766), |
|
55
|
1 |
|
array(13.762764662241, 100.53706848861), |
|
56
|
1 |
|
); |
|
57
|
1 |
|
$this->assertEquals($expected, $coors); |
|
58
|
1 |
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|