Completed
Push — AUTOMATED_TESTING ( 6591ac...6229f9 )
by Gordon
15:27
created

MapAPITest   B

Complexity

Total Complexity 40

Size/Duplication

Total Lines 550
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 7
Metric Value
wmc 40
lcom 2
cbo 7
dl 0
loc 550
rs 8.2609

37 Methods

Rating   Name   Duplication   Size   Complexity  
A setUpOnce() 0 6 1
A setUp() 0 4 1
A testSetKey() 0 8 1
A testSetClusterer() 0 22 1
A testSetShowInlineMapDivStyle() 0 11 1
A testSetAdditionalCSSClasses() 0 8 1
A testSetMapStyle() 0 57 1
A testSetDivId() 0 7 1
A testSetSize() 0 6 1
A testSetLang() 0 6 1
A testSetZoom() 0 9 1
A testSetInfoWindowZoom() 0 10 1
A testSetEnableWindowZoom() 0 9 1
A testSetEnableAutomaticCenterZoom() 0 6 1
A testSetNoLocation() 0 8 1
A testSetCenter() 0 10 1
B testSetLatLongCenter() 0 35 3
A testSetMapType() 0 22 2
A testSetAllowFullScreen() 0 17 1
A testMapWithMarkers() 0 11 1
A testMapWithMarkersDifferentCategory() 0 3 1
A testSetDefaultHideMarker() 0 17 1
A testGetContent() 0 9 1
A testGeocoding() 0 10 1
A testGeocodingNoResultsFound() 0 6 1
A testAddMarkerByAddress() 0 13 1
A testAddArrayMarkerByCoords() 0 15 1
A testAddMarkerByCoords() 0 15 1
A testAddMarkerAsObject() 0 18 1
A testAddMarkerThatIsMappableAsObject() 0 14 1
A testConnectPoints() 0 10 1
A testAddKML() 0 8 1
A testAddLine() 0 17 1
B testProcessTemplate() 0 29 1
A getMap() 0 4 1
A getMapMultipleItems() 0 4 1
A getGeolocatedMembers() 0 23 1

How to fix   Complexity   

Complex Class

Complex classes like MapAPITest often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use MapAPITest, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
class MapAPITest extends SapphireTest {
4
5
	public function setUpOnce() {
6
		$this->requiredExtensions = array(
7
			'Member' => array('MapExtension')
8
		);
9
		parent::setupOnce();
10
	}
11
12
13
	public function setUp() {
14
		MapUtil::reset();
15
		parent::setUp();
16
	}
17
18
	public function testSetKey() {
19
		$map = $this->getMap();
20
		$map->setKey('PRETEND_KEY');
21
		$html = $map->forTemplate();
0 ignored issues
show
Unused Code introduced by
$html is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
22
		$map->setKey(null);
23
24
		$this->fail('where to check effect?');
25
	}
26
27
	public function testSetClusterer() {
28
		$map = $this->getMap();
29
		$map->setClusterer(true);
30
		$html = $map->forTemplate();
31
		$this->assertContains('data-clusterergridsize=50', $html);
32
		$this->assertContains('data-clusterermaxzoom=17', $html);
33
		$this->assertContains('data-useclusterer=1', $html);
34
35
		$map = $this->getMap();
36
		$map->setClusterer(true, 60,14);
37
		$html = $map->forTemplate();
38
		$this->assertContains('data-clusterergridsize=60', $html);
39
		$this->assertContains('data-clusterermaxzoom=14', $html);
40
		$this->assertContains('data-useclusterer=1', $html);
41
42
		$map = $this->getMap();
43
		$map->setClusterer(false);
44
		$html = $map->forTemplate();
45
		$this->assertContains('data-useclusterer=false', $html);
46
		$this->assertContains('data-clusterergridsize=50', $html);
47
		$this->assertContains('data-clusterermaxzoom=17', $html);
48
	}
49
50
	/*
51
	Toggle as to whether or not to include a style= attribute with width/height
52
	 */
53
	public function testSetShowInlineMapDivStyle() {
54
		$map = $this->getMap();
55
		$map->setShowInlineMapDivStyle(true);
56
		$html = $map->forTemplate();
57
		$expected = 'style="width:100%; height: 400px;"';
58
		$this->assertContains($expected, $html);
59
60
		$map->setShowInlineMapDivStyle(false);
61
		$html = $map->forTemplate();
62
		$this->assertNotContains($expected, $html);
63
	}
64
65
	public function testSetAdditionalCSSClasses() {
66
		$map = $this->getMap();
67
		$map->setAdditionalCSSClasses('bigMap shadowMap');
68
		$html = $map->forTemplate();
69
		$expected = 'class="bigMap shadowMap mappable"';
70
		$this->assertContains($expected, $html);
71
		$map->setAdditionalCSSClasses('bigMap shadowMap');
72
	}
73
74
75
	public function testSetMapStyle() {
76
		$style = <<<STYLE
77
[{
78
	"featureType": "landscape",
79
	"stylers": [{
80
		"hue": "#FFBB00"
81
	}, {
82
		"saturation": 43.400000000000006
83
	}, {
84
		"lightness": 37.599999999999994
85
	}, {
86
		"gamma": 1
87
	}]
88
}]
89
STYLE;
90
		$map = $this->getMap();
91
		$map->setMapStyle($style);
92
		$html = $map->forTemplate()->getValue();
93
		$expected = <<<HTML
94
95
96
<div id="google_map_1" style="width:100%; height: 400px;"
97
 class=" mappable"
98
data-map
99
data-centre='{"lat":48.856614,"lng":2.3522219}'
100
data-zoom=9
101
data-maptype='road'
102
data-allowfullscreen='1'
103
data-clusterergridsize=50,
104
data-clusterermaxzoom=17,
105
data-enableautocentrezoom=false
106
data-enablewindowzoom=false
107
data-infowindowzoom=13
108
data-mapmarkers='[]'
109
data-defaulthidemarker=false
110
data-lines='[]'
111
data-kmlfiles='[]'
112
data-mapstyles='[{
113
	"featureType": "landscape",
114
	"stylers": [{
115
		"hue": "#FFBB00"
116
	}, {
117
		"saturation": 43.400000000000006
118
	}, {
119
		"lightness": 37.599999999999994
120
	}, {
121
		"gamma": 1
122
	}]
123
}]'
124
data-useclusterer=false
125
>
126
</div>
127
128
HTML;
129
		$this->assertEquals($expected, $html);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<MapAPITest>.

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.

