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

RectangleParserTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 5
dl 0
loc 28
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testGivenBoundingBox_parserReturnsRectangle() 0 13 1
A testGivenTitleAndText_rectangleHasProvidedMetaData() 0 10 1
1
<?php
2
3
namespace Maps\Tests\Integration\parsers;
4
5
use DataValues\Geo\Values\LatLongValue;
6
use Jeroen\SimpleGeocoder\Geocoders\Decorators\CoordinateFriendlyGeocoder;
7
use Jeroen\SimpleGeocoder\Geocoders\NullGeocoder;
8
use Maps\Elements\Rectangle;
9
use Maps\Presentation\WikitextParsers\RectangleParser;
10
use PHPUnit\Framework\TestCase;
11
12
/**
13
 * @covers \Maps\Presentation\WikitextParsers\RectangleParser
14
 * @licence GNU GPL v2+
15
 * @author Jeroen De Dauw < [email protected] >
16
 */
17
class RectangleParserTest extends TestCase {
18
19
	public function testGivenBoundingBox_parserReturnsRectangle() {
20
		$parser = new RectangleParser( new CoordinateFriendlyGeocoder( new NullGeocoder() ) );
21
22
		$rectangle = $parser->parse( '51.8357775,33.83789:46,23.37890625' );
23
24
		$this->assertInstanceOf( Rectangle::class, $rectangle );
25
26
		$expectedNorthEast = new LatLongValue( 51.8357775, 33.83789 );
27
		$this->assertTrue( $expectedNorthEast->equals( $rectangle->getRectangleNorthEast() ) );
28
29
		$expectedSouthWest = new LatLongValue( 46, 23.37890625 );
30
		$this->assertTrue( $expectedSouthWest->equals( $rectangle->getRectangleSouthWest() ) );
31
	}
32
33
	public function testGivenTitleAndText_rectangleHasProvidedMetaData() {
34
		$parser = new RectangleParser( new CoordinateFriendlyGeocoder( new NullGeocoder() ) );
35
36
		$rectangle = $parser->parse( "51.8357775,33.83789:46,23.37890625~I'm a square~of doom" );
37
38
		$this->assertInstanceOf( Rectangle::class, $rectangle );
39
40
		$this->assertSame( "I'm a square", $rectangle->getTitle() );
41
		$this->assertSame( 'of doom', $rectangle->getText() );
42
	}
43
44
}
45