Completed
Push — master ( cc71a9...8fd32c )
by Jeroen De
06:41
created

CircleParserTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testGivenCoordinateAndRadius_parserReturnsCircle() 0 12 1
A testGivenTitleAndText_circleHasProvidedMetaData() 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\Circle;
9
use Maps\Presentation\WikitextParsers\CircleParser;
10
use PHPUnit\Framework\TestCase;
11
12
/**
13
 * @covers \Maps\Presentation\WikitextParsers\CircleParser
14
 * @licence GNU GPL v2+
15
 * @author Jeroen De Dauw < [email protected] >
16
 */
17
class CircleParserTest extends TestCase {
18
19
	public function testGivenCoordinateAndRadius_parserReturnsCircle() {
20
		$parser = new CircleParser( new CoordinateFriendlyGeocoder( new NullGeocoder() ) );
21
22
		$circle = $parser->parse( '57.421,23.90625:32684.605182' );
23
24
		$this->assertInstanceOf( Circle::class, $circle );
25
26
		$expectedLatLong = new LatLongValue( 57.421, 23.90625 );
27
		$this->assertTrue( $expectedLatLong->equals( $circle->getCircleCentre() ) );
28
29
		$this->assertSame( 32684.605182, $circle->getCircleRadius() );
30
	}
31
32
	public function testGivenTitleAndText_circleHasProvidedMetaData() {
33
		$parser = new CircleParser( new CoordinateFriendlyGeocoder( new NullGeocoder() ) );
34
35
		$circle = $parser->parse( '57.421,23.90625:32684.605182~title~text' );
36
37
		$this->assertInstanceOf( Circle::class, $circle );
38
39
		$this->assertSame( 'title', $circle->getTitle() );
40
		$this->assertSame( 'text', $circle->getText() );
41
	}
42
43
}
44