Loading history...
130
		$map->setMapStyle(null);
131
	}
132
133
	public function testSetDivId() {
134
		$map = $this->getMap();
135
		$map->setDivId('mymapid');
136
		$html = $map->forTemplate();
137
		$expected = '<div id="mymapid" style=';
138
		$this->assertContains($expected, $html);
139
	}
140
141
	public function testSetSize() {
142
		$map = $this->getMap();
143
		$map->setSize('432px', '1234px');
144
		$html = $map->forTemplate();
145
		$this->assertContains('style="width:432px; height: 1234px;"', $html);
146
	}
147
148
	public function testSetLang() {
149
		$map = $this->getMap();
150
		$map->setLang('fr');
151
		$html = $map->forTemplate();
0 ignored issues
show
Unused Code introduced by
$html is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
152
		$this->fail('Response needs checked');
153
	}
154
155
156
	public function testSetZoom() {
157
		$map = $this->getMap();
158
		$map->setZoom(4);
159
		$html = $map->forTemplate();
160
		$this->assertContains('data-zoom=4', $html);
161
		$map->setZoom(12);
162
		$html = $map->forTemplate();
163
		$this->assertContains('data-zoom=12', $html);
164
	}
165
166
	public function testSetInfoWindowZoom() {
167
		$map = $this->getMap();
168
		$map->setInfoWindowZoom(4);
169
		$html = $map->forTemplate();
170
		$this->assertContains('data-infowindowzoom=4', $html);
171
		$map->setInfoWindowZoom(12);
172
		$html = $map->forTemplate();
173
		$this->assertContains('data-infowindowzoom=12', $html);
174
175
	}
176
177
	public function testSetEnableWindowZoom() {
178
		$map = $this->getMap();
179
		$map->setEnableWindowZoom(false);
180
		$html = $map->forTemplate();
181
		$this->assertContains('data-enablewindowzoom=false', $html);
182
		$map->setEnableWindowZoom(true);
183
		$html = $map->forTemplate();
184
		$this->assertContains('data-enablewindowzoom=1', $html);
185
	}
186
187
	public function testSetEnableAutomaticCenterZoom() {
188
		$map = $this->getMap();
189
		$map->setEnableAutomaticCenterZoom(true);
190
		$html = $map->forTemplate();
191
		$this->assertContains('data-enableautocentrezoom=1', $html);
192
	}
193
194
	public function testSetNoLocation() {
195
		$map = $this->getMap();
196
		$html = $map->forTemplate();
197
		$this->assertContains(
198
			'data-centre=\'{"lat":48.856614,"lng":2.3522219}\'',
199
			$html
200
		);
201
	}
