|
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
|
|
|
|