Completed
Push — MediaWikiFileUrlFinderTest ( d58bee )
by Jeroen De
03:36
created

ImageOverlayTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetImage() 0 9 1
A testGivenMetaData_overlayHasProvidedMetaData() 0 10 1
A testGivenLinkWithPrefix_linkIsParsedAndPrefixIsRemoved() 0 7 1
1
<?php
2
3
namespace Maps\Tests\Unit\Elements;
4
5
use DataValues\Geo\Values\LatLongValue;
6
use Jeroen\SimpleGeocoder\Geocoders\Decorators\CoordinateFriendlyGeocoder;
7
use Jeroen\SimpleGeocoder\Geocoders\NullGeocoder;
8
use Maps\Elements\ImageOverlay;
9
use Maps\Presentation\WikitextParsers\ImageOverlayParser;
10
use PHPUnit\Framework\TestCase;
11
12
/**
13
 * @covers \Maps\Elements\ImageOverlay
14
 *
15
 * @licence GNU GPL v2+
16
 * @author Jeroen De Dauw < [email protected] >
17
 */
18
class ImageOverlayTest extends TestCase {
19
20
	public function testGetImage() {
21
		$imageOverlay = new ImageOverlay(
22
			new LatLongValue( 4, 2 ),
23
			new LatLongValue( -4, -2 ),
24
			'Foo.png'
25
		);
26
27
		$this->assertSame( 'Foo.png', $imageOverlay->getImage() );
28
	}
29
30
	public function testGivenMetaData_overlayHasProvidedMetaData() {
31
		$parser = new ImageOverlayParser( new CoordinateFriendlyGeocoder( new NullGeocoder() ) );
32
33
		$overlay = $parser->parse( "1,2:3,4:https://such.an/image.png~Semantic MediaWiki~World domination imminent!~https://such.link" );
34
35
		$this->assertSame( 'https://such.an/image.png', $overlay->getImage() );
36
		$this->assertSame( 'Semantic MediaWiki', $overlay->getTitle() );
37
		$this->assertSame( 'World domination imminent!', $overlay->getText() );
38
		$this->assertSame( 'https://such.link', $overlay->getLink() );
39
	}
40
41
	public function testGivenLinkWithPrefix_linkIsParsedAndPrefixIsRemoved() {
42
		$parser = new ImageOverlayParser( new CoordinateFriendlyGeocoder( new NullGeocoder() ) );
43
44
		$overlay = $parser->parse( "1,2:3,4:https://such.an/image.png~Semantic MediaWiki~World domination imminent!~link:https://such.link" );
45
46
		$this->assertSame( 'https://such.link', $overlay->getLink() );
47
	}
48
49
}
50
51
52
53