202
203
	/**
204
	 * setCentre is mis-named, as the method expects text for a geocoder
205
	 */
206
	public function testSetCenter() {
207
		$map = $this->getMap();
208
		$map->setCenter('Klong Tan, Bangkok, Thailand');
209
		$html = $map->forTemplate();
210
211
		//coordinates of Klong Tan in Bangkok
212
		$expected = 'data-centre=\'{"lat":13.7243075,"lng":100.5718086}';
213
		$this->assertContains($expected, $html);
214
		$map->setCenter('Paris, France');
215
	}
216
217
218
	public function testSetLatLongCenter() {
219
		$map = $this->getMap();
220
		$llc = array('lat' => -23.714, 'lng' => 47.419);
221
		$map->setLatLongCenter($llc);
222
		$html = $map->forTemplate();
223
		$expected = "data-centre='{\"lat\":-23.714,\"lng\":47.419}'";
224
		$this->assertContains($expected, $html);
225
226
		// now test error conditions
227
		try {
228
			$map->setLatLongCenter('This is not a coordinate');
229
			$this->fail('Should not be able to set coordinate as text');
230
		} catch (InvalidArgumentException $e) {
231
			$message = $e->getMessage();
232
			$this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<MapAPITest>.

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.

Loading history...
233
				'Center must be an associative array containing lat,lng',
234
				$message
235
			);
236
		}
237
238
		try {
239
			$badKeys = array('lat' => 47.2, 'wibble' => 76.10);
240
			$map->setLatLongCenter($badKeys);
241
			$this->fail('Should not be able to set coordinate as text');
242
		} catch (InvalidArgumentException $e) {
243
			$message = $e->getMessage();
244
245
			$this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<MapAPITest>.

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.

Loading history...
246
				'Keys provided must be lat, lng',
247
				$message
248
			);
249
		}
250
251
252
	}
253
254
255
	public function testSetMapType() {
256
		$map = $this->getMap();
257
258
		$mapTypes = array(
259
			'road' => 'road',
260
			'satellite' => 'satellite',
261
			'hybrid' => 'hybrid',
262
			'terrain' => 'terrain',
263
			'google.maps.MapTypeId.ROADMAP' => 'road',
264
			'google.maps.MapTypeId.SATELLITE' => 'satellite',
265
			'google.maps.MapTypeId.G_HYBRID_MAP' => 'hybrid',
266
			'google.maps.MapTypeId.G_PHYSICAL_MAP' => 'terrain',
267
			'custom_layer' => 'custom_layer'
268
		);
269
270
		foreach (array_keys($mapTypes) as $mapType) {
271
			$map->setMapType($mapType);
272
			$expected = "data-maptype='".$mapTypes[$mapType]."'";
273
			$html = $map->forTemplate();
274
			$this->assertContains($expected, $html);
275
		}
276
	}
277
278
279
	public function testSetAllowFullScreen() {
280
		$map = $this->getMap();
281
		$map->setAllowFullScreen(false);
282
		$html = $map->forTemplate();
283
284
		$this->assertContains("data-allowfullscreen='false'", $html);
285
286
		$map->setAllowFullScreen(true);
287
		$html = $map->forTemplate();
288
		$this->assertContains("data-allowfullscreen='1'", $html);
289
290
		// deal with the null calse
291
		$map->setAllowFullScreen(null);
292
		$html = $map->forTemplate();
293
		$expected = Config::inst()->get('Mappable', 'allow_full_screen');
294
		$this->assertContains("data-allowfullscreen='{$expected}'", $html);
295
	}
296
297
	public function testMapWithMarkers() {
298
		$config = Config::inst();
0 ignored issues
show
Unused Code introduced by
$config is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
299
300
		$map = $this->getMapMultipleItems();
301
		$html = $map->forTemplate();
302
		$expected = 'data-mapmarkers=\'[{"latitude":23,"longitude":78,"html":"'
303
				  . 'MEMBER: Fred Bloggs","category":"default","icon":false},{"latitude'
304
				  . '":-12,"longitude":42.1,"html":"MEMBER: Kane Williamson","category"'
305
				  . ':"default","icon":false}]\'';
306
		$this->assertContains($expected, $html);
307
	}
308
309
310
	public function testMapWithMarkersDifferentCategory() {
311
		$this->markTestSkipped('TODO');
312
	}
