Completed
Push — master ( 4427e6...cf958e )
by Jeroen De
03:32 queued 11s
created

testWhenZoomIsNotSpecifiedAndThereIsOnlyOneLocation_itIsDefaulted()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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