1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Testing YouTubeShortCodeHandler. |
5
|
|
|
*/ |
6
|
|
|
class GoogleMapShortCodeTest extends SapphireTest |
7
|
|
|
{ |
8
|
|
|
protected static $fixture_file = 'mappable/tests/shortcodes.yml'; |
9
|
|
|
|
10
|
1 |
View Code Duplication |
public function testRoadMap() |
|
|
|
|
11
|
|
|
{ |
12
|
1 |
|
GoogleMapShortCodeHandler::resetCounter(); |
13
|
1 |
|
$page = $this->objFromFixture('Page', 'RoadMap'); |
14
|
1 |
|
$html = ShortcodeParser::get_active()->parse($page->Content); |
15
|
|
|
$expected = <<<TEXT |
16
|
|
|
Some text |
17
|
|
|
|
18
|
|
|
<div class="googlemapcontainer"> |
19
|
|
|
<div id="google_sc_map_1" class="map googlemap" data-shortcode-map="" data-latitude="13.7402946" data-longitude="100.5525439" data-zoom="14" data-maptype="road" data-allowfullscreen="1"></div> |
20
|
|
|
<p class="caption">Roads in Central Bangkok</p> |
21
|
|
|
</div> |
22
|
|
|
|
23
|
1 |
|
TEXT; |
24
|
1 |
|
$this->assertEquals($expected, $html); |
|
|
|
|
25
|
1 |
|
} |
26
|
|
|
|
27
|
1 |
View Code Duplication |
public function testAerialMap() |
|
|
|
|
28
|
|
|
{ |
29
|
1 |
|
GoogleMapShortCodeHandler::resetCounter(); |
30
|
1 |
|
$page = $this->objFromFixture('Page', 'AerialMap'); |
31
|
1 |
|
$html = ShortcodeParser::get_active()->parse($page->Content); |
32
|
|
|
$expected = <<<TEXT |
33
|
|
|
Some text |
34
|
|
|
|
35
|
|
|
<div class="googlemapcontainer"> |
36
|
|
|
<div id="google_sc_map_1" class="map googlemap" data-shortcode-map="" data-latitude="13.815483" data-longitude="100.5447213" data-zoom="20" data-maptype="aerial" data-allowfullscreen="1"></div> |
37
|
|
|
<p class="caption">Bang Sue Train Depot, Thailand</p> |
38
|
|
|
</div> |
39
|
|
|
|
40
|
1 |
|
TEXT; |
41
|
1 |
|
$this->assertEquals($expected, $html); |
|
|
|
|
42
|
1 |
|
} |
43
|
|
|
|
44
|
1 |
View Code Duplication |
public function testHybridMap() |
|
|
|
|
45
|
|
|
{ |
46
|
1 |
|
GoogleMapShortCodeHandler::resetCounter(); |
47
|
1 |
|
$page = $this->objFromFixture('Page', 'HybridMap'); |
48
|
1 |
|
$html = ShortcodeParser::get_active()->parse($page->Content); |
49
|
|
|
$expected = <<<TEXT |
50
|
|
|
Some text |
51
|
|
|
|
52
|
|
|
<div class="googlemapcontainer"> |
53
|
|
|
<div id="google_sc_map_1" class="map googlemap" data-shortcode-map="" data-latitude="13.8309545" data-longitude="100.5577219" data-zoom="18" data-maptype="hybrid" data-allowfullscreen="1"></div> |
54
|
|
|
<p class="caption">Junction in Bangkok, Thailand</p> |
55
|
|
|
</div> |
56
|
|
|
|
57
|
1 |
|
TEXT; |
58
|
1 |
|
$this->assertEquals($expected, $html); |
|
|
|
|
59
|
1 |
|
} |
60
|
|
|
|
61
|
1 |
View Code Duplication |
public function testTerrainmap() |
|
|
|
|
62
|
|
|
{ |
63
|
1 |
|
GoogleMapShortCodeHandler::resetCounter(); |
64
|
1 |
|
$page = $this->objFromFixture('Page', 'TerrainMap'); |
65
|
1 |
|
$html = ShortcodeParser::get_active()->parse($page->Content); |
66
|
|
|
$expected = <<<TEXT |
67
|
|
|
Some text |
68
|
|
|
|
69
|
|
|
<div class="googlemapcontainer"> |
70
|
|
|
<div id="google_sc_map_1" class="map googlemap" data-shortcode-map="" data-latitude="18.8032393" data-longitude="98.9166518" data-zoom="14" data-maptype="terrain" data-allowfullscreen="1"></div> |
71
|
|
|
<p class="caption">Mountains west of Chiang Mai</p> |
72
|
|
|
</div> |
73
|
|
|
|
74
|
1 |
|
TEXT; |
75
|
1 |
|
$this->assertEquals($expected, $html); |
|
|
|
|
76
|
1 |
|
} |
77
|
|
|
|
78
|
1 |
|
public function testNoLongitude() |
79
|
|
|
{ |
80
|
1 |
|
$page = $this->objFromFixture('Page', 'MapWithNoLongitude'); |
81
|
1 |
|
$html = ShortcodeParser::get_active()->parse($page->Content); |
82
|
1 |
|
$this->assertEquals('Some text', $html); |
|
|
|
|
83
|
1 |
|
} |
84
|
|
|
|
85
|
1 |
|
public function testNoLatitude() |
86
|
|
|
{ |
87
|
1 |
|
$page = $this->objFromFixture('Page', 'MapWithNoLatitude'); |
88
|
1 |
|
$html = ShortcodeParser::get_active()->parse($page->Content); |
89
|
1 |
|
$this->assertEquals('Some text', $html); |
|
|
|
|
90
|
1 |
|
} |
91
|
|
|
} |
92
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.