-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathgmap.php
171 lines (161 loc) · 3.76 KB
/
gmap.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?php
/**
* Tests the Google Maps Module.
*
* @group Google Maps Module
*
* @package Unittest
* @author Leonard Fischer <[email protected]>
*/
Class GmapTest extends Kohana_Unittest_TestCase
{
/**
* Provides maptype test data()
*
* @return array
*/
public function provider_maptype()
{
return array(
array('road'),
array('satellite'),
array('hybrid'),
array('terrain'),
);
}
/**
* Tests the exception, thrown by the validate_latitude method.
*
* @test
* @covers Gmap::set_pos
* @covers Gmap::validate_latitude
* @expectedException Kohana_Exception
*/
function test_validate_latitude_exception_if_higher_than_180()
{
$map = new Gmap();
$map->set_pos(180.1, NULL);
} // function
/**
* Tests the exception, thrown by the validate_latitude method.
*
* @test
* @covers Gmap::set_pos
* @covers Gmap::validate_latitude
* @expectedException Kohana_Exception
*/
function test_validate_latitude_exception_if_lower_than_minus180()
{
$map = new Gmap();
$map->set_pos(-180.1, NULL);
} // function
/**
* Tests the exception, thrown by the validate_longitude method.
*
* @test
* @covers Gmap::set_pos
* @covers Gmap::validate_longitude
* @expectedException Kohana_Exception
*/
function test_validate_longitude_exception_if_higher_than_90()
{
$map = new Gmap();
$map->set_pos(NULL, 90.1);
} // function
/**
* Tests the exception, thrown by the validate_longitude method.
*
* @test
* @covers Gmap::set_pos
* @covers Gmap::validate_longitude
* @expectedException Kohana_Exception
*/
function test_validate_longitude_exception_if_lower_than_minus90()
{
$map = new Gmap();
$map->set_pos(NULL, -90.1);
} // function
/**
* Tests the validate_maptype method.
*
* @test
* @covers Gmap::set_maptype
* @covers Gmap::validate_maptype
* @dataProvider provider_maptype
*/
function test_validate_maptype($maptype)
{
$map = new Gmap();
$this->assertSame($map ,$map->set_maptype($maptype));
} // function
/**
* Tests the exception, thrown by the validate_maptype method.
*
* @test
* @covers Gmap::set_maptype
* @covers Gmap::validate_maptype
* @expectedException Kohana_Exception
*/
function test_validate_maptype_exception()
{
$map = new Gmap();
$map->set_maptype('NotExisting');
} // function
/**
* Tests the setting options through the constructor.
*
* @test
* @covers Gmap::__construct
* @covers Gmap::get_option
*/
function test_constructor_options_parameter()
{
$options = array(
'abc' => 123,
'def' => TRUE,
'ghi' => FALSE,
'jkl' => array(),
'lat' => 12.34,
'lng' => 34.56,
'zoom' => 10,
'sensor' => TRUE,
'maptype' => 'terrain',
'view' => 'gmap_demo',
'gmap_size_x' => 666,
'gmap_size_y' => 333,
'gmap_controls' => array(
'maptype' => array('display' => FALSE),
'navigation' => array('display' => FALSE),
'scale' => array('display' => FALSE),
),
);
$map = new Gmap($options);
$expected = array(
'lat' => 12.34,
'lng' => 34.56,
'zoom' => 10,
'sensor' => TRUE,
'maptype' => 'terrain',
'view' => 'gmap_demo',
'gmap_size_x' => 666,
'gmap_size_y' => 333,
'gmap_controls' => array(
'maptype' => array('display' => FALSE),
'navigation' => array('display' => FALSE),
'scale' => array('display' => FALSE),
),
);
$this->assertEquals($expected, $map->get_option());
} // function
/**
* Tests the factory method.
*
* @test
* @covers Gmap::__construct
* @covers Gmap::factory
*/
function test_factory_metod()
{
$this->assertEquals(new Gmap(), Gmap::factory());
} // function
} // class