1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Clubdeuce\WPLib\Components\GoogleMaps\Tests\Unit; |
4
|
|
|
|
5
|
|
|
use Clubdeuce\WPGoogleMaps\Location as MLoc; |
6
|
|
|
use Clubdeuce\WPGoogleMaps\Location as Loc; |
7
|
|
|
use Clubdeuce\WPLib\Components\GoogleMaps\Location_Model; |
8
|
|
|
use Clubdeuce\WPLib\Components\GoogleMaps\Tests\TestCase; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class TestLocationModel |
12
|
|
|
* @package Clubdeuce\WPLib\Components\GoogleMaps\Tests\Integration |
13
|
|
|
* @coversDefaultClass Clubdeuce\WPLib\Components\GoogleMaps\Location_Model |
14
|
|
|
* @group Location |
15
|
|
|
*/ |
16
|
|
|
class TestLocationModel extends TestCase { |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @var Location_Model |
20
|
|
|
*/ |
21
|
|
|
private $_location; |
22
|
|
|
|
23
|
|
|
public function setUp() { |
24
|
|
|
$this->_location = new Location_Model(array('location' => $this->_getMockLocation())); |
25
|
|
|
parent::setUp(); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @covers ::__construct |
30
|
|
|
* @covers ::__call |
31
|
|
|
*/ |
32
|
|
|
public function testConstruct() { |
33
|
|
|
$this->assertEquals(self::_getMockLocation(), $this->_location->location()); |
|
|
|
|
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @covers ::__construct |
38
|
|
|
* @covers ::__call |
39
|
|
|
*/ |
40
|
|
|
public function testConstructDefaults() { |
41
|
|
|
$location = new Location_Model(); |
42
|
|
|
$this->assertTrue($location->has_location()); |
43
|
|
|
$this->assertInstanceOf(Loc::class, $location->location()); |
|
|
|
|
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @covers ::__construct |
48
|
|
|
* @covers ::has_location |
49
|
|
|
*/ |
50
|
|
|
public function testHasLocation() { |
51
|
|
|
$this->assertTrue($this->_location->has_location()); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @covers ::__call |
56
|
|
|
*/ |
57
|
|
|
public function testMagicMethodCall() { |
58
|
|
|
$this->assertEquals('bar', $this->_location->foo()); |
|
|
|
|
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @covers ::__call |
63
|
|
|
*/ |
64
|
|
|
public function testMagicMethodCallNull() { |
65
|
|
|
$location = new Location_Model(array('location' => null)); |
66
|
|
|
$this->assertNull($location->latitude()); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @return \Mockery\MockInterface |
71
|
|
|
*/ |
72
|
|
|
private function _getMockLocation() { |
73
|
|
|
$location = \Mockery::mock(MLoc::class); |
74
|
|
|
|
75
|
|
|
$location->shouldReceive('foo')->andReturn('bar'); |
76
|
|
|
|
77
|
|
|
return $location; |
78
|
|
|
} |
79
|
|
|
} |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.