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