313
314
315
	public function testSetDefaultHideMarker() {
316
		$map = $this->getMapMultipleItems();
317
		$map->setDefaultHideMarker(false);
318
		$html = $map->forTemplate();
319
		$this->assertContains(
320
			'data-defaulthidemarker=false',
321
			$html
322
		);
323
324
		$map = $this->getMapMultipleItems();
325
		$map->setDefaultHideMarker(true);
326
		$html = $map->forTemplate();
327
		$this->assertContains(
328
			'data-defaulthidemarker=1',
329
			$html
330
		);
331
	}
332
333
	public function testGetContent() {
334
		$map = $this->getMap();
335
		$filepath = 'file://' . Director::baseFolder()
336
				  . '/mappable/tests/kml/example.kml';
337
		$content = $map->getContent($filepath);
338
		$textHash = hash('ripemd160', $content);
339
		$fileHash = hash_file('ripemd160', $filepath);
340
		$this->assertEquals($fileHash, $textHash);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<MapAPITest>.

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.

Loading history...
341
	}
342
343
	public function testGeocoding() {
344
		$map = $this->getMap();
345
		$location = $map->geocoding("Nonthaburi, Thailand");
346
		$expected = array(
347
			'lat' => 13.8621125,
348
			'lon' => 100.5143528,
349
    		'geocoded' => true
350
		);
351
		$this->assertEquals($expected, $location);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<MapAPITest>.

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.

Loading history...
352
	}
353
354
	public function testGeocodingNoResultsFound() {
355
		$map = $this->getMap();
356
		$location = $map->geocoding("aasdfsafsfdsfasdf");
357
		$expected = array();
358
		$this->assertEquals($expected, $location);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<MapAPITest>.

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.

Loading history...
359
	}
360
361
	public function testAddMarkerByAddress() {
362
		//$address, $content = '', $category = '', $icon = ''
0 ignored issues
show
Unused Code Comprehensibility introduced by
46% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
363
		$map = $this->getMap();
364
		$map->addMarkerByAddress(
365
			'Koh Kred, Nonthaburi, Thailand',
366
			'Small island in the Chao Phraya river',
367
			'testing',
368
			'http://www.test.com/icon.png'
369
		);
370
		$html = $map->forTemplate();
371
		$expected = 'data-mapmarkers=\'[{"latitude":13.9114455,"longitude":100.4761897,"html":"Small island in the Chao Phraya river","category":"testing","icon":"http://www.test.com/icon.png"}]\'';
372
		$this->assertContains($expected, $html);
373
	}
374
375
376
	public function testAddArrayMarkerByCoords() {
377
		$map = $this->getMap();
378
379
		$markerArray = array();
380
		$marker1 = array(48.2, 27, 'Description marker 1', 'Marker Test', '');
381
		$marker2 = array(-12.2, 47, 'Description marker 2', 'Marker Test', '');
382
383
		array_push($markerArray, $marker1);
384
		array_push($markerArray, $marker2);
385
386
		$map->addArrayMarkerByCoords($markerArray);
387
		$html = $map->forTemplate();
388
		$expected = 'data-mapmarkers=\'[{"latitude":48.2,"longitude":27,"html":"Description marker 1","category":"","icon":""},{"latitude":-12.2,"longitude":47,"html":"Description marker 2","category":"","icon":""}]\'';
389
		$this->assertContains($expected, $html);
390
	}
391
392
	public function testAddMarkerByCoords() {
393
		$map = $this->getMap();
394
		$map->addMarkerByCoords(
395
			13.91,
396
			100.47,
397
			'Description of marker',
398
			'testing',
399
			'http://www.test.com/icon.png'
400
		);
401
		$html = $map->forTemplate();
402
		$expected =
403
		'data-mapmarkers=\'[{"latitude":13.91,"longitude":100.47,"html":"Description of marker","category":"testing","icon":"http://www.test.com/icon.png"}]';
404
405
		$this->assertContains($expected, $html);
406
	}
407
408
409
	public function testAddMarkerAsObject() {
410
		$map = $this->getMap();
411
		$member = new Member();
412
		$member->FirstName = 'Test';
413
		$member->Surname = 'User';
414
		$member->Lat = 24.2;
415
		$member->Lon = -40;
416
		$member->write();
417
		$params = array();
418
		$map->addMarkerAsObject(
419
			$member,
420
			$params
421
		);
422
423
		$html = $map->forTemplate();
424
		$expected = 'data-mapmarkers=\'[{"latitude":24.2,"longitude":-40,"html":"MEMBER: Test User","category":"default","icon":false}]\'';
425
		$this->assertContains($expected, $html);
426
	}
