|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare( strict_types = 1 ); |
|
4
|
|
|
|
|
5
|
|
|
namespace Maps\Tests\Unit\Presentation; |
|
6
|
|
|
|
|
7
|
|
|
use DataValues\Geo\Values\LatLongValue; |
|
8
|
|
|
use Maps\LegacyModel\Location; |
|
9
|
|
|
use Maps\Presentation\KmlFormatter; |
|
10
|
|
|
use PHPUnit\Framework\TestCase; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @covers \Maps\Presentation\KmlFormatter |
|
14
|
|
|
* |
|
15
|
|
|
* @licence GNU GPL v2+ |
|
16
|
|
|
* @author Jeroen De Dauw < [email protected] > |
|
17
|
|
|
*/ |
|
18
|
|
|
class KmlFormatterTest extends TestCase { |
|
19
|
|
|
|
|
20
|
|
|
public function testEmptyList() { |
|
21
|
|
|
$this->assertSame( |
|
22
|
|
|
'<?xml version="1.0" encoding="UTF-8"?> |
|
23
|
|
|
<kml xmlns="http://www.opengis.net/kml/2.2"> |
|
24
|
|
|
<Document> |
|
25
|
|
|
|
|
26
|
|
|
</Document> |
|
27
|
|
|
</kml>', |
|
28
|
|
|
( new KmlFormatter() )->formatLocationsAsKml() |
|
29
|
|
|
); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function testSeveralLocations() { |
|
33
|
|
|
$this->assertSame( |
|
34
|
|
|
'<?xml version="1.0" encoding="UTF-8"?> |
|
35
|
|
|
<kml xmlns="http://www.opengis.net/kml/2.2"> |
|
36
|
|
|
<Document> |
|
37
|
|
|
<Placemark> |
|
38
|
|
|
<name><![CDATA[first title]]></name> |
|
39
|
|
|
<description><![CDATA[first text]]></description> |
|
40
|
|
|
<Point> |
|
41
|
|
|
<coordinates>23,42.42,0</coordinates> |
|
42
|
|
|
</Point> |
|
43
|
|
|
</Placemark> |
|
44
|
|
|
<Placemark> |
|
45
|
|
|
<name><![CDATA[second title]]></name> |
|
46
|
|
|
<description><![CDATA[second text]]></description> |
|
47
|
|
|
<Point> |
|
48
|
|
|
<coordinates>0,-1,0</coordinates> |
|
49
|
|
|
</Point> |
|
50
|
|
|
</Placemark> |
|
51
|
|
|
</Document> |
|
52
|
|
|
</kml>', |
|
53
|
|
|
( new KmlFormatter() )->formatLocationsAsKml( |
|
54
|
|
|
new Location( |
|
55
|
|
|
new LatLongValue( 42.42,23 ), |
|
56
|
|
|
'first title', |
|
57
|
|
|
'first text' |
|
58
|
|
|
), |
|
59
|
|
|
new Location( |
|
60
|
|
|
new LatLongValue( -1,0 ), |
|
61
|
|
|
'second title', |
|
62
|
|
|
'second text' |
|
63
|
|
|
) |
|
64
|
|
|
) |
|
65
|
|
|
); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function testLocationWithoutTitleAndText() { |
|
69
|
|
|
$this->assertSame( |
|
70
|
|
|
'<?xml version="1.0" encoding="UTF-8"?> |
|
71
|
|
|
<kml xmlns="http://www.opengis.net/kml/2.2"> |
|
72
|
|
|
<Document> |
|
73
|
|
|
<Placemark> |
|
74
|
|
|
<name><![CDATA[]]></name> |
|
75
|
|
|
<description><![CDATA[]]></description> |
|
76
|
|
|
<Point> |
|
77
|
|
|
<coordinates>23,42.42,0</coordinates> |
|
78
|
|
|
</Point> |
|
79
|
|
|
</Placemark> |
|
80
|
|
|
</Document> |
|
81
|
|
|
</kml>', |
|
82
|
|
|
( new KmlFormatter() )->formatLocationsAsKml( |
|
83
|
|
|
new Location( |
|
84
|
|
|
new LatLongValue( 42.42,23 ) |
|
85
|
|
|
) |
|
86
|
|
|
) |
|
87
|
|
|
); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
} |
|
91
|
|
|
|