Completed
Push — MediaWikiFileUrlFinderTest ( d58bee...394f02 )
by Jeroen De
08:48
created

WmsOverlayParserTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 40
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testGivenValidInput_parserReturnsOverlayObject() 0 15 1
A testWhenStyleNameIsSpecified_getStyleNameReturnsIt() 0 12 1
A testWhenThereAreLessThanTwoSegments_parseExceptionIsThrown() 0 6 1
1
<?php
2
3
namespace Maps\Tests\Integration\parsers;
4
5
use Maps\Presentation\WikitextParsers\WmsOverlayParser;
6
use PHPUnit\Framework\TestCase;
7
use PHPUnit4And6Compat;
8
use ValueParsers\ParseException;
9
10
/**
11
 * @covers \Maps\Presentation\WikitextParsers\WmsOverlayParser
12
 * @licence GNU GPL v2+
13
 * @author Mathias Mølster Lidal <[email protected]>
14
 */
15
class WmsOverlayParserTest extends TestCase {
16
	use PHPUnit4And6Compat;
17
18
	public function testGivenValidInput_parserReturnsOverlayObject() {
19
		$parser = new WmsOverlayParser();
20
21
		$overlay = $parser->parse( 'http://demo.cubewerx.com/demo/cubeserv/cubeserv.cgi? Foundation.GTOPO30' );
22
23
		$this->assertSame(
24
			'http://demo.cubewerx.com/demo/cubeserv/cubeserv.cgi?',
25
			$overlay->getWmsServerUrl()
26
		);
27
28
		$this->assertSame(
29
			'Foundation.GTOPO30',
30
			$overlay->getWmsLayerName()
31
		);
32
	}
33
34
	public function testWhenStyleNameIsSpecified_getStyleNameReturnsIt() {
35
		$parser = new WmsOverlayParser();
36
37
		$overlay = $parser->parse(
38
			'http://maps.imr.no:80/geoserver/wms? vulnerable_areas:Identified_coral_area coral_identified_areas'
39
		);
40
41
		$this->assertSame(
42
			'coral_identified_areas',
43
			$overlay->getWmsStyleName()
44
		);
45
	}
46
47
	public function testWhenThereAreLessThanTwoSegments_parseExceptionIsThrown() {
48
		$parser = new WmsOverlayParser();
49
50
		$this->expectException( ParseException::class );
51
		$parser->parse( 'Such' );
52
	}
53
54
}
55