Skip to content

Commit

Permalink
Add extra KML test
Browse files Browse the repository at this point in the history
  • Loading branch information
JeroenDeDauw committed Nov 20, 2018
1 parent 1e6ec73 commit 234d289
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Presentation/KmlFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ function( Location $location ) {

private function locationToKmlPlacemark( Location $location ): string {
// TODO: escaping?
$name = '<name><![CDATA[ ' . $location->getTitle() . ']]></name>';
$name = '<name><![CDATA[' . $location->getTitle() . ']]></name>';

// TODO: escaping?
$description = '<description><![CDATA[ ' . $location->getText() . ']]></description>';
$description = '<description><![CDATA[' . $location->getText() . ']]></description>';

$coordinates = '<coordinates>'
. $this->escapeValue( $this->getCoordinateString( $location ) )
Expand Down
30 changes: 26 additions & 4 deletions tests/Unit/Presentation/KmlFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ public function testSeveralLocations() {
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Placemark>
<name><![CDATA[ first title]]></name>
<description><![CDATA[ first text]]></description>
<name><![CDATA[first title]]></name>
<description><![CDATA[first text]]></description>
<Point>
<coordinates>23,42.42,0</coordinates>
</Point>
</Placemark>
<Placemark>
<name><![CDATA[ second title]]></name>
<description><![CDATA[ second text]]></description>
<name><![CDATA[second title]]></name>
<description><![CDATA[second text]]></description>
<Point>
<coordinates>0,-1,0</coordinates>
</Point>
Expand All @@ -63,4 +63,26 @@ public function testSeveralLocations() {
);
}

public function testLocationWithoutTitleAndText() {
$this->assertSame(
'<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Placemark>
<name><![CDATA[]]></name>
<description><![CDATA[]]></description>
<Point>
<coordinates>23,42.42,0</coordinates>
</Point>
</Placemark>
</Document>
</kml>',
( new KmlFormatter() )->formatLocationsAsKml(
new Location(
new LatLongValue( 42.42,23 )
)
)
);
}

}

0 comments on commit 234d289

Please sign in to comment.