Completed
Branch AUTOMATED_TESTING (09d9f2)
by Gordon
13:24
created

MapUtilTest::testSanitizeSlashR()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 6
rs 9.4286
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
class MapUtilTest extends SapphireTest {
4
5
	/*
0 ignored issues
show
Unused Code Comprehensibility introduced by
42% 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...
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
	public function setUpOnce() {
13
		$this->requiredExtensions = array(
14
			'Member' => array('MapExtension')
15
		);
16
		parent::setupOnce();
17
	}
18
*/
19
20
	public function test_set_api_key() {
21
		MapUtil::set_api_key('PRETENDAPIKEY');
22
		$html = $this->htmlForMap();
23
		echo $html;
24
		$this->fail('Where is this used?');
25
	}
26
27
	public function test_get_set_map_already_rendered() {
28
		MapUtil::set_map_already_rendered(false);
29
		$this->assertFalse(MapUtil::get_map_already_rendered());
30
		MapUtil::set_map_already_rendered(true);
31
		$this->assertTrue(MapUtil::get_map_already_rendered());
32
	}
33
34
	public function test_set_map_size() {
35
		MapUtil::set_map_size('890px','24em');
36
		$html = $this->htmlForMap();
37
		$this->assertContains(' style="width:890px; height: 24em;"', $html);
38
	}
39
40
	public function testSanitizeEmptyString() {
41
		$this->assertEquals(
42
			'',
43
			MapUtil::sanitize('')
44
		);
45
	}
46
47
	public function testSanitizeAlreadySanitized() {
48
		$this->assertEquals(
49
			'This is already sanitized',
50
			MapUtil::sanitize('This is already sanitized')
51
		);
52
	}
53
54
	public function testSanitizeSlashN() {
55
		$this->assertEquals(
56
			'String to be sanitized',
57
			MapUtil::sanitize("String\n to be sanitized")
58
		);
59
	}
60
61
	public function testSanitizeSlashT() {
62
		$this->assertEquals(
63
			'String to be sanitized',
64
			MapUtil::sanitize("String\t to be sanitized")
65
		);
66
	}
67
68
	public function testSanitizeSlashR() {
69
		$this->assertEquals(
70
			'String to be sanitized',
71
			MapUtil::sanitize("String\r to be sanitized")
72
		);
73
	}
74
75
	public function testSingularMappableItem() {
76
		Member::add_extension('MapExtension');
77
		$member = new Member();
78
		$member->Lat = 12.847;
79
		$member->Lon = 29.24;
80
		$list = new ArrayList();
81
		$list->push($member);
82
		$map = MapUtil::get_map($list,array());
83
		$html = $map->forTemplate();
84
		echo $html;
85
		$this->fail('No change observed in generated HTML');
86
		Member::remove_extension('MapExtension');
87
	}
88
89
	private function htmlForMap() {
90
		$map = MapUtil::get_map(new ArrayList(),array());
91
		$html = $map->forTemplate();
92
		return $html;
93
	}
94
95
96
	// These appear to test code that's not used
97
	public function test_set_center() {
98
		MapUtil::set_center('Bangkok, Thailand');
99
		$html = $this->htmlForMap();
100
		echo $html;
101
		$this->fail('No evidence of map type changing');
102
	}
103
104
	 public function test_set_map_type() {
105
		MapUtil::set_map_type('google.maps.MapTypeId.G_PHYSICAL_MAP');
106
		$html = $this->htmlForMap();
107
		echo $html;
108
		$this->fail('No evidence of map type changing');
109
	}
110
111
	 public function test_set_info_window_width()  {
112
	 	$this->fail('No evidence of set info width being used');
113
	}
114
115
	 public function test_set_icon_size() {
116
117
	}
118
119
}
120