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