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
|
|
|
|