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

CircleParserTest::setUp()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
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