Completed
Pull Request — master (#22)
by Daryl
01:32
created

TestInfoWindowModel   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 57
rs 10
1
<?php
2
3
namespace Clubdeuce\WPLib\Components\GoogleMaps\Tests\Unit;
4
5
use Clubdeuce\WPGoogleMaps\Info_Window as MIW;
6
use Clubdeuce\WPLib\Components\GoogleMaps\Info_Window_Model;
7
use Clubdeuce\WPLib\Components\GoogleMaps\Tests\TestCase;
8
9
/**
10
 * Class TestInfoWindowModel
11
 * @package            Clubdeuce\WPLib\Components\GoogleMaps\Tests\Integration
12
 * @coversDefaultClass Clubdeuce\WPLib\Components\GoogleMaps\Info_Window_Model
13
 * @group              InfoWindow
14
 */
15
class TestInfoWindowModel extends TestCase {
16
17
	/**
18
	 * @var Info_Window_Model
19
	 */
20
	private $_model;
21
22
	public function setUp() {
23
24
		$this->_model = new Info_Window_Model(array('info_window' => self::_get_mock_info_window()));
25
		parent::setUp();
26
	}
27
28
	/**
29
	 * @covers ::__construct
30
	 * @covers ::__call
31
	 */
32
	public function testInfoWindowIsSet() {
33
		$this->assertEquals(self::_get_mock_info_window(), $this->_model->info_window());
34
	}
35
36
	/**
37
	 * @covers ::has_info_window
38
	 */
39
	public function testHasInfoWindow() {
40
		$this->assertTrue($this->_model->has_info_window());
41
	}
42
43
	/**
44
	 * @covers ::__call
45
	 */
46
	public function testMagicMethods() {
47
		$this->assertEquals('Sample Info Window Content', $this->_model->content());
48
		$this->assertEquals('12', $this->_model->pixel_offset());
49
		$this->assertEquals(array('lat' => 123.45, 'lng' => -123.45), $this->_model->position());
50
		$this->assertEquals('450px', $this->_model->max_width());
51
	}
52
53
	/**
54
	 * @covers ::__call
55
	 */
56
	public function testMagicMethodNull() {
57
		$window = new Info_Window_Model(array('info_window' => null));
58
59
		$this->assertNull($window->content());
60
	}
61
62
	/**
63
	 * @return \Mockery\MockInterface
64
	 */
65
	private function _get_mock_info_window() {
66
		$mock = \Mockery::mock(MIW::class);
67
		$mock->shouldReceive('content')->andReturn('Sample Info Window Content');
68
		$mock->shouldReceive('pixel_offset')->andReturn(12);
69
		$mock->shouldReceive('position')->andReturn(array('lat' => 123.45, 'lng' => -123.45));
70
		$mock->shouldReceive('max_width')->andReturn('450px');
71
72
		return $mock;
73
	}
74
}
75