|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Clubdeuce\WPLib\Components\GoogleMaps\Tests\UnitTests; |
|
4
|
|
|
|
|
5
|
|
|
use Clubdeuce\WPLib\Components\GoogleMaps\Map_Model; |
|
6
|
|
|
use Clubdeuce\WPLib\Components\GoogleMaps\Tests\TestCase; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Class testMapModel |
|
10
|
|
|
* @package Clubdeuce\WPLib\Components\GoogleMaps\Tests\UnitTests |
|
11
|
|
|
* @coversDefaultClass Clubdeuce\WPLib\Components\GoogleMaps\Map_Model |
|
12
|
|
|
* @group Map |
|
13
|
|
|
*/ |
|
14
|
|
|
class testMapModel extends TestCase { |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @var array |
|
18
|
|
|
*/ |
|
19
|
|
|
private $_center = array( 'lat' => 100.23435532, 'lng' => -100.1234642345325 ); |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @var Map_Model |
|
23
|
|
|
*/ |
|
24
|
|
|
private $_model; |
|
25
|
|
|
|
|
26
|
|
|
public function setUp() { |
|
27
|
|
|
|
|
28
|
|
|
$this->_model = new Map_Model(array('center' => $this->_center, 'markers' => array('foo', 'bar', 'baz'), 'zoom' => 12)); |
|
29
|
|
|
|
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @covers ::center |
|
34
|
|
|
*/ |
|
35
|
|
|
public function testCenter() { |
|
36
|
|
|
|
|
37
|
|
|
$this->assertEquals($this->_center, $this->_model->center()); |
|
38
|
|
|
|
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @covers ::markers |
|
43
|
|
|
*/ |
|
44
|
|
|
public function testMarkers() { |
|
45
|
|
|
|
|
46
|
|
|
$this->assertEquals(array('foo','bar','baz'), $this->_model->markers()); |
|
47
|
|
|
|
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @depends testMarkers |
|
52
|
|
|
* @covers ::add_marker |
|
53
|
|
|
*/ |
|
54
|
|
|
function testAddMarker() { |
|
55
|
|
|
|
|
56
|
|
|
$this->_model->add_marker('foobar'); |
|
|
|
|
|
|
57
|
|
|
|
|
58
|
|
|
$this->assertContains('foobar', $this->_model->markers()); |
|
59
|
|
|
|
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @depends testMarkers |
|
64
|
|
|
* @covers ::add_markers |
|
65
|
|
|
*/ |
|
66
|
|
|
function testAddMarkers() { |
|
67
|
|
|
|
|
68
|
|
|
$this->_model->add_markers(array('foobar', 'barbaz')); |
|
|
|
|
|
|
69
|
|
|
|
|
70
|
|
|
$markers = $this->_model->markers(); |
|
71
|
|
|
|
|
72
|
|
|
$this->assertContains('foobar', $markers); |
|
73
|
|
|
$this->assertContains('barbaz', $markers); |
|
74
|
|
|
|
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @covers ::zoom |
|
79
|
|
|
*/ |
|
80
|
|
|
public function testZoom() { |
|
81
|
|
|
$this->assertEquals(12, $this->_model->zoom()); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @covers ::make_args |
|
86
|
|
|
*/ |
|
87
|
|
|
public function testMakeArgs() { |
|
88
|
|
|
|
|
89
|
|
|
$args = $this->_model->make_args(); |
|
90
|
|
|
|
|
91
|
|
|
$this->assertInternalType('array', $args); |
|
92
|
|
|
$this->assertArrayHasKey('center', $args); |
|
93
|
|
|
$this->assertArrayHasKey('zoom', $args); |
|
94
|
|
|
$this->assertInternalType('array', $args['center']); |
|
95
|
|
|
$this->assertInternalType('integer', $args['zoom']); |
|
96
|
|
|
$this->assertArrayHasKey('lat', $args['center']); |
|
97
|
|
|
$this->assertArrayHasKey('lat', $args['center']); |
|
98
|
|
|
$this->assertInternalType('float', $args['center']['lat']); |
|
99
|
|
|
$this->assertInternalType('float', $args['center']['lng']); |
|
100
|
|
|
|
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* @covers ::height |
|
105
|
|
|
*/ |
|
106
|
|
|
public function testHeight() { |
|
107
|
|
|
|
|
108
|
|
|
$this->assertEquals('400px', $this->_model->height()); |
|
109
|
|
|
|
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* @covers ::width |
|
114
|
|
|
*/ |
|
115
|
|
|
public function testWidth() { |
|
116
|
|
|
|
|
117
|
|
|
$this->assertEquals('100%', $this->_model->width()); |
|
118
|
|
|
|
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* @covers ::html_id |
|
123
|
|
|
*/ |
|
124
|
|
|
public function testHtmlId() { |
|
125
|
|
|
|
|
126
|
|
|
$id = $this->_model->html_id(); |
|
127
|
|
|
|
|
128
|
|
|
$this->assertInternalType('string', $id); |
|
129
|
|
|
$this->assertStringStartsWith('map-', $id); |
|
130
|
|
|
|
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
} |
|
134
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: