CircleParserTest   A
last analyzed

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