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