Completed
Push — AUTOMATED_TESTING ( 9cc382...c62760 )
by Gordon
12:06
created

MappableDataTest::testStaticMapChangeLocation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 10

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 11
rs 9.4286
cc 1
eloc 10
nc 1
nop 0
1
<?php
2
3
class MappableDataTest extends SapphireTest {
4
5
	public function setUpOnce() {
6
		$this->requiredExtensions = array(
7
			'Member' => array('MapExtension')
8
		);
9
		parent::setupOnce();
10
	}
11
12
13
14
	public function testGetRenderableMap() {
15
		$this->markTestSkipped('TODO');
16
	}
17
18
19
	public function testSetMarkerTemplateValues() {
20
		$instance = $this->getInstance();
21
		$vals = array('TestKey' => 'TestVal');
22
		$instance->setMarkerTemplateValues($vals);
23
		$html = $instance->getRenderableMap(300,800,2)->forTemplate();
24
		$expected =  '';
25
		$this->assertEquals($expected, $html);
1 ignored issue
show
Bug introduced by
The method assertEquals() does not seem to exist on object<MappableDataTest>.

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...
26
	}
27
28
29
30
	public function testStaticMapChangeLocation() {
31
		$instance = $this->getInstance();
32
		$instance->Lat = 13.84;
33
		$instance->Lon = 100.52;
34
		$html = $instance->StaticMap(300,800);
35
		$expected = '<img src="//maps.googleapis.com/maps/api/staticmap?center='
36
				  . '13.84%2C100.52&amp;markers=13.84%2C100.52'
37
				  . '&amp;zoom=13&amp;size=300x800&amp;sensor=false&amp;mapt'
38
				  . 'ype=roadmap" width="300" height="800" alt="" />';
39
		$this->assertEquals($expected, $html);
1 ignored issue
show
Bug introduced by
The method assertEquals() does not seem to exist on object<MappableDataTest>.

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...
40
	}
41
42
	public function testStaticMapVarySize() {
43
		$instance = $this->getInstance();
44
		$instance->Lat = 13.8188931;
45
		$instance->Lon = 100.5005558;
46
		$html = $instance->StaticMap(300,800);
47
		$expected = '<img src="//maps.googleapis.com/maps/api/staticmap?center='
48
				  . '13.8188931%2C100.5005558&amp;markers=13.8188931%2C100.5005'
49
				  . '558&amp;zoom=13&amp;size=300x800&amp;sensor=false&amp;mapt'
50
				  . 'ype=roadmap" width="300" height="800" alt="" />';
51
		$this->assertEquals($expected, $html);
1 ignored issue
show
Bug introduced by
The method assertEquals() does not seem to exist on object<MappableDataTest>.

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...
52
53
		$html = $instance->StaticMap(310,810);
54
		$expected = '<img src="//maps.googleapis.com/maps/api/staticmap?center='
55
				  . '13.8188931%2C100.5005558&amp;markers=13.8188931%2C100.5005'
56
				  . '558&amp;zoom=13&amp;size=310x810&amp;sensor=false&amp;mapt'
57
				  . 'ype=roadmap" width="310" height="810" alt="" />';
58
		$this->assertEquals($expected, $html);
1 ignored issue
show
Bug introduced by
The method assertEquals() does not seem to exist on object<MappableDataTest>.

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...
59
	}
60
61
62
	public function testStaticMapVaryTerrain() {
63
		$instance = $this->getInstance();
64
		$instance->Lat = 13.8188931;
65
		$instance->Lon = 100.5005558;
66
		$html = $instance->StaticMap(300,800,  null, 'satellite');
67
		$expected = '<img src="//maps.googleapis.com/maps/api/staticmap?center='
68
				  . '13.8188931%2C100.5005558&amp;markers=13.8188931%2C100.5005'
69
				  . '558&amp;zoom=13&amp;size=300x800&amp;sensor=false&amp;mapt'
70
				  . 'ype=satellite" width="300" height="800" alt="" />';
71
		$this->assertEquals($expected, $html);
1 ignored issue
show
Bug introduced by
The method assertEquals() does not seem to exist on object<MappableDataTest>.

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...
72
73
		$html = $instance->StaticMap(300,800,null, 'terrain');
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...
74
		$expected = '<img src="//maps.googleapis.com/maps/api/staticmap?center='
0 ignored issues
show
Unused Code introduced by
$expected 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...
75
				  . '13.8188931%2C100.5005558&amp;markers=13.8188931%2C100.5005'
76
				  . '558&amp;zoom=13&amp;size=300x800&amp;sensor=false&amp;mapt'
77
				  . 'ype=terrain" width="300" height="800" alt="" />';
78
79
		$html = $instance->StaticMap(300,800,null, 'hybrid');
80
		$expected = '<img src="//maps.googleapis.com/maps/api/staticmap?center='
81
				  . '13.8188931%2C100.5005558&amp;markers=13.8188931%2C100.5005'
82
				  . '558&amp;zoom=13&amp;size=300x800&amp;sensor=false&amp;mapt'
83
				  . 'ype=hybrid" width="300" height="800" alt="" />';
84
		$this->assertEquals($expected, $html);
1 ignored issue
show
Bug introduced by
The method assertEquals() does not seem to exist on object<MappableDataTest>.

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...
85
	}
86
87
88
	public function testStaticMapVaryZoom() {
89
		$instance = $this->getInstance();
90
91
		$html = $instance->StaticMap(300,800,2);
92
		$expected = '<img src="//maps.googleapis.com/maps/api/staticmap?center='
93
				  . '13.8188931%2C100.5005558&amp;markers=13.8188931%2C100.5005'
94
				  . '558&amp;zoom=2&amp;size=300x800&amp;sensor=false&amp;mapt'
95
				  . 'ype=roadmap" width="300" height="800" alt="" />';
96
		$this->assertEquals($expected, $html);
1 ignored issue
show
Bug introduced by
The method assertEquals() does not seem to exist on object<MappableDataTest>.

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...
97
98
		$html = $instance->StaticMap(300,800,12);
99
		$expected = '<img src="//maps.googleapis.com/maps/api/staticmap?center='
100
				  . '13.8188931%2C100.5005558&amp;markers=13.8188931%2C100.5005'
101
				  . '558&amp;zoom=12&amp;size=300x800&amp;sensor=false&amp;mapt'
102
				  . 'ype=roadmap" width="300" height="800" alt="" />';
103
		$this->assertEquals($expected, $html);
1 ignored issue
show
Bug introduced by
The method assertEquals() does not seem to exist on object<MappableDataTest>.

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...
104
	}
105
106
	private function getInstance() {
107
		$instance = new Member();
108
		$instance->Lat = 13.8188931;
109
		$instance->Lon = 100.5005558;
110
		return $instance;
111
	}
112
113
}
114