|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Clubdeuce\WPLib\Components\GoogleMaps\Tests\UnitTests; |
|
4
|
|
|
|
|
5
|
|
|
use Clubdeuce\WPLib\Components\GoogleMaps\Marker_Model; |
|
6
|
|
|
use Clubdeuce\WPLib\Components\GoogleMaps\Tests\TestCase; |
|
7
|
|
|
use Mockery\Mock; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Class TestMarkerModel |
|
11
|
|
|
* @package Clubdeuce\WPLib\Components\GoogleMaps\Tests\UnitTests |
|
12
|
|
|
* @coversDefaultClass Clubdeuce\WPLib\Components\GoogleMaps\Marker_Model |
|
13
|
|
|
*/ |
|
14
|
|
|
class TestMarkerModel extends TestCase { |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @var Marker_Model |
|
18
|
|
|
*/ |
|
19
|
|
|
private $_model; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @var string |
|
23
|
|
|
*/ |
|
24
|
|
|
private $_address = '1600 Amphitheatre Parkway Mountain View CA'; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @var Mock |
|
28
|
|
|
*/ |
|
29
|
|
|
private $_geocoder; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var array |
|
33
|
|
|
*/ |
|
34
|
|
|
private $_latlng = ['lat' => 100.2345325, 'lng' => -45.23423423567]; |
|
35
|
|
|
|
|
36
|
|
|
public function setUp() { |
|
37
|
|
|
$this->_geocoder = \Mockery::mock('\Clubdeuce\WPLib\Components\GoogleMaps\Geocoder'); |
|
38
|
|
|
$this->_geocoder->shouldReceive('geocode')->andReturn($this->_latlng); |
|
39
|
|
|
|
|
40
|
|
|
$this->_model = new Marker_Model([ |
|
41
|
|
|
'address' => $this->_address, |
|
42
|
|
|
'geocoder' => $this->_geocoder, |
|
43
|
|
|
]); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @covers ::latlng_object |
|
49
|
|
|
*/ |
|
50
|
|
|
public function testLatLngObject() { |
|
51
|
|
|
$latlng = $this->_model->latlng_object(); |
|
52
|
|
|
|
|
53
|
|
|
$this->assertJson($latlng); |
|
54
|
|
|
$this->assertEquals(json_encode($this->_latlng), $latlng); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @covers ::_geocoder |
|
59
|
|
|
*/ |
|
60
|
|
|
public function testGeocoder() { |
|
61
|
|
|
$this->assertEquals($this->_geocoder, $this->reflectionMethodInvoke($this->_model, '_geocoder')); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @covers ::_geocoder |
|
66
|
|
|
*/ |
|
67
|
|
|
public function testCreateGeocoder() { |
|
68
|
|
|
$marker_model = new Marker_Model(); |
|
69
|
|
|
$this->assertInstanceOf('\Clubdeuce\WPLib\Components\GoogleMaps\Geocoder', $this->reflectionMethodInvoke($marker_model, '_geocoder')); |
|
70
|
|
|
} |
|
71
|
|
|
} |