1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare( strict_types = 1 ); |
4
|
|
|
|
5
|
|
|
namespace Maps\Tests\Integration\Parser; |
6
|
|
|
|
7
|
|
|
use MediaWiki\MediaWikiServices; |
8
|
|
|
use PHPUnit\Framework\TestCase; |
9
|
|
|
|
10
|
|
|
class GoogleMapsTest extends TestCase { |
11
|
|
|
|
12
|
|
|
private function parse( string $textToParse ): string { |
13
|
|
|
$parser = MediaWikiServices::getInstance()->getParser(); |
14
|
|
|
|
15
|
|
|
return $parser->parse( $textToParse, \Title::newMainPage(), new \ParserOptions() )->getText(); |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
public function testGoogleMapsKmlFiltersInvalidFileNames() { |
19
|
|
|
$this->assertContains( |
20
|
|
|
'"kml":["ValidFile.kml"],', |
21
|
|
|
$this->parse( |
22
|
|
|
"{{#google_maps:kml=, ,ValidFile.kml ,}}" |
23
|
|
|
) |
24
|
|
|
); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function testWhenValidZoomIsSpecified_itGetsUsed() { |
28
|
|
|
$this->assertContains( |
29
|
|
|
'"zoom":5', |
30
|
|
|
$this->parse( '{{#google_maps:1,1|zoom=5}}' ) |
31
|
|
|
); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function testWhenZoomIsNotSpecifiedAndThereIsOnlyOneLocation_itIsDefaulted() { |
35
|
|
|
$this->assertContains( |
36
|
|
|
'"zoom":' . $GLOBALS['egMapsGMaps3Zoom'], |
37
|
|
|
$this->parse( '{{#google_maps:1,1}}' ) |
38
|
|
|
); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function testWhenZoomIsNotSpecifiedAndThereAreMultipleLocations_itIsDefaulted() { |
42
|
|
|
$this->assertContains( |
43
|
|
|
'"zoom":false', |
44
|
|
|
$this->parse( '{{#google_maps:1,1;2,2}}' ) |
45
|
|
|
); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function testWhenZoomIsInvalid_itIsDefaulted() { |
49
|
|
|
$this->assertContains( |
50
|
|
|
'"zoom":' . $GLOBALS['egMapsGMaps3Zoom'], |
51
|
|
|
$this->parse( '{{#google_maps:1,1|zoom=tomato}}' ) |
52
|
|
|
); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
} |
56
|
|
|
|