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 testHasGeoMapLayers() { |
89
|
|
|
Member::add_extension('MapLayerExtension'); |
90
|
|
|
$instance = $this->getInstance(); |
91
|
|
|
$layer = new MapLayer(); |
92
|
|
|
$layer->Title = 'Ari Administrative Boundary'; |
|
|
|
|
93
|
|
|
$layers = new ArrayList(); |
94
|
|
|
$layers->push($layer); |
95
|
|
|
$member->MapLayers = $layers; |
|
|
|
|
96
|
|
|
$this->assertTrue($instance->HasGeo()); |
97
|
|
|
Member::remove_extension('MapLayerExtension'); |
98
|
|
|
|
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
|
102
|
|
|
public function testHasGeoWest() { |
103
|
|
|
$instance = $this->getInstance(); |
104
|
|
|
$instance->Lon = -20; |
105
|
|
|
$this->assertTrue($instance->HasGeo()); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
public function testHasGeoEast() { |
109
|
|
|
$instance = $this->getInstance(); |
110
|
|
|
$instance->Lon = 20; |
111
|
|
|
$this->assertTrue($instance->HasGeo()); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
public function testHasGeoNorth() { |
115
|
|
|
$instance = $this->getInstance(); |
116
|
|
|
$instance->Lat = 20; |
117
|
|
|
$this->assertTrue($instance->HasGeo()); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
public function testHasGeoNorthWest() { |
121
|
|
|
$instance = $this->getInstance(); |
122
|
|
|
$instance->Lat = 20; |
123
|
|
|
$instance->Lon = -20; |
124
|
|
|
$this->assertTrue($instance->HasGeo()); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
public function testHasGeoNortEast() { |
128
|
|
|
$instance = $this->getInstance(); |
129
|
|
|
$instance->Lat = 20; |
130
|
|
|
$instance->Lon = 20; |
131
|
|
|
$this->assertTrue($instance->HasGeo()); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
public function testHasGeoSouth() { |
135
|
|
|
$instance = $this->getInstance(); |
136
|
|
|
$instance->Lat = -20; |
137
|
|
|
$this->assertTrue($instance->HasGeo()); |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
public function testHasGeoSouthWest() { |
141
|
|
|
$instance = $this->getInstance(); |
142
|
|
|
$instance->Lat = -20; |
143
|
|
|
$instance->Lon = -20; |
144
|
|
|
$this->assertTrue($instance->HasGeo()); |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
public function testHasGeoSouthEast() { |
148
|
|
|
$instance = $this->getInstance(); |
149
|
|
|
$instance->Lat = -20; |
150
|
|
|
$instance->Lon = 20; |
151
|
|
|
$this->assertTrue($instance->HasGeo()); |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
public function testHasGeoOrigin() { |
155
|
|
|
$instance = $this->getInstance(); |
156
|
|
|
$instance->Lat = 0; |
157
|
|
|
$instance->Lon = 0; |
158
|
|
|
$this->assertFalse($instance->HasGeo()); |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
public function testHasGeoOriginMapLayerExtension() { |
162
|
|
|
$instance = $this->getInstance(); |
163
|
|
|
$instance->Lat = 0; |
164
|
|
|
$instance->Lon = 0; |
165
|
|
|
$this->assertFalse($instance->HasGeo()); |
166
|
|
|
Page::add_extension('MapLayerExtension'); |
167
|
|
|
Page::remove_extension('MapLayerExtension'); |
168
|
|
|
$this->markTestSkipped('TODO'); |
|
|
|
|
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
public function testHasGeoOriginPointsOfInterestLayers() { |
172
|
|
|
$instance = $this->getInstance(); |
173
|
|
|
$instance->Lat = 0; |
174
|
|
|
$instance->Lon = 0; |
175
|
|
|
$this->assertFalse($instance->HasGeo()); |
176
|
|
|
$this->markTestSkipped('TODO'); |
|
|
|
|
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
public function testBasicMap() { |
180
|
|
|
|
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
|
184
|
|
|
public function testGetMapField() { |
185
|
|
|
$instance = $this->getInstance(); |
186
|
|
|
$this->Lat = 37.1; |
187
|
|
|
$this->Lon = 28; |
188
|
|
|
$this->Zoom = 12; |
189
|
|
|
$mapField = $instance->getMapField(); |
190
|
|
|
$this->assertInstanceOf('LatLongField', $mapField); |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
|
194
|
|
|
public function testUseCompressedAssets() { |
195
|
|
|
|
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
|
199
|
|
|
private function getInstance() { |
200
|
|
|
$instance = new Member(); |
201
|
|
|
return $instance; |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* @param integer $lat |
206
|
|
|
* @param integer $lon |
207
|
|
|
*/ |
208
|
|
|
private function showMapPinEdited(&$instance, $lat, $lon) { |
209
|
|
|
$instance->Lat = $lat; |
210
|
|
|
$instance->Long = $lon; |
211
|
|
|
$instance->write(); |
212
|
|
|
$this->assertTrue($instance->MapPinEdited); |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
|
216
|
|
|
|
217
|
|
|
} |
218
|
|
|
|
Since your code implements the magic setter
_set
, this function will be called for any write access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.