Completed
Branch AUTOMATED_TESTING (6eabf7)
by Gordon
14:03
created

MapUtilTest   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 101
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4
Metric Value
wmc 14
lcom 1
cbo 4
dl 0
loc 101
rs 10

14 Methods

Rating   Name   Duplication   Size   Complexity  
A test_set_api_key() 0 5 1
A test_get_set_map_already_rendered() 0 6 1
A test_set_map_size() 0 5 1
A testSanitizeEmptyString() 0 6 1
A testSanitizeAlreadySanitized() 0 6 1
A testSanitizeSlashN() 0 6 1
A testSanitizeSlashT() 0 6 1
A testSanitizeSlashR() 0 6 1
A test_chooseToAddDataobject() 0 3 1
A htmlForMap() 0 5 1
A test_set_center() 0 6 1
A test_set_map_type() 0 6 1
A test_set_info_window_width() 0 3 1
A test_set_icon_size() 0 3 1
1
<?php
2
3
class MapUtilTest extends SapphireTest {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
5
	/*
6
	Other tests:
7
	1) List, ArrayList, DataList, null for get_map
8
	2) Negative and zero map sizes
9
	3) Invalid map type
10
	 */
11
12
13
	public function test_set_api_key() {
14
		MapUtil::set_api_key('PRETENDAPIKEY');
15
		$html = $this->htmlForMap();
16
		echo $html;
17
	}
18
19
	public function test_get_set_map_already_rendered() {
20
		MapUtil::set_map_already_rendered(false);
21
		$this->assertFalse(MapUtil::get_map_already_rendered());
1 ignored issue
show
Bug introduced by
The method assertFalse() does not seem to exist on object<MapUtilTest>.

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...
22
		MapUtil::set_map_already_rendered(true);
23
		$this->assertTrue(MapUtil::get_map_already_rendered());
1 ignored issue
show
Bug introduced by
The method assertTrue() does not seem to exist on object<MapUtilTest>.

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...
24
	}
25
26
	public function test_set_map_size() {
27
    	MapUtil::set_map_size('890px','24em');
28
		$html = $this->htmlForMap();
29
		$this->assertContains(' style="width:890px; height: 24em;"', $html);
30
	}
31
32
33
34
	public function testSanitizeEmptyString() {
35
		$this->assertEquals(
1 ignored issue
show
Bug introduced by
The method assertEquals() does not seem to exist on object<MapUtilTest>.

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...
36
			'',
37
			MapUtil::sanitize('')
38
		);
39
	}
40
41
	public function testSanitizeAlreadySanitized() {
42
		$this->assertEquals(
1 ignored issue
show
Bug introduced by
The method assertEquals() does not seem to exist on object<MapUtilTest>.

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...
43
			'This is already sanitized',
44
			MapUtil::sanitize('This is already sanitized')
45
		);
46
	}
47
48
	public function testSanitizeSlashN() {
49
		$this->assertEquals(
1 ignored issue
show
Bug introduced by
The method assertEquals() does not seem to exist on object<MapUtilTest>.

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...
50
			'String to be sanitized',
51
			MapUtil::sanitize("String\n to be sanitized")
52
		);
53
	}
54
55
	public function testSanitizeSlashT() {
56
		$this->assertEquals(
1 ignored issue
show
Bug introduced by
The method assertEquals() does not seem to exist on object<MapUtilTest>.

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...
57
			'String to be sanitized',
58
			MapUtil::sanitize("String\t to be sanitized")
59
		);
60
	}
61
62
	public function testSanitizeSlashR() {
63
		$this->assertEquals(
1 ignored issue
show
Bug introduced by
The method assertEquals() does not seem to exist on object<MapUtilTest>.

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...
64
			'String to be sanitized',
65
			MapUtil::sanitize("String\r to be sanitized")
66
		);
67
	}
68
69
	public static function test_chooseToAddDataobject() {
70
71
	}
72
73
	private function htmlForMap() {
74
		$map = MapUtil::get_map(new ArrayList(),array());
75
		$html = $map->forTemplate();
76
		return $html;
77
	}
78
79
80
	// These appear to test code that's not used
81
	public function test_set_center() {
82
    	MapUtil::set_center('Bangkok, Thailand');
83
		$html = $this->htmlForMap();
84
		echo $html;
85
		$this->fail('No evidence of map type changing');
1 ignored issue
show
Bug introduced by
The method fail() does not seem to exist on object<MapUtilTest>.

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...
86
    }
87
88
     public function test_set_map_type() {
89
    	MapUtil::set_map_type('google.maps.MapTypeId.G_PHYSICAL_MAP');
90
		$html = $this->htmlForMap();
91
		echo $html;
92
		$this->fail('No evidence of map type changing');
1 ignored issue
show
Bug introduced by
The method fail() does not seem to exist on object<MapUtilTest>.

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...
93
    }
94
95
     public function test_set_info_window_width()  {
96
     	$this->fail('No evidence of set info width being used');
1 ignored issue
show
Bug introduced by
The method fail() does not seem to exist on object<MapUtilTest>.

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
99
     public function test_set_icon_size() {
100
101
    }
102
103
}
104