RectangleTest::testSetCorners()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace Maps\Tests\Unit\LegacyModel;
6
7
use DataValues\Geo\Values\LatLongValue;
8
use Maps\LegacyModel\Rectangle;
9
10
/**
11
 * @covers \Maps\LegacyModel\Rectangle
12
 *
13
 * @licence GNU GPL v2+
14
 * @author Jeroen De Dauw < [email protected] >
15
 */
16
class RectangleTest extends BaseElementTest {
17
18
	/**
19
	 * @see BaseElementTest::getClass
20
	 *
21
	 * @since 3.0
22
	 *
23
	 * @return string
24
	 */
25
	public function getClass() {
26
		return Rectangle::class;
27
	}
28
29
	public function validConstructorProvider() {
30
		$argLists = [];
31
32
		$argLists[] = [ new LatLongValue( 4, 2 ), new LatLongValue( -4, -2 ) ];
33
		$argLists[] = [ new LatLongValue( -42, -42 ), new LatLongValue( -4, -2 ) ];
34
35
		return $argLists;
36
	}
37
38
	public function invalidConstructorProvider() {
39
		$argLists = [];
40
41
		$argLists[] = [ new LatLongValue( 4, 2 ), new LatLongValue( 4, 2 ) ];
42
43
		return $argLists;
44
	}
45
46
	/**
47
	 * @dataProvider instanceProvider
48
	 */
49
	public function testGetCorners( Rectangle $rectangle, array $arguments ) {
50
		$this->assertTrue( $rectangle->getRectangleNorthEast()->equals( $arguments[0] ) );
51
		$this->assertTrue( $rectangle->getRectangleSouthWest()->equals( $arguments[1] ) );
52
	}
53
54
	/**
55
	 * @dataProvider instanceProvider
56
	 */
57
	public function testSetCorners( Rectangle $rectangle ) {
58
		$coordinates = [
59
			new LatLongValue( 42, 42 ),
60
			new LatLongValue( 0, 0 )
61
		];
62
63
		foreach ( $coordinates as $coordinate ) {
64
			$rectangle->setRectangleNorthEast( $coordinate );
65
			$this->assertTrue( $rectangle->getRectangleNorthEast()->equals( $coordinate ) );
66
67
			$rectangle->setRectangleSouthWest( $coordinate );
68
			$this->assertTrue( $rectangle->getRectangleSouthWest()->equals( $coordinate ) );
69
		}
70
	}
71
72
}
73
74
75
76