Completed
Push — master ( 934849...10255c )
by Daryl
01:34
created

TestMarkerModel::testTitle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
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
 * @group              Marker
16
 */
17
class TestMarkerModel extends TestCase {
18
19
    /**
20
     * @var Marker_Model
21
     */
22
    private $_model;
23
24
    /**
25
     * @var Mock
26
     */
27
    private $_geocoder;
28
29
	/**
30
	 * @var array
31
	 */
32
	private $_position = array( 'lat' => 37.4224764, 'lng' => -122.0842499);
33
34
    public function setUp() {
35
36
        $this->_geocoder = $this->getMockGeocoder();
37
38
        $this->_model = new Marker_Model([
39
            'address'  => $this->_address,
40
            'geocoder' => $this->_geocoder,
41
	        'title'    => 'Sample Title'
42
        ]);
43
    }
44
45
46
    /**
47
     * @covers ::latitude
48
     */
49
    public function testLatitude() {
50
        $this->assertEquals($this->_position['lat'], $this->_model->latitude());
51
    }
52
53
    /**
54
     * @covers ::longitude
55
     */
56
    public function testLongitude() {
57
        $this->assertEquals($this->_position['lng'], $this->_model->longitude());
58
    }
59
60
    /**
61
     * @covers ::_geocoder
62
     */
63
    public function testGeocoder() {
64
        $this->assertEquals($this->_geocoder, $this->reflectionMethodInvoke($this->_model, '_geocoder'));
65
    }
66
67
    /**
68
     * @covers ::_geocoder
69
     */
70
    public function testCreateGeocoder() {
71
        $marker_model = new Marker_Model();
72
        $this->assertInstanceOf('\Clubdeuce\WPLib\Components\GoogleMaps\Geocoder',  $this->reflectionMethodInvoke($marker_model, '_geocoder'));
73
    }
74
75
	/**
76
	 * @covers ::position
77
	 */
78
    public function testPosition() {
79
    	$this->assertEquals($this->_position, $this->_model->position());
80
    }
81
82
	/**
83
	 * @covers ::title
84
	 */
85
    public function testTitle() {
86
    	$this->assertEquals('Sample Title', $this->_model->title());
87
    }
88
89
    public function testMarkerArgs() {
90
91
    	$args = $this->_model->marker_args();
92
93
	    $this->assertInternalType('array', $args);
94
	    $this->assertArrayHasKey('position', $args);
95
	    $this->assertArrayHasKey('label', $args);
96
	    $this->assertArrayHasKey('title', $args);
97
	    $this->assertEquals($this->_position, $args['position']);
98
	    $this->assertEquals('Sample Title', $args['title']);
99
    }
100
}
101