Passed
Branch master (41ef34)
by Roberto
04:08
created

GeometryTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 27
dl 0
loc 68
c 0
b 0
f 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testLocationSetterGetterViaArray() 0 16 1
A testLocationTypeSetterGetter() 0 7 1
A setUp() 0 5 1
A testLocationSetterGetter() 0 16 1
1
<?php
2
/**
3
 * Copyright (c) 2018 - present
4
 * Google Maps PHP - GeometryTest.php
5
 * author: Roberto Belotti - [email protected]
6
 * web : robertobelotti.com, github.com/biscolab
7
 * Initial version created on: 5/9/2018
8
 * MIT license: https://github.com/biscolab/google-maps-php/blob/master/LICENSE
9
 */
10
11
namespace Biscolab\geocode\Tests;
12
13
use Biscolab\GoogleMaps\Fields\LatLngFields;
14
use Biscolab\GoogleMaps\Object\Geometry;
15
use Biscolab\GoogleMaps\Object\Location;
16
use Biscolab\GoogleMaps\Values\GeometryLocationTypeValues;
17
use PHPUnit\Framework\TestCase;
18
19
/**
20
 * Class GeometryTest
21
 * @package Biscolab\geocode\Tests
22
 */
23
class GeometryTest extends TestCase {
24
25
	/**
26
	 * @var Geometry
27
	 */
28
	protected $geometry;
29
30
	public function setUp()/* The :void return type declaration that should be here would cause a BC issue */ {
31
32
		parent::setUp(); // TODO: Change the autogenerated stub
33
34
		$this->geometry = new Geometry();
35
	}
36
37
	/**
38
	 * @test
39
	 */
40
	public function testLocationSetterGetter() {
41
42
		$geometry = $this->geometry;
43
44
		$geometry->setLocation(new Location([
45
			LatLngFields::LAT => 20,
46
			LatLngFields::LNG => 33,
47
		]));
48
49
		$this->assertEquals(new Location([
50
			LatLngFields::LAT => 20,
51
			LatLngFields::LNG => 33,
52
		]), $geometry->getLocation());
53
54
		$this->assertEquals(20, $geometry->getLocation()->getLat());
55
		$this->assertEquals(33, $geometry->getLocation()->getLng());
56
57
	}
58
59
	/**
60
	 * @test
61
	 */
62
	public function testLocationSetterGetterViaArray() {
63
64
		$geometry = $this->geometry;
65
66
		$geometry->setLocation([
67
			LatLngFields::LAT => 20,
68
			LatLngFields::LNG => 33,
69
		]);
70
71
		$this->assertEquals(new Location([
72
			LatLngFields::LAT => 20,
73
			LatLngFields::LNG => 33,
74
		]), $geometry->getLocation());
75
76
		$this->assertEquals(20, $geometry->getLocation()->getLat());
77
		$this->assertEquals(33, $geometry->getLocation()->getLng());
78
79
	}
80
81
	/**
82
	 * @tets
83
	 */
84
	public function testLocationTypeSetterGetter() {
85
86
		$geometry = $this->geometry;
87
88
		$geometry->setLocationType(GeometryLocationTypeValues::ROOFTOP);
89
90
		$this->assertEquals(GeometryLocationTypeValues::ROOFTOP, $geometry->getLocationType());
91
92
	}
93
}
94