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