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