RectangleParserTest   A
last analyzed

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