1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
class MapExtensionTest extends SapphireTest { |
4
|
|
|
protected static $fixture_file = 'mappable/tests/mapextensions.yml'; |
5
|
|
|
|
6
|
|
|
public function setUpOnce() { |
7
|
|
|
$this->requiredExtensions = array( |
8
|
|
|
'Member' => array('MapExtension') |
9
|
|
|
); |
10
|
|
|
parent::setupOnce(); |
11
|
|
|
} |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
public function testupdateCMSFields() { |
15
|
|
|
|
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
|
19
|
|
|
public function testGetMappableLatitude() { |
20
|
|
|
$instance = $this->getInstance(); |
21
|
|
|
$instance->Lat = 42.1; |
22
|
|
|
$instance->write(); |
23
|
|
|
$this->assertEquals( |
24
|
|
|
42.1, |
25
|
|
|
$instance->getMappableLatitude() |
26
|
|
|
); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
|
30
|
|
|
public function testGetMappableLongitude() { |
31
|
|
|
$instance = $this->getInstance(); |
32
|
|
|
$instance->Lon = 42.1; |
33
|
|
|
$this->assertEquals( |
34
|
|
|
42.1, |
35
|
|
|
$instance->getMappableLongitude() |
36
|
|
|
); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
|
40
|
|
|
public function testgetMappableMapContent() { |
41
|
|
|
|
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
|
45
|
|
|
public function testonBeforeWriteMapPinNotEdited() { |
46
|
|
|
$instance = $this->getInstance(); |
47
|
|
|
$this->Lat = 0; |
48
|
|
|
$this->Lon = 0; |
49
|
|
|
$instance->write(); |
50
|
|
|
$this->assertFalse($instance->MapPinEdited); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function testonBeforeWriteMapPinEdited() { |
54
|
|
|
$instance = $this->getInstance(); |
55
|
|
|
|
56
|
|
|
// north |
57
|
|
|
$this->showMapPinEdited($instance, 10, 0); |
58
|
|
|
|
59
|
|
|
// north west |
60
|
|
|
$this->showMapPinEdited($instance, 10, -10); |
61
|
|
|
|
62
|
|
|
// west |
63
|
|
|
$this->showMapPinEdited($instance, 0, -10); |
64
|
|
|
|
65
|
|
|
// south west |
66
|
|
|
$this->showMapPinEdited($instance, -10, -10); |
67
|
|
|
|
68
|
|
|
// south |
69
|
|
|
$this->showMapPinEdited($instance, -10, 0); |
70
|
|
|
|
71
|
|
|
// south east |
72
|
|
|
$this->showMapPinEdited($instance, -10, 10); |
73
|
|
|
|
74
|
|
|
// east |
75
|
|
|
$this->showMapPinEdited($instance, 0, 10); |
76
|
|
|
|
77
|
|
|
// north east |
78
|
|
|
$this->showMapPinEdited($instance, 10, 10); |
79
|
|
|
|
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
|
83
|
|
|
public function testgetMappableMapPin() { |
84
|
|
|
|
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
|
88
|
|
|
public function testHasGeoWest() { |
89
|
|
|
$instance = $this->getInstance(); |
90
|
|
|
$instance->Lon = -20; |
91
|
|
|
$this->assertTrue($instance->HasGeo()); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
public function testHasGeoEast() { |
95
|
|
|
$instance = $this->getInstance(); |
96
|
|
|
$instance->Lon = 20; |
97
|
|
|
$this->assertTrue($instance->HasGeo()); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
public function testHasGeoNorth() { |
101
|
|
|
$instance = $this->getInstance(); |
102
|
|
|
$instance->Lat = 20; |
103
|
|
|
$this->assertTrue($instance->HasGeo()); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
public function testHasGeoNorthWest() { |
107
|
|
|
$instance = $this->getInstance(); |
108
|
|
|
$instance->Lat = 20; |
109
|
|
|
$instance->Lon = -20; |
110
|
|
|
$this->assertTrue($instance->HasGeo()); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
public function testHasGeoNortEast() { |
114
|
|
|
$instance = $this->getInstance(); |
115
|
|
|
$instance->Lat = 20; |
116
|
|
|
$instance->Lon = 20; |
117
|
|
|
$this->assertTrue($instance->HasGeo()); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
public function testHasGeoSouth() { |
121
|
|
|
$instance = $this->getInstance(); |
122
|
|
|
$instance->Lat = -20; |
123
|
|
|
$this->assertTrue($instance->HasGeo()); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
public function testHasGeoSouthWest() { |
127
|
|
|
$instance = $this->getInstance(); |
128
|
|
|
$instance->Lat = -20; |
129
|
|
|
$instance->Lon = -20; |
130
|
|
|
$this->assertTrue($instance->HasGeo()); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
public function testHasGeoSouthEast() { |
134
|
|
|
$instance = $this->getInstance(); |
135
|
|
|
$instance->Lat = -20; |
136
|
|
|
$instance->Lon = 20; |
137
|
|
|
$this->assertTrue($instance->HasGeo()); |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
public function testHasGeoOrigin() { |
141
|
|
|
$instance = $this->getInstance(); |
142
|
|
|
$instance->Lat = 0; |
143
|
|
|
$instance->Lon = 0; |
144
|
|
|
$this->assertFalse($instance->HasGeo()); |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
public function testHasGeoOriginMapLayerExtension() { |
148
|
|
|
$instance = $this->getInstance(); |
149
|
|
|
$instance->Lat = 0; |
150
|
|
|
$instance->Lon = 0; |
151
|
|
|
$this->assertFalse($instance->HasGeo()); |
152
|
|
|
Page::add_extension('MapLayerExtension'); |
153
|
|
|
Page::remove_extension('MapLayerExtension'); |
154
|
|
|
$this->markTestSkipped('TODO'); |
|
|
|
|
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
public function testHasGeoOriginPointsOfInterestLayers() { |
158
|
|
|
$instance = $this->getInstance(); |
159
|
|
|
$instance->Lat = 0; |
160
|
|
|
$instance->Lon = 0; |
161
|
|
|
$this->assertFalse($instance->HasGeo()); |
162
|
|
|
$this->markTestSkipped('TODO'); |
|
|
|
|
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
public function testBasicMap() { |
166
|
|
|
|
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
|
170
|
|
|
public function testGetMapField() { |
171
|
|
|
$instance = $this->getInstance(); |
172
|
|
|
$this->Lat = 37.1; |
173
|
|
|
$this->Lon = 28; |
174
|
|
|
$this->Zoom = 12; |
175
|
|
|
$mapField = $instance->getMapField(); |
176
|
|
|
$this->assertInstanceOf('LatLongField', $mapField); |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
|
180
|
|
|
public function testUseCompressedAssets() { |
181
|
|
|
|
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
|
185
|
|
|
private function getInstance() { |
186
|
|
|
$instance = new Member(); |
187
|
|
|
return $instance; |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
/** |
191
|
|
|
* @param integer $lat |
192
|
|
|
* @param integer $lon |
193
|
|
|
*/ |
194
|
|
|
private function showMapPinEdited(&$instance, $lat, $lon) { |
195
|
|
|
$instance->Lat = $lat; |
196
|
|
|
$instance->Long = $lon; |
197
|
|
|
$instance->write(); |
198
|
|
|
$this->assertTrue($instance->MapPinEdited); |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
|
202
|
|
|
|
203
|
|
|
} |
204
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.