427
428
429
	public function testAddMarkerThatIsMappableAsObject() {
430
		$map = $this->getMap();
431
		$member = new MappableExampleClass();
432
		//$member->write();
0 ignored issues
show
Unused Code Comprehensibility introduced by
84% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
433
		$params = array();
434
		$map->addMarkerAsObject(
435
			$member,
436
			$params
437
		);
438
439
		$html = $map->forTemplate();
440
		$expected = 'data-mapmarkers=\'[{"latitude":13.4,"longitude":100.7,"html":"example content","category":"default","icon":null}]\'';
441
		$this->assertContains($expected, $html);
442
	}
443
444
445
	public function testConnectPoints() {
446
		$members = $this->getGeolocatedMembers();
447
		$member1 = $members->pop();
448
		$member2 = $members->pop();
449
		$map = $this->getMap();
450
		$map->connectPoints($member1, $member2);
451
		$html = $map->forTemplate();
452
		$expected = 'data-lines=\'[{"lat1":-12,"lon1":42.1,"lat2":23,"lon2":78,"color":"#FF3300"}]\'';
453
		$this->assertContains($expected, $html);
454
	}
455
456
457
	public function testAddKML() {
458
		$map = $this->getMap();
459
		$map->addKml('http://www.test.com/route1.kml');
460
		$map->addKml('http://www.test.com/route2.kml');
461
		$html = $map->forTemplate();
462
		$expected = 'data-kmlfiles=\'["http://www.test.com/route1.kml","http://www.test.com/route2.kml"]\'';
463
		$this->assertContains($expected, $html);
464
	}
465
466
467
	public function testAddLine() {
468
		$map = $this->getMap();
469
		$map->addLine(
470
			array(13,101),
471
			array(13.2, 101.4),
472
			'#F32'
473
		);
474
475
		$map->addLine(
476
			array(13.2, 101.4),
477
			array(14.2,99.8)
478
		);
479
480
		$html = $map->forTemplate();
481
		$expected = 'data-lines=\'[{"lat1":13,"lon1":101,"lat2":13.2,"lon2":101.4,"color":"#F32"},{"lat1":13.2,"lon1":101.4,"lat2":14.2,"lon2":99.8,"color":"#FF3300"}]\'';
482
		$this->assertContains($expected, $html);
483
	}
484
485
	/**
486
	 * This tests out a specific case of passing null for template values
487
	 */
488
	public function testProcessTemplate() {
489
		$map = $this->getMap();
490
		$html = $map->processTemplateHTML('Map', null);
491
		$expected = <<<HTML
492
493
494
<div id=""
495
data-map
496
data-centre=''
497
data-zoom=
498
data-maptype=''
499
data-allowfullscreen=''
500
data-clusterergridsize=,
501
data-clusterermaxzoom=,
502
data-enableautocentrezoom=
503
data-enablewindowzoom=
504
data-infowindowzoom=
505
data-mapmarkers=''
506
data-defaulthidemarker=
507
data-lines=''
508
data-kmlfiles=''
509
data-mapstyles=''
510
data-useclusterer=
511
>
512
</div>
513
514
HTML;
515
		$this->assertEquals($expected, $html->getValue());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<MapAPITest>.

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.

Loading history...
516
	}
517
518
	private function getMap() {
519
		$instance = new Member();
520
		return $instance->getRenderableMap();
521
	}
522
523
	private function getMapMultipleItems() {
524
		$members = $this->getGeolocatedMembers();
525
		return $members->getRenderableMap();
526
	}
527
528
	private function getGeolocatedMembers() {
529
		$members = new ArrayList();
530
531
		$member1 = new Member();
532
		$member1->Lat = 23;
533
		$member1->Lon = 78;
534
		$member1->MapPinEdited = true;
535
		$member1->FirstName = 'Fred';
536
		$member1->Surname = 'Bloggs';
537
		$member1->write();
538
		$members->push($member1);
539
540
		$member2 = new Member();
541
		$member2->Lat = -12;
542
		$member2->Lon = 42.1;
543
		$member2->MapPinEdited = true;
544
		$member2->FirstName = 'Kane';
545
		$member2->Surname = 'Williamson';
546
		$member2->write();
547
		$members->push($member2);
548
549
		return $members;
550
	}
551
552
}
553
554
555
556
// basic implementation of Mappable interface for some of the tests
557
class MappableExampleClass extends ViewableData implements TestOnly, Mappable {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
558
559
	public function getMappableLatitude() {
560
		return 13.4;
561
	}
562
563
	public function getMappableLongitude() {
564
		return 100.7;
565
	}
566
567
	public function getMappableMapPin() {
568
		return null;
569
	}
570
571
	public function getMappableMapContent() {
572
		return 'example content';
573
	}
574
}
575