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

ViewportTest::testViewportSetterGetter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 27
c 0
b 0
f 0
rs 9.7
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * Copyright (c) 2018 - present
4
 * Google Maps PHP - ViewportTest.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\LatLngBoundsFields;
14
use Biscolab\GoogleMaps\Fields\LatLngFields;
15
use Biscolab\GoogleMaps\Object\LatLng;
16
use Biscolab\GoogleMaps\Object\LatLngBounds;
17
use Biscolab\GoogleMaps\Object\Viewport;
18
use PHPUnit\Framework\TestCase;
19
20
/**
21
 * Class ViewportTest
22
 * @package Biscolab\geocode\Tests
23
 */
24
class ViewportTest extends TestCase {
25
26
	/**
27
	 * @var LatLngBounds
28
	 */
29
	private $viewport;
30
31
	public function setUp()/* The :void return type declaration that should be here would cause a BC issue */ {
32
33
		parent::setUp(); // TODO: Change the autogenerated stub
34
35
		$this->viewport = new Viewport();
36
	}
37
38
	/**
39
	 * @test
40
	 */
41
	public function testViewportSetterGetter() {
42
43
		$viewport = $this->viewport;
44
45
		$southwest = new LatLng([
46
			LatLngFields::LAT => 20.89,
47
			LatLngFields::LNG => -40.82,
48
		]);
49
50
		$northeast = new LatLng([
51
			LatLngFields::LAT => 22.73,
52
			LatLngFields::LNG => 3.6370,
53
		]);
54
55
		$viewport->setSouthwest($southwest);
0 ignored issues
show
Bug introduced by
The method setSouthwest() does not exist on Biscolab\GoogleMaps\Object\LatLngBounds. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

55
		$viewport->/** @scrutinizer ignore-call */ 
56
             setSouthwest($southwest);
Loading history...
56
		$viewport->setNortheast($northeast);
0 ignored issues
show
Bug introduced by
The method setNortheast() does not exist on Biscolab\GoogleMaps\Object\LatLngBounds. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

56
		$viewport->/** @scrutinizer ignore-call */ 
57
             setNortheast($northeast);
Loading history...
57
58
		$this->assertEquals(new Viewport([
59
			LatLngBoundsFields::SOUTHWEST => [
60
				LatLngFields::LAT => 20.89,
61
				LatLngFields::LNG => -40.82,
62
			],
63
			LatLngBoundsFields::NORTHEAST => [
64
				LatLngFields::LAT => 22.73,
65
				LatLngFields::LNG => 3.6370,
66
			],
67
		]), $viewport);
68
69
	}
70
}
71