Completed
Push — merge-sm ( 44b830...c70fa4 )
by Jeroen De
10:03 queued 07:12
created

CircleParserTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 38
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 3

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 2
A testCanConstruct() 0 4 1
A testGivenCoordinateAndRadius_parserReturnsCircle() 0 12 1
A testGivenTitleAndText_circleHasProvidedMetaData() 0 10 1
1
<?php
2
3
namespace Maps\Test;
4
5
use DataValues\Geo\Values\LatLongValue;
6
use Maps\CircleParser;
7
use Maps\Elements\Circle;
8
9
/**
10
 * @covers Maps\CircleParser
11
 * @licence GNU GPL v2+
12
 * @author Jeroen De Dauw < [email protected] >
13
 */
14
class CircleParserTest extends \PHPUnit_Framework_TestCase {
15
16
	public function setUp() {
17
		if ( !defined( 'MEDIAWIKI' ) ) {
18
			$this->markTestSkipped( 'MediaWiki is not available' );
19
		}
20
	}
21
22
	public function testCanConstruct() {
23
		new CircleParser();
24
		$this->assertTrue( true );
25
	}
26
27
	public function testGivenCoordinateAndRadius_parserReturnsCircle() {
28
		$parser = new CircleParser();
29
30
		$circle = $parser->parse( '57.421,23.90625:32684.605182' );
31
32
		$this->assertInstanceOf( Circle::class, $circle );
33
34
		$expectedLatLong = new LatLongValue( 57.421, 23.90625 );
35
		$this->assertTrue( $expectedLatLong->equals( $circle->getCircleCentre() ) );
36
37
		$this->assertEquals( 32684.605182, $circle->getCircleRadius() );
38
	}
39
40
	public function testGivenTitleAndText_circleHasProvidedMetaData() {
41
		$parser = new CircleParser();
42
43
		$circle = $parser->parse( '57.421,23.90625:32684.605182~title~text' );
44
45
		$this->assertInstanceOf( Circle::class, $circle );
46
47
		$this->assertEquals( 'title', $circle->getTitle() );
48
		$this->assertEquals( 'text', $circle->getText() );
49
	}
50
51
}
52