|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Clubdeuce\WPLib\Components\GoogleMaps\Tests\UnitTests; |
|
4
|
|
|
|
|
5
|
|
|
use Clubdeuce\WPLib\Components\GoogleMaps\Location; |
|
6
|
|
|
use Clubdeuce\WPLib\Components\GoogleMaps\Marker_Model; |
|
7
|
|
|
use Clubdeuce\WPLib\Components\GoogleMaps\Tests\TestCase; |
|
8
|
|
|
use Mockery\Loader; |
|
9
|
|
|
use Mockery\Mock; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Class TestMarkerModel |
|
13
|
|
|
* @package Clubdeuce\WPLib\Components\GoogleMaps\Tests\UnitTests |
|
14
|
|
|
* @coversDefaultClass Clubdeuce\WPLib\Components\GoogleMaps\Marker_Model |
|
15
|
|
|
*/ |
|
16
|
|
|
class TestMarkerModel extends TestCase { |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @var Location |
|
20
|
|
|
*/ |
|
21
|
|
|
private $_location; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @var Marker_Model |
|
25
|
|
|
*/ |
|
26
|
|
|
private $_model; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @var Mock |
|
30
|
|
|
*/ |
|
31
|
|
|
private $_geocoder; |
|
32
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
public function setUp() { |
|
35
|
|
|
$this->_location = new Location([ |
|
36
|
|
|
'address' => '123 Anywhere Street Anywhere NY', |
|
37
|
|
|
'formatted_address' => '123 Anywhere Street, Anywhere, NY 12345 USA', |
|
38
|
|
|
'latitude' => 100.12345, |
|
39
|
|
|
'longitude' => -100.12345, |
|
40
|
|
|
'place_id' => 'foobar', |
|
41
|
|
|
'types' => ['foo', 'bar'], |
|
42
|
|
|
'viewport' => ['northeast' => ['lat' => 100.12346, 'lng' => -100.12344], 'southwest' => ['lat' => 100.12344, 'lng' => -100.12346]], |
|
43
|
|
|
]); |
|
44
|
|
|
|
|
45
|
|
|
$this->_geocoder = \Mockery::mock('\Clubdeuce\WPLib\Components\GoogleMaps\Geocoder'); |
|
46
|
|
|
$this->_geocoder->shouldReceive('geocode')->andReturn($this->_location); |
|
47
|
|
|
|
|
48
|
|
|
$this->_model = new Marker_Model([ |
|
49
|
|
|
'address' => $this->_address, |
|
50
|
|
|
'geocoder' => $this->_geocoder, |
|
51
|
|
|
]); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @covers ::latitude |
|
57
|
|
|
*/ |
|
58
|
|
|
public function testLatitude() { |
|
59
|
|
|
$this->assertEquals(100.12345, $this->_model->latitude()); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @covers ::location |
|
64
|
|
|
*/ |
|
65
|
|
|
public function testLocation() { |
|
66
|
|
|
$this->assertEquals($this->_location, $this->_model->location()); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @covers ::longitude |
|
71
|
|
|
*/ |
|
72
|
|
|
public function testLongitude() { |
|
73
|
|
|
$this->assertEquals(-100.12345, $this->_model->longitude()); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @covers ::_geocoder |
|
78
|
|
|
*/ |
|
79
|
|
|
public function testGeocoder() { |
|
80
|
|
|
$this->assertEquals($this->_geocoder, $this->reflectionMethodInvoke($this->_model, '_geocoder')); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @covers ::_geocoder |
|
85
|
|
|
*/ |
|
86
|
|
|
public function testCreateGeocoder() { |
|
87
|
|
|
$marker_model = new Marker_Model(); |
|
88
|
|
|
$this->assertInstanceOf('\Clubdeuce\WPLib\Components\GoogleMaps\Geocoder', $this->reflectionMethodInvoke($marker_model, '_geocoder')); |
|
89
|
|
|
} |
|
90
|
|
|
} |