Completed
Push — MediaWikiFileUrlFinderTest ( d58bee )
by Jeroen De
03:36
created

RectangleTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 3
dl 0
loc 57
rs 10
c 0
b 0
f 0

5 Methods

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