Completed
Branch AUTOMATED_TESTING (6eabf7)
by Gordon
15:07
created

MapUtilTest::testSanitizeSlashT()   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
	/*
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());
22
		MapUtil::set_map_already_rendered(true);
23
		$this->assertTrue(MapUtil::get_map_already_rendered());
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(
36
			'',
37
			MapUtil::sanitize('')
38
		);
39
	}
40
41
	public function testSanitizeAlreadySanitized() {
42
		$this->assertEquals(
43
			'This is already sanitized',
44
			MapUtil::sanitize('This is already sanitized')
45
		);
46
	}
47
48
	public function testSanitizeSlashN() {
49
		$this->assertEquals(
50
			'String to be sanitized',
51
			MapUtil::sanitize("String\n to be sanitized")
52
		);
53
	}
54
55
	public function testSanitizeSlashT() {
56
		$this->assertEquals(
57
			'String to be sanitized',
58
			MapUtil::sanitize("String\t to be sanitized")
59
		);
60
	}
61
62
	public function testSanitizeSlashR() {
63
		$this->assertEquals(
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');
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');
93
    }
94
95
     public function test_set_info_window_width()  {
96
     	$this->fail('No evidence of set info width being used');
97
    }
98
99
     public function test_set_icon_size() {
100
101
    }
102
103
}
104