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

TestMarker   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 4
dl 0
loc 56
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 7 1
A testLocation() 0 11 1
A testInfoWindow() 0 8 1
A testMarkerLabel() 0 9 1
1
<?php
2
3
namespace Clubdeuce\WPLib\Components\GoogleMaps\Tests\Integration;
4
5
use Clubdeuce\WPLib\Components\GoogleMaps\Marker;
6
use Clubdeuce\WPLib\Components\GoogleMaps\Marker_Model;
7
use Clubdeuce\WPLib\Components\GoogleMaps\Tests\TestCase;
8
9
/**
10
 * Class TestMarkerModel
11
 * @package            Clubdeuce\WPLib\Components\GoogleMaps\Tests\Integration
12
 * @coversDefaultClass Clubdeuce\WPLib\Components\GoogleMaps\Marker_Model
13
 * @group              Marker
14
 * @group              Integration
15
 */
16
class TestMarker extends TestCase {
17
18
	/**
19
	 * @var Marker
20
	 */
21
	private $_marker;
22
23
	public function setUp() {
24
		$this->_marker = new Marker(array(
25
			'address'  => '1600 Amphitheatre Parkway, Mountain View, CA 94043, USA',
26
			'title'    => 'Sample Location'
27
		));
28
		parent::setUp();
29
	}
30
31
	/**
32
	 * @covers ::location
33
	 */
34
	public function testLocation() {
35
		$marker = $this->_marker;
36
37
		$this->assertInstanceOf('\Clubdeuce\WPLib\Components\GoogleMaps\Location', $this->_marker->location());
0 ignored issues
show
Documentation Bug introduced by
The method location does not exist on object<Clubdeuce\WPLib\C...ents\GoogleMaps\Marker>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
38
		$this->assertInstanceOf('\Clubdeuce\WPLib\Components\GoogleMaps\Marker_Label', $marker->label());
39
		$this->assertInternalType('double', $marker->latitude());
40
		$this->assertInternalType('double', $marker->longitude());
41
		$this->assertInternalType('string', $marker->title());
42
		$this->assertInstanceOf('\Clubdeuce\WPLib\Components\GoogleMaps\Info_Window', $marker->info_window());
43
		$this->assertInternalType('array', $marker->marker_args());
44
	}
45
46
	/**
47
	 * @coversNothing
48
	 */
49
	public function testInfoWindow() {
50
		$window = $this->_marker->info_window();
51
52
		$this->assertInternalType('string', $window->content());
53
		$this->assertInternalType('integer', $window->pixel_offset());
54
		$this->assertInternalType('array', $window->position());
55
		$this->assertNull($window->max_width());
56
	}
57
58
	/**
59
	 * @coversNothing
60
	 */
61
	public function testMarkerLabel() {
62
		$label = $this->_marker->label();
63
64
		$this->assertInternalType('string', $label->color(), 'Color is not a string');
65
		$this->assertInternalType('string', $label->font_family(), 'font_family is not a string');
66
		$this->assertInternalType('string', $label->font_size(), 'font_size is not a string');
67
		$this->assertInternalType('string', $label->font_weight());
68
		$this->assertInternalType('string', $label->text());
69
	}
70
71
}
72