1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
class GoogleStreetViewShortCodeTest extends SapphireTest |
4
|
|
|
{ |
5
|
|
|
protected static $fixture_file = 'mappable/tests/shortcodes.yml'; |
6
|
|
|
|
7
|
1 |
View Code Duplication |
public function testRoadMap() |
|
|
|
|
8
|
|
|
{ |
9
|
1 |
|
GoogleStreetViewShortCodeHandler::resetCounter(); |
10
|
1 |
|
$page = $this->objFromFixture('Page', 'StreetView'); |
11
|
1 |
|
$html = ShortcodeParser::get_active()->parse($page->Content); |
12
|
|
|
$expected = <<<TEXT |
13
|
|
|
Some text |
14
|
|
|
|
15
|
|
|
<div class="streetviewcontainer"> |
16
|
|
|
<div id="google_streetview_1" class="streetview googlestreetview" data-streetview="" data-latitude="13.811841" data-longitude="100.527309" data-zoom="1" data-pitch="-10" data-heading="162.43"></div> |
17
|
|
|
<p class="caption">Canal south from Pracha Rat 1 Soi 28</p> |
18
|
|
|
</div> |
19
|
|
|
|
20
|
1 |
|
TEXT; |
21
|
1 |
|
$this->assertEquals($expected, $html); |
|
|
|
|
22
|
1 |
|
} |
23
|
|
|
|
24
|
1 |
View Code Duplication |
public function testNoLongitude() |
|
|
|
|
25
|
|
|
{ |
26
|
1 |
|
GoogleStreetViewShortCodeHandler::resetCounter(); |
27
|
1 |
|
$page = $this->objFromFixture('Page', 'StreetViewNoLongitude'); |
28
|
1 |
|
$html = ShortcodeParser::get_active()->parse($page->Content); |
29
|
1 |
|
$this->assertEquals('Some text', $html); |
|
|
|
|
30
|
1 |
|
} |
31
|
|
|
|
32
|
1 |
View Code Duplication |
public function testNoLatitude() |
|
|
|
|
33
|
|
|
{ |
34
|
1 |
|
GoogleStreetViewShortCodeHandler::resetCounter(); |
35
|
1 |
|
$page = $this->objFromFixture('Page', 'StreetViewNoLatitude'); |
36
|
1 |
|
$html = ShortcodeParser::get_active()->parse($page->Content); |
37
|
1 |
|
$this->assertEquals('Some text', $html); |
|
|
|
|
38
|
1 |
|
} |
39
|
|
|
|
40
|
1 |
View Code Duplication |
public function testNoHeading() |
|
|
|
|
41
|
|
|
{ |
42
|
1 |
|
GoogleStreetViewShortCodeHandler::resetCounter(); |
43
|
1 |
|
$page = $this->objFromFixture('Page', 'StreetViewNoHeading'); |
44
|
1 |
|
$html = ShortcodeParser::get_active()->parse($page->Content); |
45
|
1 |
|
$this->assertEquals('Some text', $html); |
|
|
|
|
46
|
1 |
|
} |
47
|
|
|
|
48
|
1 |
View Code Duplication |
public function testZoom() |
|
|
|
|
49
|
|
|
{ |
50
|
1 |
|
GoogleStreetViewShortCodeHandler::resetCounter(); |
51
|
1 |
|
$page = $this->objFromFixture('Page', 'StreetViewWithZoom'); |
52
|
1 |
|
$html = ShortcodeParser::get_active()->parse($page->Content); |
53
|
|
|
$expected = <<< TEXT |
54
|
|
|
Some text |
55
|
|
|
|
56
|
|
|
<div class="streetviewcontainer"> |
57
|
|
|
<div id="google_streetview_1" class="streetview googlestreetview" data-streetview="" data-latitude="13.811841" data-longitude="100.527309" data-zoom="12" data-pitch="-10" data-heading="162.43"></div> |
58
|
|
|
<p class="caption">Canal south from Pracha Rat 1 Soi 28</p> |
59
|
|
|
</div> |
60
|
|
|
|
61
|
1 |
|
TEXT; |
62
|
1 |
|
$this->assertEquals($expected, $html); |
|
|
|
|
63
|
1 |
|
} |
64
|
|
|
} |
65
|
|
|
|
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.