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

RectangleParserTest::testCanConstruct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Maps\Test;
4
5
use DataValues\Geo\Values\LatLongValue;
6
use Maps\Elements\Rectangle;
7
use Maps\RectangleParser;
8
9
/**
10
 * @covers Maps\RectangleParser
11
 * @licence GNU GPL v2+
12
 * @author Jeroen De Dauw < [email protected] >
13
 */
14
class RectangleParserTest 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 RectangleParser();
24
		$this->assertTrue( true );
25
	}
26
27
	public function testGivenBoundingBox_parserReturnsRectangle() {
28
		$parser = new RectangleParser();
29
30
		$rectangle = $parser->parse( '51.8357775,33.83789:46,23.37890625' );
31
32
		$this->assertInstanceOf( Rectangle::class, $rectangle );
33
34
		$expectedNorthEast = new LatLongValue( 51.8357775, 33.83789 );
35
		$this->assertTrue( $expectedNorthEast->equals( $rectangle->getRectangleNorthEast() ) );
36
37
		$expectedSouthWest = new LatLongValue( 46, 23.37890625 );
38
		$this->assertTrue( $expectedSouthWest->equals( $rectangle->getRectangleSouthWest() ) );
39
	}
40
41
	public function testGivenTitleAndText_rectangleHasProvidedMetaData() {
42
		$parser = new RectangleParser();
43
44
		$rectangle = $parser->parse( "51.8357775,33.83789:46,23.37890625~I'm a square~of doom" );
45
46
		$this->assertInstanceOf( Rectangle::class, $rectangle );
47
48
		$this->assertEquals( "I'm a square", $rectangle->getTitle() );
49
		$this->assertEquals( 'of doom', $rectangle->getText() );
50
	}
51
52
}
53