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
|
|
|
|