Skip to content

Commit 0c4e061

Browse files
committed
KML Style parsing acceptance tests
1 parent 150b4e6 commit 0c4e061

3 files changed

Lines changed: 140 additions & 0 deletions

File tree

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
Feature: Parse <Document>
2+
In order to manipulate a KML document
3+
As an user
4+
I need <Document> tag to be parsed as a Document object
5+
6+
Scenario: Style with a Balloon
7+
Given a KML document with a Document in "tests/kml/document.kml"
8+
When I parse the KML document
9+
Then I should get a KmlDocument object containing one feature 'LibKml\Domain\Feature\Container\Document'
10+
And the feature should contain a Style object with the following properties:
11+
| property | value |
12+
| id | style-1 |
13+
| targetId | target-1 |
14+
And the Style should contain a BalloonStyle with the following properties:
15+
| property | value |
16+
| bgColor | ffffffbb |
17+
| textColor | ff00aabb |
18+
| text | $[name] |
19+
| displayMode | random |
20+
21+
Scenario: Style with a IconStyle
22+
Given a KML document with a Document in "tests/kml/document.kml"
23+
When I parse the KML document
24+
Then I should get a KmlDocument object containing one feature 'LibKml\Domain\Feature\Container\Document'
25+
And the feature should contain a Style object with the following properties:
26+
| property | value |
27+
| id | style-1 |
28+
| targetId | target-1 |
29+
And the Style should contain a IconStyle with the following properties:
30+
| property | value |
31+
| color | ff00bbcc |
32+
| colorMode | random |
33+
| scale | 0.5 |
34+
| heading | 2.56 |
35+
36+
Scenario: Style with a LabelStyle
37+
Given a KML document with a Document in "tests/kml/document.kml"
38+
When I parse the KML document
39+
Then I should get a KmlDocument object containing one feature 'LibKml\Domain\Feature\Container\Document'
40+
And the feature should contain a Style object with the following properties:
41+
| property | value |
42+
| id | style-1 |
43+
| targetId | target-1 |
44+
And the Style should contain a LabelStyle with the following properties:
45+
| property | value |
46+
| color | ffaabbcc |
47+
| colorMode | random |
48+
| scale | 0.75 |
49+
| heading | 56.42 |
50+
51+
Scenario: Style with a LineStyle
52+
Given a KML document with a Document in "tests/kml/document.kml"
53+
When I parse the KML document
54+
Then I should get a KmlDocument object containing one feature 'LibKml\Domain\Feature\Container\Document'
55+
And the feature should contain a Style object with the following properties:
56+
| property | value |
57+
| id | style-1 |
58+
| targetId | target-1 |
59+
And the Style should contain a LineStyle with the following properties:
60+
| property | value |
61+
| color | ffddbbcc |
62+
| colorMode | random |
63+
| width | 2.75 |
64+
65+
Scenario: Style with a ListStyle
66+
Given a KML document with a Document in "tests/kml/document.kml"
67+
When I parse the KML document
68+
Then I should get a KmlDocument object containing one feature 'LibKml\Domain\Feature\Container\Document'
69+
And the feature should contain a Style object with the following properties:
70+
| property | value |
71+
| id | style-1 |
72+
| targetId | target-1 |
73+
And the Style should contain a ListStyle with the following properties:
74+
| property | value |
75+
| listItemType | radioFolder |
76+
| bgColor | 55aabbcc |
77+
78+
Scenario: Style with a PolyStyle
79+
Given a KML document with a Document in "tests/kml/document.kml"
80+
When I parse the KML document
81+
Then I should get a KmlDocument object containing one feature 'LibKml\Domain\Feature\Container\Document'
82+
And the feature should contain a Style object with the following properties:
83+
| property | value |
84+
| id | style-1 |
85+
| targetId | target-1 |
86+
And the Style should contain a PolyStyle with the following properties:
87+
| property | value |
88+
| color | ffddaa00 |
89+
| colorMode | random |
90+
| fill | 0 |
91+
| outline | 0 |

tests/kml/style.kml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,32 @@
1212
<Folder>
1313
<name>Folder 3</name>
1414
</Folder>
15+
<Style id="style-1" targetId="target-1">
16+
<BalloonStyle>
17+
<bgColor>ffffffbb</bgColor>
18+
<textColor>ff00aabb</textColor>
19+
<text>$[name]</text>
20+
<displayMode>random</displayMode>
21+
</BalloonStyle>
22+
<IconStyle>
23+
<color>a1ff00ff</color>
24+
<scale>1.399999976158142</scale>
25+
<Icon>
26+
<href>http://myserver.com/icon.jpg</href>
27+
</Icon>
28+
</IconStyle>
29+
<LabelStyle>
30+
<color>7fffaaff</color>
31+
<scale>1.5</scale>
32+
</LabelStyle>
33+
<LineStyle>
34+
<color>ff0000ff</color>
35+
<width>15</width>
36+
</LineStyle>
37+
<PolyStyle>
38+
<color>7f7faaaa</color>
39+
<colorMode>random</colorMode>
40+
</PolyStyle>
41+
</Style>
1542
</Document>
1643
</kml>

tests/src/Bdd/Read/Kml/ParserKmlContext.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Behat\Behat\Context\Context;
66
use Behat\Gherkin\Node\TableNode;
77
use LibKml\Domain\KmlDocument;
8+
use LibKml\Domain\StyleSelector\Style;
89
use LibKml\Reader\LibKmlReader;
910
use PHPUnit\Framework\TestCase;
1011

@@ -92,6 +93,27 @@ public function theFeatureShouldContainALookatObjectWithTheTheFollowingPropertie
9293
$this->containsProperties($feature->getAbstractView(), $table);
9394
}
9495

96+
/**
97+
* @Then the feature should contain a Style object with the following properties:
98+
*/
99+
public function theFeatureShouldContainAStyleObjectWithTheFollowingProperties(TableNode $table) {
100+
$styles = $this->kmlDocument->getFeature()->getStyleSelectors();
101+
102+
TestCase::assertCount(1, $styles);
103+
TestCase::assertInstanceOf(Style::class, $styles[0]);
104+
$this->containsProperties($styles[0], $table);
105+
106+
$this->target = $styles[0];
107+
}
108+
109+
/**
110+
* @Then the Style should contain a :subStyle with the following properties:
111+
*/
112+
public function theStyleShouldContainABalloonstyleWithTheFollowingProperties($subStyle, TableNode $table) {
113+
$subStyle = $this->target->{'get' . $subStyle}();
114+
$this->containsProperties($subStyle, $table);
115+
}
116+
95117
/**
96118
* @Then the NetworkLinkControl should have an AbstractView with the following properties:
97119
*/

0 commit comments

Comments
 (0)