|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Clubdeuce\WPLib\Components\GoogleMaps\Tests\Unit; |
|
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\Integration |
|
11
|
|
|
* @coversDefaultClass Clubdeuce\WPLib\Components\GoogleMaps\Map_Model |
|
12
|
|
|
* @group Map |
|
13
|
|
|
*/ |
|
14
|
|
|
class TestMapModel extends TestCase { |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @var Map_Model |
|
18
|
|
|
*/ |
|
19
|
|
|
private $_model; |
|
20
|
|
|
|
|
21
|
|
|
public function setUp() { |
|
22
|
|
|
$this->_model = new Map_Model(array( |
|
23
|
|
|
'map' => $this->_mockMap(array('center' => array('lat' => 200, 'lng' => -200), 'zoom' => 13)), |
|
24
|
|
|
'label' => $this->mockLabel(), |
|
25
|
|
|
'marker' => $this->mockMarker(), |
|
26
|
|
|
)); |
|
27
|
|
|
parent::setUp(); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @covers ::has_map |
|
32
|
|
|
*/ |
|
33
|
|
|
public function testHasMap() { |
|
34
|
|
|
$this->assertTrue($this->_model->has_map()); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @covers ::has_map |
|
39
|
|
|
*/ |
|
40
|
|
|
public function testHasMapFalse() { |
|
41
|
|
|
$model = new Map_Model(array('map' => null)); |
|
42
|
|
|
$this->assertFalse($model->has_map()); |
|
43
|
|
|
} |
|
44
|
|
|
/** |
|
45
|
|
|
* @covers ::__call |
|
46
|
|
|
*/ |
|
47
|
|
|
public function testMagicMethods() { |
|
48
|
|
|
$this->assertEquals(array('lat' => 200, 'lng' => -200), $this->_model->center()); |
|
49
|
|
|
$this->assertEquals(13, $this->_model->zoom()); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @param array $args |
|
54
|
|
|
* |
|
55
|
|
|
* @return \Mockery\MockInterface |
|
56
|
|
|
*/ |
|
57
|
|
|
private function _mockMap($args = array() ) { |
|
58
|
|
|
$map = \Mockery::mock(\Clubdeuce\WPGoogleMaps\Map::class); |
|
59
|
|
|
|
|
60
|
|
|
foreach ( $args as $key => $val ) { |
|
61
|
|
|
$map->shouldReceive($key)->andReturn($val); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
return $map; |
|
65
|
|
|
} |
|
66
|
|
|
} |