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

testGivenTitleAndText_circleHasProvidedMetaData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
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