Skip to content

Commit

Permalink
Fix service parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
JeroenDeDauw committed Jul 4, 2018
1 parent 7810137 commit c654d4c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ different releases and which versions of PHP and MediaWiki they support, see the

Released on July 4th, 2018.

* Fixed regression introduced in 5.5.0 causing the `#display_map` parameter `service` to often be ignored
* Fixed fatal error when using `#display_map` parameter `circles`
* Fixed fatal error when using `#display_map` parameter `rectangles`
* Fixed `#display_map` parameter `rectangles` fill color modifier (it is no longer ignored)
Expand Down
2 changes: 1 addition & 1 deletion src/ParameterExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ParameterExtractor {
public function extract( array $parameterNames, array $rawParameters ) {
foreach( $parameterNames as $parameterName ) {
foreach ( $rawParameters as $rawName => $rawValue ) {
if ( strtolower( $rawName ) === $parameterName ) {
if ( trim( strtolower( $rawName ) ) === $parameterName ) {
return trim( $rawValue );
}
}
Expand Down
9 changes: 9 additions & 0 deletions tests/Integration/Parser/DisplayMapTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,13 @@ public function testRectangleFillColorIsUsed() {
);
}

public function testServiceSelectionWorksWhenItIsPrecededByMultipleParameters() {
$this->assertContains(
'maps-googlemaps3',
$this->parse(
"{{#display_map:rectangles=\n 1,1:2,2~title~text~color\n| scrollwheelzoom=off\n| service = google}}"
)
);
}

}
10 changes: 10 additions & 0 deletions tests/Unit/ParameterExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,14 @@ public function testWhenUpperCaseIsUsedInTheName_itIsStillFound() {
);
}

public function testNameHasSpacesAroundIt_itIsStillFound() {
$this->assertSame(
'value',
( new ParameterExtractor() )->extract(
[ 'name' ],
[ ' name ' => 'value' ]
)
);
}

}

0 comments on commit c654d4c

Please sign in to comment.